Module: Seccomp::Attributes
- Included in:
- Filter
- Defined in:
- lib/seccomp/attributes.rb
Overview
Named accessors for libseccomp filter attributes.
Constant Summary collapse
- ATTRIBUTE_NAMES =
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.
Symbol-to-C-attribute lookup.
{ default_action: FilterAttr::ACT_DEFAULT, bad_arch_action: FilterAttr::ACT_BADARCH, no_new_privs: FilterAttr::CTL_NNP, tsync: FilterAttr::CTL_TSYNC, tskip: FilterAttr::API_TSKIP, log: FilterAttr::CTL_LOG, ssb: FilterAttr::CTL_SSB, optimize: FilterAttr.const_defined?(:CTL_OPTIMIZE) ? FilterAttr::CTL_OPTIMIZE : nil, raw_rc: FilterAttr.const_defined?(:API_SYSRAWRC) ? FilterAttr::API_SYSRAWRC : nil, wait_killable: FilterAttr.const_defined?(:CTL_WAITKILL) ? FilterAttr::CTL_WAITKILL : nil }.compact.freeze
- BOOLEAN_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.
Attributes exposed as predicate accessors.
%i[no_new_privs tsync tskip log ssb raw_rc wait_killable].freeze
- ATTRIBUTE_API_LEVELS =
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.
Minimum runtime API level for newer attributes.
{ FilterAttr::CTL_TSYNC => 2, FilterAttr::CTL_LOG => 3, FilterAttr::CTL_SSB => 4, (FilterAttr::CTL_WAITKILL if FilterAttr.const_defined?(:CTL_WAITKILL)) => 7 }.compact.freeze
Instance Method Summary collapse
-
#[](attribute) ⇒ Integer
Raw attribute value.
-
#[]=(attribute, value) ⇒ Integer
Assigned value.
-
#bad_arch_action ⇒ Integer
Action for unsupported architectures.
-
#bad_arch_action=(value) ⇒ Integer
Assigned action.
-
#default_action ⇒ Integer
Default action.
-
#optimize ⇒ Integer
Optimization level.
-
#optimize=(value) ⇒ Integer
Assigned level.
Instance Method Details
#[](attribute) ⇒ Integer
Returns raw attribute value.
37 38 39 40 41 42 43 |
# File 'lib/seccomp/attributes.rb', line 37 def [](attribute) synchronize do rc, value = LowLevel.attr_get(@context, resolve_attribute(attribute)) Error.check!(rc, call: "seccomp_attr_get", hint: "attribute #{attribute}") value end end |
#[]=(attribute, value) ⇒ Integer
Returns assigned value.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/seccomp/attributes.rb', line 50 def []=(attribute, value) synchronize do resolved = resolve_attribute(attribute) value = Action.resolve(value) if resolved == FilterAttr::ACT_BADARCH if resolved == FilterAttr::CTL_TSYNC && value.is_a?(Integer) && !value.zero? ensure_notification_tsync_supported!(tsync: true) end Error.check!(LowLevel.attr_set(@context, resolved, value), call: "seccomp_attr_set", hint: "attribute #{attribute}") end value end |
#bad_arch_action ⇒ Integer
Returns action for unsupported architectures.
72 73 74 |
# File 'lib/seccomp/attributes.rb', line 72 def bad_arch_action self[:bad_arch_action] end |
#bad_arch_action=(value) ⇒ Integer
Returns assigned action.
80 81 82 |
# File 'lib/seccomp/attributes.rb', line 80 def bad_arch_action=(value) self[:bad_arch_action] = value end |
#default_action ⇒ Integer
Returns default action.
66 67 68 |
# File 'lib/seccomp/attributes.rb', line 66 def default_action self[:default_action] end |
#optimize ⇒ Integer
Returns optimization level.
95 96 97 |
# File 'lib/seccomp/attributes.rb', line 95 def optimize self[:optimize] end |
#optimize=(value) ⇒ Integer
Returns assigned level.
103 104 105 |
# File 'lib/seccomp/attributes.rb', line 103 def optimize=(value) self[:optimize] = value end |