Update docs
This commit is contained in:
parent
876371226a
commit
5de096abde
3 changed files with 39 additions and 39 deletions
|
@ -11,7 +11,7 @@ VALUE
|
||||||
bsdcontrol_context_alloc(VALUE klass)
|
bsdcontrol_context_alloc(VALUE klass)
|
||||||
{
|
{
|
||||||
hbsdctrl_ctx_t *ctx;
|
hbsdctrl_ctx_t *ctx;
|
||||||
ctx = hbsdctrl_ctx_new(FLAGS, NAMESPACE);
|
ctx = hbsdctrl_ctx_new(FLAGS, NAMESPACE);
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
{
|
{
|
||||||
rb_raise(rb_eSystemCallError, "hbsdctrl_ctx_new");
|
rb_raise(rb_eSystemCallError, "hbsdctrl_ctx_new");
|
||||||
|
|
|
@ -8,21 +8,21 @@ module BSD::Control
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [BSD::Control::Context]
|
# @return [BSD::Control::Context]
|
||||||
# Returns an instance of {BSD::Control::Context BSD::Control::Context}.
|
# Returns an instance of {BSD::Control::Context BSD::Control::Context}
|
||||||
def self.context
|
def self.context
|
||||||
@context ||= BSD::Control::Context.new
|
@context ||= BSD::Control::Context.new
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [String]
|
# @return [String]
|
||||||
# Returns the version of libhbsdcontrol.
|
# Returns the version of libhbsdcontrol
|
||||||
def self.library_version
|
def self.library_version
|
||||||
context.library_version
|
context.library_version
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Array<BSD::Control::Feature>]
|
# @return [Array<BSD::Control::Feature>]
|
||||||
# Returns an array of available features.
|
# Returns an array of available features
|
||||||
def self.available_features
|
def self.available_features
|
||||||
context.available_features
|
context.available_features
|
||||||
end
|
end
|
||||||
|
@ -34,16 +34,16 @@ module BSD::Control
|
||||||
# .enable!("/usr/local/bin/emacs-29.2")
|
# .enable!("/usr/local/bin/emacs-29.2")
|
||||||
#
|
#
|
||||||
# @param [String] name
|
# @param [String] name
|
||||||
# The name of a feature.
|
# The name of a feature
|
||||||
#
|
#
|
||||||
# @raise [BSD::Control::Error]
|
# @raise [BSD::Control::Error]
|
||||||
# When a feature is not found.
|
# When a feature wasn't found
|
||||||
#
|
#
|
||||||
# @return [BSD::Control::Feature]
|
# @return [BSD::Control::Feature]
|
||||||
# Returns an instance of {BSD::Control::Feature BSD::Control::Feature}.
|
# Returns an instance of {BSD::Control::Feature BSD::Control::Feature}
|
||||||
def self.feature(name)
|
def self.feature(name)
|
||||||
feature = available_features.find { _1.name == name.to_s }
|
feature = available_features.find { _1.name == name.to_s }
|
||||||
feature || raise(Error, "feature '#{name}' wasn't found")
|
feature || raise(Error, "'#{name}' wasn't found")
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative "control/context"
|
require_relative "control/context"
|
||||||
|
|
|
@ -4,7 +4,7 @@ module BSD::Control
|
||||||
class Feature < Struct.new(:name, :context)
|
class Feature < Struct.new(:name, :context)
|
||||||
##
|
##
|
||||||
# @return [Array<BSD::Control::Feature>]
|
# @return [Array<BSD::Control::Feature>]
|
||||||
# Returns an array of available features.
|
# Returns an array of available features
|
||||||
def self.available
|
def self.available
|
||||||
BSD::Control.available_features
|
BSD::Control.available_features
|
||||||
end
|
end
|
||||||
|
@ -13,47 +13,47 @@ module BSD::Control
|
||||||
# @group Actions
|
# @group Actions
|
||||||
|
|
||||||
##
|
##
|
||||||
# Enables a feature for a given file.
|
# Enables a feature for a given file
|
||||||
#
|
#
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @raise [SystemCallError]
|
# @raise [SystemCallError]
|
||||||
# Might raise a number of Errno exceptions.
|
# Might raise a number of Errno exceptions
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true on success.
|
# Returns true on success
|
||||||
def enable!(path)
|
def enable!(path)
|
||||||
set!(path, ENABLED)
|
set!(path, ENABLED)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Disables a feature for a given file.
|
# Disables a feature for a given file
|
||||||
#
|
#
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @raise [SystemCallError]
|
# @raise [SystemCallError]
|
||||||
# Might raise a number of Errno exceptions.
|
# Might raise a number of Errno exceptions
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true on success.
|
# Returns true on success
|
||||||
def disable!(path)
|
def disable!(path)
|
||||||
set!(path, DISABLED)
|
set!(path, DISABLED)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @!method sysdef!(path)
|
# @!method sysdef!(path)
|
||||||
# Restores the system default for a given file.
|
# Restores the system default for a given file
|
||||||
#
|
#
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @raise [SystemCallError]
|
# @raise [SystemCallError]
|
||||||
# Might raise a number of Errno exceptions.
|
# Might raise a number of Errno exceptions
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true on success.
|
# Returns true on success
|
||||||
|
|
||||||
# @endgroup
|
# @endgroup
|
||||||
|
|
||||||
|
@ -62,10 +62,10 @@ module BSD::Control
|
||||||
|
|
||||||
##
|
##
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true when a feature is enabled for a given file.
|
# Returns true when a feature is enabled
|
||||||
def enabled?(path)
|
def enabled?(path)
|
||||||
status(path) == :enabled
|
status(path) == :enabled
|
||||||
end
|
end
|
||||||
|
@ -75,28 +75,28 @@ module BSD::Control
|
||||||
# The path to a file.
|
# The path to a file.
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true when a feature is disabled for a given file.
|
# Returns true when a feature is disabled
|
||||||
def disabled?(path)
|
def disabled?(path)
|
||||||
status(path) == :disabled
|
status(path) == :disabled
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true when a feature is configured to use the system default.
|
# Returns true when the system default setting is used
|
||||||
def sysdef?(path)
|
def sysdef?(path)
|
||||||
status(path) == :sysdef
|
status(path) == :sysdef
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true when a feature is in an invalid state
|
# Returns true when a feature is in an invalid state
|
||||||
# (eg: the feature is both enabled and disabled at the same time).
|
# (eg: the feature is both enabled and disabled at the same time)
|
||||||
def invalid?(path)
|
def invalid?(path)
|
||||||
status(path) == :invalid
|
status(path) == :invalid
|
||||||
end
|
end
|
||||||
|
@ -104,10 +104,10 @@ module BSD::Control
|
||||||
##
|
##
|
||||||
# @!method status(path)
|
# @!method status(path)
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# The path to a file.
|
# The path to a file
|
||||||
#
|
#
|
||||||
# @raise [SystemCallError]
|
# @raise [SystemCallError]
|
||||||
# Might raise a number of Errno exceptions.
|
# Might raise a number of Errno exceptions
|
||||||
#
|
#
|
||||||
# @return [Symbol]
|
# @return [Symbol]
|
||||||
# Returns the status of a feature for a given file.
|
# Returns the status of a feature for a given file.
|
||||||
|
@ -121,63 +121,63 @@ module BSD::Control
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the pageexec feature.
|
# Returns true for `pageexec`
|
||||||
def pageexec?
|
def pageexec?
|
||||||
name == "pageexec"
|
name == "pageexec"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the mprotect feature.
|
# Returns true for `mprotect`
|
||||||
def mprotect?
|
def mprotect?
|
||||||
name == "mprotect"
|
name == "mprotect"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the segv-guard feature.
|
# Returns true for `segvguard`
|
||||||
def segvguard?
|
def segvguard?
|
||||||
name == "segvguard"
|
name == "segvguard"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the ASLR feature.
|
# Returns true for `aslr`
|
||||||
def aslr?
|
def aslr?
|
||||||
name == "aslr"
|
name == "aslr"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the shlibrandom feature.
|
# Returns true for `shlibrandom`
|
||||||
def shlibrandom?
|
def shlibrandom?
|
||||||
name == "shlibrandom"
|
name == "shlibrandom"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the disallow-map32bit feature.
|
# Returns true for `disallow_map32bit`
|
||||||
def disallow_map32bit?
|
def disallow_map32bit?
|
||||||
name == "disallow_map32bit"
|
name == "disallow_map32bit"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the insecure kmod feature.
|
# Returns true for `insecure_kmod`
|
||||||
def insecure_kmod?
|
def insecure_kmod?
|
||||||
name == "insecure_kmod"
|
name == "insecure_kmod"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the harden SHM feature.
|
# Returns true for `harden_shm`
|
||||||
def harden_shm?
|
def harden_shm?
|
||||||
name == "harden_shm"
|
name == "harden_shm"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Returns true for the prohibit ptrace capsicum feature.
|
# Returns true for `prohibit_ptrace_capsicum`
|
||||||
def prohibit_ptrace_capsicum?
|
def prohibit_ptrace_capsicum?
|
||||||
name == "prohibit_ptrace_capsicum"
|
name == "prohibit_ptrace_capsicum"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue