Class: BSD::Control::Feature

Inherits:
Struct
  • Object
show all
Defined in:
lib/bsd/control/feature.rb

Instance Attribute Summary collapse

Actions collapse

Queries collapse

Predicates collapse

Class Method Summary collapse

Instance Attribute Details

#disableObject

Returns the value of attribute disable

Returns:

  • (Object)

    the current value of disable



2
3
4
# File 'lib/bsd/control/feature.rb', line 2

def disable
  @disable
end

#enableObject

Returns the value of attribute enable

Returns:

  • (Object)

    the current value of enable



2
3
4
# File 'lib/bsd/control/feature.rb', line 2

def enable
  @enable
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/bsd/control/feature.rb', line 2

def name
  @name
end

Class Method Details

.availableArray<BSD::Control::Feature>

Returns an array of available features.

Returns:



6
7
8
# File 'lib/bsd/control/feature.rb', line 6

def self.available
  BSD::Control::FFI.available_features
end

Instance Method Details

#aslr?Boolean

Returns true for the ASLR feature.

Returns:

  • (Boolean)

    Returns true for the ASLR feature.



149
150
151
# File 'lib/bsd/control/feature.rb', line 149

def aslr?
  name == "aslr"
end

#conflict?(path) ⇒ Boolean

Returns true when a feature is in conflict (i.e: the feature is both enabled and disabled at the same time).

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true when a feature is in conflict (i.e: the feature is both enabled and disabled at the same time).



100
101
102
# File 'lib/bsd/control/feature.rb', line 100

def conflict?(path)
  status(path) == :conflict
end

#disable!(path) ⇒ Boolean

Disables a feature for a given file.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true on success.

Raises:

  • (SystemCallError)

    Might raise a number of Errno exceptions.



39
40
41
# File 'lib/bsd/control/feature.rb', line 39

def disable!(path)
  set!(path, BSD::Control::Disable)
end

#disabled?(path) ⇒ Boolean

Returns true when a feature is disabled for a given file.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true when a feature is disabled for a given file.



79
80
81
# File 'lib/bsd/control/feature.rb', line 79

def disabled?(path)
  status(path) == :disabled
end

#disallow_map32bit?Boolean

Returns true for the disallow-map32bit feature.

Returns:

  • (Boolean)

    Returns true for the disallow-map32bit feature.



163
164
165
# File 'lib/bsd/control/feature.rb', line 163

def disallow_map32bit?
  name == "disallow_map32bit"
end

#enable!(path) ⇒ Boolean

Enables a feature for a given file.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true on success.

Raises:

  • (SystemCallError)

    Might raise a number of Errno exceptions.



24
25
26
# File 'lib/bsd/control/feature.rb', line 24

def enable!(path)
  set!(path, BSD::Control::Enable)
end

#enabled?(path) ⇒ Boolean

Returns true when a feature is enabled for a given file.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true when a feature is enabled for a given file.



69
70
71
# File 'lib/bsd/control/feature.rb', line 69

def enabled?(path)
  status(path) == :enabled
end

#harden_shm?Boolean

Returns true for the harden SHM feature.

Returns:

  • (Boolean)

    Returns true for the harden SHM feature.



177
178
179
# File 'lib/bsd/control/feature.rb', line 177

def harden_shm?
  name == "harden_shm"
end

#insecure_kmod?Boolean

Returns true for the insecure kmod feature.

Returns:

  • (Boolean)

    Returns true for the insecure kmod feature.



170
171
172
# File 'lib/bsd/control/feature.rb', line 170

def insecure_kmod?
  name == "insecure_kmod"
end

#mprotect?Boolean

Returns true for the mprotect feature.

Returns:

  • (Boolean)

    Returns true for the mprotect feature.



135
136
137
# File 'lib/bsd/control/feature.rb', line 135

def mprotect?
  name == "mprotect"
end

#pageexec?Boolean

Returns true for the pageexec feature.

Returns:

  • (Boolean)

    Returns true for the pageexec feature.



128
129
130
# File 'lib/bsd/control/feature.rb', line 128

def pageexec?
  name == "pageexec"
end

#prohibit_ptrace_capsicum?Boolean

Returns true for the prohibit ptrace capsicum feature.

Returns:

  • (Boolean)

    Returns true for the prohibit ptrace capsicum feature.



184
185
186
# File 'lib/bsd/control/feature.rb', line 184

def prohibit_ptrace_capsicum?
  name == "prohibit_ptrace_capsicum"
end

#segvguard?Boolean

Returns true for the segv-guard feature.

Returns:

  • (Boolean)

    Returns true for the segv-guard feature.



142
143
144
# File 'lib/bsd/control/feature.rb', line 142

def segvguard?
  name == "segvguard"
end

#shlibrandom?Boolean

Returns true for the shlibrandom feature.

Returns:

  • (Boolean)

    Returns true for the shlibrandom feature.



156
157
158
# File 'lib/bsd/control/feature.rb', line 156

def shlibrandom?
  name == "shlibrandom"
end

#status(path) ⇒ Symbol

Returns the status of a feature for a given file. Status can be one of: ‘:conflict`, `:sysdef`, `:enabled`, `:disabled`.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Symbol)

    Returns the status of a feature for a given file. Status can be one of: ‘:conflict`, `:sysdef`, `:enabled`, `:disabled`.

Raises:

  • (SystemCallError)

    Might raise a number of Errno exceptions.



114
115
116
117
118
# File 'lib/bsd/control/feature.rb', line 114

def status(path)
  FFI.status(self, path)
rescue Errno::ENOATTR
  :sysdef
end

#sysdef!(path) ⇒ Boolean

Restore system defaults for a given file.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true on success.

Raises:

  • (SystemCallError)

    Might raise a number of Errno exceptions.



54
55
56
# File 'lib/bsd/control/feature.rb', line 54

def sysdef!(path)
  FFI.sysdef!(self, path)
end

#sysdef?(path) ⇒ Boolean

Returns true when a feature is configured to use the system default.

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true when a feature is configured to use the system default.



89
90
91
# File 'lib/bsd/control/feature.rb', line 89

def sysdef?(path)
  status(path) == :sysdef
end