Ruby bindings for libhbsdcontrol(3)
Go to file
2024-07-08 14:13:12 -03:00
.bundle First commit 2024-02-29 22:29:43 -03:00
bin Move readme_examples_test.rb 2024-05-12 22:49:15 -03:00
ext/bsdcontrol.rb Add errno.h include directive to glue.c 2024-05-14 20:56:37 -03:00
lib v0.2.1 2024-05-14 20:57:20 -03:00
share/bsdcontrol.rb/examples Add standard 2024-05-12 00:59:38 -03:00
test Update docs 2024-06-20 23:09:33 -03:00
.clang-format Bump indent width to 4 2024-05-12 19:11:11 -03:00
.editorconfig Add .editorconfig 2024-05-12 19:11:57 -03:00
.gitignore Update test/ 2024-05-12 22:44:29 -03:00
.projectile First commit 2024-02-29 22:29:43 -03:00
.rubocop.yml Update .rubocop.yml 2024-05-13 16:05:08 -03:00
bsdcontrol.rb.gemspec Update docs 2024-06-20 23:09:33 -03:00
Gemfile Add standard 2024-05-12 00:59:38 -03:00
Gemfile.lock Update docs 2024-06-20 23:09:33 -03:00
LICENSE Add LICENSE 2024-02-29 22:35:05 -03:00
Rakefile.rb Update Rakefile.rb 2024-05-12 01:09:26 -03:00
README.md Update sources 2024-07-08 14:13:12 -03:00

About

bsdcontrol.rb provides Ruby bindings for libhbsdcontrol.

Examples

Features

The first example prints a list of HardenedBSD features that can be enabled, disabled or restored to the system default setting:

#!/usr/bin/env ruby
# Required privileges: user, superuser
require "bsdcontrol"
BSD::Control
  .available_features
  .each do
  print "The ", _1.name, " feature is available", "\n"
end

Enable

The following example enables the mprotect feature for the emacs binary. When a feature is enabled for a given file, that setting takes precendence over the system default. The system default can be restored with BSD::Control::Feature#sysdef!:

#!/usr/bin/env ruby
# Required privileges: superuser
require "bsdcontrol"
BSD::Control
  .feature(:mprotect)
  .enable!("/usr/local/bin/emacs-29.2")

Status

There are five recognized statuses: unknown, enabled, disabled, sysdef, and invalid. The sysdef status indicates that a feature is configured to use the system default, and it is the most common status:

#!/usr/bin/env ruby
# Required privileges: superuser
require "bsdcontrol"
BSD::Control
  .feature(:mprotect)
  .status("/bin/ls") # => :sysdef

Documentation

A complete API reference is available at 0x1eef.github.io/x/bsdcontrol.rb

Install

bsdcontrol.rb can be installed via rubygems.org:

gem install bsdcontrol.rb

Sources

License

BSD Zero Clause
See LICENSE