Update set_rights

This commit is contained in:
0x1eef 2024-07-12 04:46:29 -03:00
parent 5d8a05fb22
commit 8839b1f4d4

View file

@ -62,11 +62,8 @@ module BSD::Capsicum
def set_rights!(io, capabilities) def set_rights!(io, capabilities)
rights = Fiddle::Pointer.malloc(Constants::SIZEOF_CAP_RIGHTS_T) rights = Fiddle::Pointer.malloc(Constants::SIZEOF_CAP_RIGHTS_T)
FFI.cap_rights_init(rights, *capabilities) FFI.cap_rights_init(rights, *capabilities)
if FFI.cap_rights_limit(io.to_i, rights).zero? FFI.cap_rights_limit(io.to_i, rights).zero? ||
true raise(SystemCallError.new("cap_rights_limit", Fiddle.last_error))
else
raise SystemCallError.new("cap_rights_limit", Fiddle.last_error)
end
ensure ensure
rights.call_free rights.call_free
end end