bsdcapsicum.rb/lib/bsd/capsicum/ffi.rb

37 lines
711 B
Ruby
Raw Normal View History

2024-06-25 08:25:53 +02:00
# @api private
module BSD::Capsicum
2024-06-25 09:37:54 +02:00
module FFI
2024-06-25 08:25:53 +02:00
require "fiddle"
module_function
##
# Provides a Ruby interface for cap_enter(2)
# @return [Integer]
def cap_enter
Fiddle::Function.new(
libc["cap_enter"],
[],
Fiddle::Types::INT
).call
end
##
# Provides a Ruby interface for cap_getmode(2)
# @param [Fiddle::Pointer] uintp
# @return [Integer]
def cap_getmode(uintp)
Fiddle::Function.new(
libc["cap_getmode"],
[Fiddle::Types::INTPTR_T],
Fiddle::Types::INT
).call(uintp)
end
##
# @api private
def libc
@libc ||= Fiddle.dlopen Dir["/lib/libc.*"].first
end
end
end