Add cap_all
This commit is contained in:
parent
0e0b52320f
commit
3cc2221cc3
1 changed files with 12 additions and 4 deletions
|
@ -4,11 +4,11 @@ module BSD::Capsicum
|
||||||
module FFI
|
module FFI
|
||||||
require "fiddle"
|
require "fiddle"
|
||||||
require "fiddle/import"
|
require "fiddle/import"
|
||||||
|
include Fiddle::Types
|
||||||
|
include Constants
|
||||||
extend Fiddle::Importer
|
extend Fiddle::Importer
|
||||||
dlload Dir["/lib/libc.*"].first
|
dlload Dir["/lib/libc.*"].first
|
||||||
|
|
||||||
include Fiddle::Types
|
|
||||||
include Constants
|
|
||||||
extern "int cap_getmode(u_int*)"
|
extern "int cap_getmode(u_int*)"
|
||||||
extern "int cap_enter(void)"
|
extern "int cap_enter(void)"
|
||||||
extern "int cap_rights_limit(int, const cap_rights_t*)"
|
extern "int cap_rights_limit(int, const cap_rights_t*)"
|
||||||
|
@ -53,11 +53,19 @@ module BSD::Capsicum
|
||||||
self["__cap_rights_init"].call(
|
self["__cap_rights_init"].call(
|
||||||
CAP_RIGHTS_VERSION,
|
CAP_RIGHTS_VERSION,
|
||||||
rights,
|
rights,
|
||||||
*capabilities.flat_map {
|
*capabilities.flat_map { |cap|
|
||||||
[ULONG_LONG, (Symbol === _1) ? Constants.const_get(_1) : _1]
|
[ULONG_LONG, cap_all.include?(cap) ? Constants.const_get(cap) : cap]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# @api private
|
||||||
|
# @return [Array<Symbol>]
|
||||||
|
# Returns all known capabilities
|
||||||
|
def cap_all
|
||||||
|
@cap_all ||= Constants.constants.select { _1.to_s.start_with?("CAP_") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
private_constant :FFI
|
private_constant :FFI
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue