class CapNG::State

Handle CapNG state.

@example

require 'capng'

@state = CapNG::State.new
@state.save
# Some capability operations
@state.restore

Public Class Methods

new() click to toggle source

Initalize State class.

@return [nil]

static VALUE
rb_capng_state_initialize(VALUE self)
{
  struct CapNGState* capng_state;

  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);

  capng_state->state = NULL;
  return Qnil;
}

Public Instance Methods

restore() click to toggle source

Restore saved capability state.

@return [nil]

static VALUE
rb_capng_state_restore(VALUE self)
{
  struct CapNGState* capng_state;
  void* state = NULL;

  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);

  state = capng_state->state;
  capng_restore_state(&state);

  return Qnil;
}
save() click to toggle source

Save current capability state.

@return [nil]

static VALUE
rb_capng_state_save(VALUE self)
{
  struct CapNGState* capng_state;
  void* state = NULL;

  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);

  state = capng_save_state();
  capng_state->state = state;

  return Qnil;
}