Module: Seccomp::LowLevel

Defined in:
lib/seccomp/low_level.rb

Overview

Thin C-compatible API. Methods return negative errno values unless documented otherwise.

Defined Under Namespace

Classes: Context

Class Method Summary collapse

Class Method Details

.api_getInteger

Returns runtime API level.

Examples:

LowLevel.api_get

Returns:

  • (Integer)

    runtime API level



# File 'lib/seccomp/low_level.rb', line 10

.api_set(level) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.api_set(6)

Parameters:

  • level (Integer)

Returns:

  • (Integer)

    raw return code

Raises:

  • (RangeError)

    for an invalid integer



# File 'lib/seccomp/low_level.rb', line 10

.arch_add(context, arch) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.arch_add(context, Arch::X86)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.arch_exist(context, arch) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.arch_exist(context, Arch::X86)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.arch_nativeInteger

Returns native architecture token.

Examples:

LowLevel.arch_native

Returns:

  • (Integer)

    native architecture token



# File 'lib/seccomp/low_level.rb', line 10

.arch_remove(context, arch) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.arch_remove(context, Arch::X86)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.arch_resolve_name(name) ⇒ Integer

Returns architecture token, or zero.

Examples:

LowLevel.arch_resolve_name("x86_64")

Parameters:

  • name (String)

Returns:

  • (Integer)

    architecture token, or zero



# File 'lib/seccomp/low_level.rb', line 10

.attr_get(context, attribute) ⇒ Array(Integer, Integer)

Returns raw return code and value.

Examples:

LowLevel.attr_get(context, FilterAttr::CTL_NNP)

Parameters:

  • context (Context)
  • attribute (Integer)

Returns:

  • (Array(Integer, Integer))

    raw return code and value

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.attr_set(context, attribute, value) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.attr_set(context, FilterAttr::CTL_NNP, 1)

Parameters:

  • context (Context)
  • attribute (Integer)
  • value (Integer)

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.closed?(context) ⇒ Boolean

Examples:

LowLevel.closed?(context)

Parameters:

Returns:

  • (Boolean)


# File 'lib/seccomp/low_level.rb', line 10

.export_bpf(context, fd) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.export_bpf(context, io.fileno)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.export_bpf_mem(context) ⇒ Array(Integer, String)

Returns raw return code and BPF.

Examples:

LowLevel.export_bpf_mem(context)

Parameters:

Returns:

  • (Array(Integer, String))

    raw return code and BPF

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.export_pfc(context, fd) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.export_pfc(context, io.fileno)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.init(action) ⇒ Context

Examples:

LowLevel.init(Action::ALLOW)

Parameters:

  • action (Integer)

Returns:

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.load(context) ⇒ Integer

Returns raw return code.

Examples:

fork { LowLevel.load(context) }

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.loaded?(context) ⇒ Boolean

Examples:

LowLevel.loaded?(context)

Parameters:

Returns:

  • (Boolean)

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.merge(destination, source) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.merge(destination, source)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.notify_addfd(fd, id, flags, source_fd, newfd, newfd_flags) ⇒ Integer

Returns installed fd or negative errno.

Examples:

LowLevel.notify_addfd(fd, id, 0, source.fileno, 0, 0)

Parameters:

  • fd (Integer)
  • id (Integer)
  • flags (Integer)
  • source_fd (Integer)
  • newfd (Integer)
  • newfd_flags (Integer)

Returns:

  • (Integer)

    installed fd or negative errno

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.notify_fd(context) ⇒ Integer

Returns listener fd or negative errno.

Examples:

LowLevel.notify_fd(context)

Parameters:

Returns:

  • (Integer)

    listener fd or negative errno

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.notify_id_valid(fd, id) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.notify_id_valid(fd, id)

Parameters:

  • fd (Integer)
  • id (Integer)

Returns:

  • (Integer)

    raw return code



# File 'lib/seccomp/low_level.rb', line 10

.notify_receive(fd) ⇒ Array(Integer, Hash)

Returns raw return code and request.

Examples:

LowLevel.notify_receive(fd)

Parameters:

  • fd (Integer)

Returns:

  • (Array(Integer, Hash))

    raw return code and request



# File 'lib/seccomp/low_level.rb', line 10

.notify_respond(fd, id, value, error, flags) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.notify_respond(fd, id, 0, 0, 0)

Parameters:

  • fd (Integer)
  • id (Integer)
  • value (Integer)
  • error (Integer)
  • flags (Integer)

Returns:

  • (Integer)

    raw return code



# File 'lib/seccomp/low_level.rb', line 10

.precompute(context) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.precompute(context)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.release(context) ⇒ nil

Examples:

LowLevel.release(context)

Parameters:

Returns:

  • (nil)


# File 'lib/seccomp/low_level.rb', line 10

.reset(context, action) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.reset(context, Action::ALLOW)

Parameters:

  • context (Context)
  • action (Integer)

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.rule_add_array(context, action, syscall, comparisons) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.rule_add_array(context, Action::ALLOW, 1, [])

Parameters:

  • context (Context)
  • action (Integer)
  • syscall (Integer)
  • comparisons (Array<Array<Integer>>)

Returns:

  • (Integer)

    raw return code

Raises:

  • (ArgumentError)

    for malformed comparisons



# File 'lib/seccomp/low_level.rb', line 10

.rule_add_exact_array(context, action, syscall, comparisons) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.rule_add_exact_array(context, Action::ALLOW, 1, [])

Parameters:

  • context (Context)
  • action (Integer)
  • syscall (Integer)
  • comparisons (Array<Array<Integer>>)

Returns:

  • (Integer)

    raw return code

Raises:

  • (ArgumentError)

    for malformed comparisons



# File 'lib/seccomp/low_level.rb', line 10

.supports?(feature) ⇒ Boolean

Examples:

LowLevel.supports?(:notify)

Parameters:

  • feature (Symbol)

Returns:

  • (Boolean)


# File 'lib/seccomp/low_level.rb', line 10

.syscall_priority(context, syscall, priority) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.syscall_priority(context, 1, 100)

Parameters:

  • context (Context)
  • syscall (Integer)
  • priority (Integer)

Returns:

  • (Integer)

    raw return code

Raises:

  • (RangeError)

    outside 0..255



# File 'lib/seccomp/low_level.rb', line 10

.syscall_resolve_name(name) ⇒ Integer

Returns syscall number.

Examples:

LowLevel.syscall_resolve_name("write")

Parameters:

  • name (String)

Returns:

  • (Integer)

    syscall number



# File 'lib/seccomp/low_level.rb', line 10

.syscall_resolve_name_arch(arch, name) ⇒ Integer

Returns syscall number.

Examples:

LowLevel.syscall_resolve_name_arch(Arch::X86, "write")

Parameters:

  • arch (Integer)
  • name (String)

Returns:

  • (Integer)

    syscall number



# File 'lib/seccomp/low_level.rb', line 10

.syscall_resolve_name_rewrite(arch, name) ⇒ Integer

Returns rewritten syscall number.

Examples:

LowLevel.syscall_resolve_name_rewrite(Arch::X86, "socket")

Parameters:

  • arch (Integer)
  • name (String)

Returns:

  • (Integer)

    rewritten syscall number



# File 'lib/seccomp/low_level.rb', line 10

.syscall_resolve_num_arch(arch, number) ⇒ String?

Returns syscall name.

Examples:

LowLevel.syscall_resolve_num_arch(Arch::X86_64, 1)

Parameters:

  • arch (Integer)
  • number (Integer)

Returns:

  • (String, nil)

    syscall name



# File 'lib/seccomp/low_level.rb', line 10

.transaction_commit(context) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.transaction_commit(context)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.transaction_reject(context) ⇒ Integer

Returns zero.

Examples:

LowLevel.transaction_reject(context)

Parameters:

Returns:

  • (Integer)

    zero

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.transaction_start(context) ⇒ Integer

Returns raw return code.

Examples:

LowLevel.transaction_start(context)

Parameters:

Returns:

  • (Integer)

    raw return code

Raises:



# File 'lib/seccomp/low_level.rb', line 10

.versionArray<Integer>

Returns major, minor, and micro version.

Examples:

LowLevel.version #=> [2, 6, 1]

Returns:

  • (Array<Integer>)

    major, minor, and micro version



# File 'lib/seccomp/low_level.rb', line 10