Class: Seccomp::Notification
- Inherits:
-
Object
- Object
- Seccomp::Notification
- Defined in:
- lib/seccomp/notification.rb
Overview
One immutable user-notification request.
Constant Summary collapse
- ATTRIBUTES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Fields copied from the kernel notification request.
%i[id pid flags syscall arch instruction_pointer args].freeze
Instance Attribute Summary collapse
-
#arch ⇒ Object
readonly
Returns the value of attribute arch.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#instruction_pointer ⇒ Object
readonly
Returns the value of attribute instruction_pointer.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#syscall ⇒ Object
readonly
Returns the value of attribute syscall.
Instance Method Summary collapse
-
#add_fd(io, flags: 0, newfd: 0, newfd_flags: 0) ⇒ Integer
Installed descriptor.
- #allow(value = 0) ⇒ nil
- #continue! ⇒ nil
- #deny(errno) ⇒ nil
- #initialize(notifier, data) ⇒ void constructor
- #respond(val: 0, error: 0, flags: 0) ⇒ nil
-
#valid? ⇒ Boolean
Whether the kernel still recognizes the request.
Constructor Details
#initialize(notifier, data) ⇒ void
15 16 17 18 19 |
# File 'lib/seccomp/notification.rb', line 15 def initialize(notifier, data) @notifier = notifier ATTRIBUTES.each { |attribute| instance_variable_set("@#{attribute}", data.fetch(attribute)) } @args.freeze end |
Instance Attribute Details
#arch ⇒ Object (readonly)
Returns the value of attribute arch.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def arch @arch end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def args @args end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def flags @flags end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def id @id end |
#instruction_pointer ⇒ Object (readonly)
Returns the value of attribute instruction_pointer.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def instruction_pointer @instruction_pointer end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def pid @pid end |
#syscall ⇒ Object (readonly)
Returns the value of attribute syscall.
9 10 11 |
# File 'lib/seccomp/notification.rb', line 9 def syscall @syscall end |
Instance Method Details
#add_fd(io, flags: 0, newfd: 0, newfd_flags: 0) ⇒ Integer
Returns installed descriptor.
73 74 75 76 |
# File 'lib/seccomp/notification.rb', line 73 def add_fd(io, flags: 0, newfd: 0, newfd_flags: 0) @notifier.add_fd(id: id, source_fd: io.fileno, flags: flags, newfd: newfd, newfd_flags: newfd_flags) end |
#allow(value = 0) ⇒ nil
43 44 45 |
# File 'lib/seccomp/notification.rb', line 43 def allow(value = 0) respond(val: value) end |
#continue! ⇒ nil
62 63 64 |
# File 'lib/seccomp/notification.rb', line 62 def continue! respond(flags: LowLevel::USER_NOTIF_FLAG_CONTINUE) end |
#deny(errno) ⇒ nil
52 53 54 55 56 57 |
# File 'lib/seccomp/notification.rb', line 52 def deny(errno) number = errno_number(errno) raise ArgumentError, "errno must not be zero" if number.zero? respond(error: -number.abs) end |
#respond(val: 0, error: 0, flags: 0) ⇒ nil
34 35 36 37 |
# File 'lib/seccomp/notification.rb', line 34 def respond(val: 0, error: 0, flags: 0) error = -errno_number(error).abs unless error.is_a?(Integer) && error.zero? @notifier.respond(id: id, val: val, error: error, flags: flags) end |
#valid? ⇒ Boolean
Returns whether the kernel still recognizes the request.
24 25 26 |
# File 'lib/seccomp/notification.rb', line 24 def valid? @notifier.id_valid?(id) end |