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

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/bsd/control/feature.rb', line 4

def name
  @name
end

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



4
5
6
# File 'lib/bsd/control/feature.rb', line 4

def context
  @context
end

Class Method Details

.availableArray<BSD::Control::Feature>

Returns an array of available features

Returns:



8
9
10
# File 'lib/bsd/control/feature.rb', line 8

def self.available
  BSD::Control.available_features
end

Instance Method Details

#prohibit_ptrace_capsicum?Boolean

Returns true for prohibit_ptrace_capsicum

Returns:

  • (Boolean)

    Returns true for prohibit_ptrace_capsicum



181
182
183
# File 'lib/bsd/control/feature.rb', line 181

def prohibit_ptrace_capsicum?
  name == "prohibit_ptrace_capsicum"
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



26
27
28
# File 'lib/bsd/control/feature.rb', line 26

def enable!(path)
  set!(path, ENABLED)
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



41
42
43
# File 'lib/bsd/control/feature.rb', line 41

def disable!(path)
  set!(path, DISABLED)
end

#sysdef!(path) ⇒ Boolean

Restores the system default 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



# File 'lib/bsd/control/feature.rb', line 45

#enabled?(path) ⇒ Boolean

Returns true when a feature is enabled

Parameters:

  • path (String)

    The path to a file

Returns:

  • (Boolean)

    Returns true when a feature is enabled



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

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

#disabled?(path) ⇒ Boolean

Returns true when a feature is disabled

Parameters:

  • path (String)

    The path to a file.

Returns:

  • (Boolean)

    Returns true when a feature is disabled



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

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

#sysdef?(path) ⇒ Boolean

Returns true when the system default setting is used

Parameters:

  • path (String)

    The path to a file

Returns:

  • (Boolean)

    Returns true when the system default setting is used



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

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

#invalid?(path) ⇒ Boolean

Returns true when a feature is in an invalid state (eg: 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 an invalid state (eg: the feature is both enabled and disabled at the same time)



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

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

#status(path) ⇒ Symbol

Returns the status of a feature for a given file. Status could be: :unknown, :enabled, :disabled, :sysdef, or :invalid.

Parameters:

  • path (String)

    The path to a file

Returns:

  • (Symbol)

    Returns the status of a feature for a given file. Status could be: :unknown, :enabled, :disabled, :sysdef, or :invalid.

Raises:

  • (SystemCallError)

    Might raise a number of Errno exceptions



# File 'lib/bsd/control/feature.rb', line 104

#pageexec?Boolean

Returns true for pageexec

Returns:

  • (Boolean)

    Returns true for pageexec



125
126
127
# File 'lib/bsd/control/feature.rb', line 125

def pageexec?
  name == "pageexec"
end

#mprotect?Boolean

Returns true for mprotect

Returns:

  • (Boolean)

    Returns true for mprotect



132
133
134
# File 'lib/bsd/control/feature.rb', line 132

def mprotect?
  name == "mprotect"
end

#segvguard?Boolean

Returns true for segvguard

Returns:

  • (Boolean)

    Returns true for segvguard



139
140
141
# File 'lib/bsd/control/feature.rb', line 139

def segvguard?
  name == "segvguard"
end

#aslr?Boolean

Returns true for aslr

Returns:

  • (Boolean)

    Returns true for aslr



146
147
148
# File 'lib/bsd/control/feature.rb', line 146

def aslr?
  name == "aslr"
end

#shlibrandom?Boolean

Returns true for shlibrandom

Returns:

  • (Boolean)

    Returns true for shlibrandom



153
154
155
# File 'lib/bsd/control/feature.rb', line 153

def shlibrandom?
  name == "shlibrandom"
end

#disallow_map32bit?Boolean

Returns true for disallow_map32bit

Returns:

  • (Boolean)

    Returns true for disallow_map32bit



160
161
162
# File 'lib/bsd/control/feature.rb', line 160

def disallow_map32bit?
  name == "disallow_map32bit"
end

#insecure_kmod?Boolean

Returns true for insecure_kmod

Returns:

  • (Boolean)

    Returns true for insecure_kmod



167
168
169
# File 'lib/bsd/control/feature.rb', line 167

def insecure_kmod?
  name == "insecure_kmod"
end

#harden_shm?Boolean

Returns true for harden_shm

Returns:

  • (Boolean)

    Returns true for harden_shm



174
175
176
# File 'lib/bsd/control/feature.rb', line 174

def harden_shm?
  name == "harden_shm"
end