module Keyutils::Lib
Constants
- KEYCTL
keyctl commands
- KEY_REQKEY_DEFL
request-key default keyrings
- KEY_SPEC
special process keyring shortcut IDs
Public Class Methods
attach_function(fname, *a, errors: {})
click to toggle source
Attach a C function that can raise error (eg. through return type converter), allowing to provide errorclass => description map
# File lib/keyutils/lib.rb, line 85 def self.attach_function fname, *a, errors: {}, **kwargs function = FFI::Library.instance_method(:attach_function).bind(self).call fname, *a, **kwargs singleton_class.send :define_method, fname, ->(*a) do begin function.call *a rescue Exception => e msg = errors[e.class] || e.message call = caller_locations(2, 1).first call_desc = "#{call.absolute_path}:#{call.lineno}:in `#{fname}'" raise e, msg, [call_desc] + caller(2) end end end
attach_text_string(name)
click to toggle source
# File lib/keyutils/lib.rb, line 8 def self.attach_text_string name val = @@lib.find_variable(name.to_s).get_string 0 singleton_class.send :define_method, name, ->() { val } end