Class: CapNG::State

Inherits:
Object
  • Object
show all
Defined in:
ext/capng/state.c,
ext/capng/state.c

Overview

Handle CapNG state.

Examples:

require 'capng'

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

Instance Method Summary collapse

Constructor Details

#initializenil

Initalize State class.



77
78
79
80
81
82
83
84
85
86
# File 'ext/capng/state.c', line 77

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;
}

Instance Method Details

#restorenil

Restore saved capability state.

Returns:

  • (nil)


115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'ext/capng/state.c', line 115

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;
}

#savenil

Save current capability state.

Returns:

  • (nil)


94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'ext/capng/state.c', line 94

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;
}