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



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

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



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

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



35
36
37
# File 'lib/bsd/control/feature.rb', line 35

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 39

#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



59
60
61
# File 'lib/bsd/control/feature.rb', line 59

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



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

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



77
78
79
# File 'lib/bsd/control/feature.rb', line 77

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)



87
88
89
# File 'lib/bsd/control/feature.rb', line 87

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 91

#pageexec?Boolean

Returns true for pageexec

Returns:

  • (Boolean)

    Returns true for pageexec



110
111
112
# File 'lib/bsd/control/feature.rb', line 110

def pageexec?
  name == "pageexec"
end

#mprotect?Boolean

Returns true for mprotect

Returns:

  • (Boolean)

    Returns true for mprotect



117
118
119
# File 'lib/bsd/control/feature.rb', line 117

def mprotect?
  name == "mprotect"
end

#segvguard?Boolean

Returns true for segvguard

Returns:

  • (Boolean)

    Returns true for segvguard



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

def segvguard?
  name == "segvguard"
end

#aslr?Boolean

Returns true for aslr

Returns:

  • (Boolean)

    Returns true for aslr



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

def aslr?
  name == "aslr"
end

#shlibrandom?Boolean

Returns true for shlibrandom

Returns:

  • (Boolean)

    Returns true for shlibrandom



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

def shlibrandom?
  name == "shlibrandom"
end

#disallow_map32bit?Boolean

Returns true for disallow_map32bit

Returns:

  • (Boolean)

    Returns true for disallow_map32bit



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

def disallow_map32bit?
  name == "disallow_map32bit"
end

#insecure_kmod?Boolean

Returns true for insecure_kmod

Returns:

  • (Boolean)

    Returns true for insecure_kmod



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

def insecure_kmod?
  name == "insecure_kmod"
end

#harden_shm?Boolean

Returns true for harden_shm

Returns:

  • (Boolean)

    Returns true for harden_shm



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

def harden_shm?
  name == "harden_shm"
end