2024-03-01 02:29:43 +01:00
|
|
|
## About
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-08 02:35:34 +01:00
|
|
|
hbsdctl.rb is a C extension that binds libhbsdcontrol from the
|
|
|
|
[hardenedbsd](https://hardenedbsd.org) project to Ruby. Through
|
|
|
|
this library, you can query what features are available and if
|
|
|
|
root, enable or disable those features for a given file.
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
## Examples
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
__Available features__
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
As a regular user account, you can obtain a list of available features.
|
|
|
|
But to enable or disable those features a superuser account is required:
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
``` ruby
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# As a regular user account
|
|
|
|
require 'hbsdctl'
|
|
|
|
BSD::Control
|
|
|
|
.available_features
|
|
|
|
.each do
|
|
|
|
print "The ", _1.name, " feature is available", "\n"
|
|
|
|
end
|
2024-03-01 02:28:22 +01:00
|
|
|
```
|
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
__Enable feature__
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-01 05:05:42 +01:00
|
|
|
As a superuser account, you can enable or disable features for a given file.
|
2024-03-01 02:29:43 +01:00
|
|
|
The example enables the mprotect feature for the emacs binary:
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
``` ruby
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# As a root account
|
|
|
|
require 'hbsdctl'
|
|
|
|
BSD::Control
|
2024-03-01 02:40:38 +01:00
|
|
|
.feature!(:mprotect)
|
2024-03-08 02:35:34 +01:00
|
|
|
.enable!("/usr/local/bin/emacs-29.2")
|
2024-03-01 02:29:43 +01:00
|
|
|
```
|
2024-03-01 02:28:22 +01:00
|
|
|
|
2024-03-08 02:35:34 +01:00
|
|
|
## Documentation
|
|
|
|
|
|
|
|
A complete API reference is available at
|
|
|
|
[0x1eef.github.io/x/hbsdctl.rb](https://0x1eef.github.io/x/hbsdctl.rb).
|
|
|
|
|
2024-03-01 02:35:05 +01:00
|
|
|
## Install
|
|
|
|
|
|
|
|
**Git**
|
|
|
|
|
|
|
|
hbsdctl.rb is distributed as a RubyGem through its git repositories. <br>
|
|
|
|
[GitHub](https://github.com/0x1eef/hbsdctl.rb),
|
|
|
|
and
|
|
|
|
[GitLab](https://gitlab.com/0x1eef/hbsdctl.rb)
|
|
|
|
are available as sources.
|
|
|
|
|
|
|
|
**Rubygems.org**
|
|
|
|
|
2024-03-01 03:49:37 +01:00
|
|
|
hbsdctl.rb can also be installed via rubygems.org.
|
2024-03-01 02:35:05 +01:00
|
|
|
|
|
|
|
gem install hbsdctl.rb
|
|
|
|
|
2024-03-01 02:28:22 +01:00
|
|
|
## License
|
|
|
|
|
2024-03-01 02:29:43 +01:00
|
|
|
[BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
|
|
|
|
<br>
|
|
|
|
See [LICENSE](./LICENSE).
|
|
|
|
|