Module: BSD::Capsicum::FFI::Private

Extended by:
Private
Included in:
Private
Defined in:
lib/bsd/capsicum/ffi.rb

Instance Method Summary collapse

Instance Method Details

#cap_lookup(capabilities, allowed) ⇒ Array<Integer>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a list of capabilities (as integers)

Returns:

  • (Array<Integer>)

    Returns a list of capabilities (as integers)



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/bsd/capsicum/ffi.rb', line 82

def cap_lookup(capabilities, allowed)
  capabilities.flat_map do |cap|
    if Integer === cap
      cap
    elsif allowed.include?(cap)
      FFI.const_get(cap)
    elsif allowed.include?(:"CAP_#{cap.upcase}")
      FFI.const_get(:"CAP_#{cap.upcase}")
    elsif allowed.include?(:"CAP_FCNTL_#{cap.upcase}")
      FFI.const_get(:"CAP_FCNTL_#{cap.upcase}")
    else
      raise TypeError, "unknown capability: #{cap}"
    end
  end
end

#cap_allArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all known capabilities

Returns:

  • (Array<Symbol>)

    Returns all known capabilities



102
103
104
# File 'lib/bsd/capsicum/ffi.rb', line 102

def cap_all
  @cap_all ||= Constants.constants.select { _1.to_s.start_with?("CAP_") }
end

#cap_fcntlsArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all known fcntl capabilities

Returns:

  • (Array<Symbol>)

    Returns all known fcntl capabilities



110
111
112
# File 'lib/bsd/capsicum/ffi.rb', line 110

def cap_fcntls
  @cap_fcntls ||= Constants.constants.select { _1.to_s.start_with?("CAP_FCNTL_") }
end