Map HBSDCTRL_STATE_(ENABLED|DISABLED) into Ruby
And fix `BSD::Control::Feature#disable!`.
This commit is contained in:
parent
a4e5b8893f
commit
275d622843
3 changed files with 16 additions and 2 deletions
|
@ -20,4 +20,6 @@ Init_bsdcontrol(void)
|
|||
rb_define_method(rb_cFeature, "status", bsdcontrol_feature_status, 1);
|
||||
rb_define_method(rb_cFeature, "sysdef!", bsdcontrol_feature_sysdef, 1);
|
||||
rb_define_private_method(rb_cFeature, "set!", bsdcontrol_feature_set, 2);
|
||||
rb_define_const(rb_cFeature, "ENABLED", INT2NUM(HBSDCTRL_STATE_ENABLED));
|
||||
rb_define_const(rb_cFeature, "DISABLED", INT2NUM(HBSDCTRL_STATE_DISABLED));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ module BSD::Control
|
|||
# @return [Boolean]
|
||||
# Returns true on success.
|
||||
def enable!(path)
|
||||
set!(path, 1)
|
||||
set!(path, ENABLED)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -37,7 +37,7 @@ module BSD::Control
|
|||
# @return [Boolean]
|
||||
# Returns true on success.
|
||||
def disable!(path)
|
||||
set!(path, 0)
|
||||
set!(path, DISABLED)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -4,6 +4,18 @@ module BSD::Control
|
|||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
def test_disable_pageexec
|
||||
touch(file)
|
||||
assert BSD::Control.feature(:pageexec).disable!(file),
|
||||
"The disable! method should have returned true"
|
||||
assert_equal(
|
||||
:disabled,
|
||||
BSD::Control.feature(:pageexec).status(file)
|
||||
)
|
||||
ensure
|
||||
rm(file)
|
||||
end
|
||||
|
||||
def test_disable_pageexec_nonexistent_file
|
||||
assert_raises(Errno::ENOENT) do
|
||||
BSD::Control.feature(:pageexec).disable!(file)
|
||||
|
|
Loading…
Reference in a new issue