capng_c 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,21 +13,44 @@
13
13
 
14
14
  #include <capng.h>
15
15
 
16
- struct CapNG {};
17
-
18
- static void capng_free(void* capng);
19
-
20
- static const rb_data_type_t rb_capng_type = {
21
- "capng/capng",
22
- {
23
- 0,
24
- capng_free,
25
- 0,
26
- },
27
- NULL,
28
- NULL,
29
- RUBY_TYPED_FREE_IMMEDIATELY
30
- };
16
+ /* clang-format off */
17
+ /*
18
+ * Document-class: CapNG
19
+ *
20
+ * CapNG class.
21
+ *
22
+ * @example
23
+ * # Current process capability example
24
+ * require 'capng'
25
+ *
26
+ * @capng = CapNG.new(:current_process)
27
+ * @capng.have_capability?(:effective, :dac_read_search)
28
+ *
29
+ * @example
30
+ * # Other process capability example
31
+ * require 'capng'
32
+ *
33
+ * @capng = CapNG.new(:other_process, 12345)
34
+ * @capng.have_capability?(:effective, :dac_override)
35
+ *
36
+ */
37
+ /* clang-format on */
38
+
39
+ struct CapNG
40
+ {};
41
+
42
+ static void
43
+ capng_free(void* capng);
44
+
45
+ static const rb_data_type_t rb_capng_type = { "capng/capng",
46
+ {
47
+ 0,
48
+ capng_free,
49
+ 0,
50
+ },
51
+ NULL,
52
+ NULL,
53
+ RUBY_TYPED_FREE_IMMEDIATELY };
31
54
 
32
55
  static void
33
56
  capng_free(void* ptr)
@@ -40,21 +63,28 @@ rb_capng_alloc(VALUE klass)
40
63
  {
41
64
  VALUE obj;
42
65
  struct CapNG* capng;
43
- obj = TypedData_Make_Struct(
44
- klass, struct CapNG, &rb_capng_type, capng);
66
+ obj = TypedData_Make_Struct(klass, struct CapNG, &rb_capng_type, capng);
45
67
  return obj;
46
68
  }
47
69
 
70
+ /*
71
+ * Initalize CapNG class.
72
+ *
73
+ * @overload initialize(target=nil, pid_or_file=nil)
74
+ * @option param target [String or Symbol] Specify capability target.
75
+ * @option param pid_or_file [String or Symbol] Querying XPath.
76
+ * @return [nil]
77
+ *
78
+ */
48
79
  static VALUE
49
- rb_capng_initialize(int argc, VALUE *argv, VALUE self)
80
+ rb_capng_initialize(int argc, VALUE* argv, VALUE self)
50
81
  {
51
- VALUE rb_target, rb_pid_or_file;
82
+ VALUE rb_target, rb_pid;
52
83
  int result = 0;
53
- char *target = NULL;
54
- int pid = 0, fd = 0;
55
- rb_io_t *fptr = NULL;
84
+ char* target = NULL;
85
+ int pid = 0;
56
86
 
57
- rb_scan_args(argc, argv, "02", &rb_target, &rb_pid_or_file);
87
+ rb_scan_args(argc, argv, "02", &rb_target, &rb_pid);
58
88
 
59
89
  if (NIL_P(rb_target)) {
60
90
  return Qnil;
@@ -74,51 +104,47 @@ rb_capng_initialize(int argc, VALUE *argv, VALUE self)
74
104
  rb_raise(rb_eRuntimeError, "Couldn't get current process' capability");
75
105
  }
76
106
  } else if (strcmp(target, "other_process") == 0) {
77
- Check_Type(rb_pid_or_file, T_FIXNUM);
107
+ Check_Type(rb_pid, T_FIXNUM);
78
108
 
79
- pid = NUM2INT(rb_pid_or_file);
109
+ pid = NUM2INT(rb_pid);
80
110
  capng_setpid(pid);
81
111
  result = capng_get_caps_process();
82
112
  if (result != 0) {
83
113
  rb_raise(rb_eRuntimeError, "Couldn't get current process' capability");
84
114
  }
85
- } else if (strcmp(target, "file") == 0) {
86
- Check_Type(rb_pid_or_file, T_FILE);
87
-
88
- fptr = RFILE(rb_pid_or_file)->fptr;
89
- fd = fptr->fd;
90
- result = capng_get_caps_fd(fd);
91
- /* Just store result into instance variable. */
92
- /* This is because capng_get_caps_fd should return 0 if file cap is not set. */
93
- rb_iv_set(self, "@return_code", INT2NUM(result));
94
115
  }
95
116
 
96
117
  return Qnil;
97
118
  }
98
119
 
99
- static VALUE
100
- rb_capng_return_code(VALUE self)
101
- {
102
- return rb_iv_get(self, "@return_code");
103
- }
104
-
120
+ /*
121
+ * Clear capabilities on specified target.
122
+ *
123
+ * @param rb_select_name_or_enum [Symbol or String or Fixnum] targets are CAPS, BOUNDS,
124
+ * BOTH, and AMBIENT for supported platform.
125
+ *
126
+ * @return [nil]
127
+ *
128
+ */
105
129
  static VALUE
106
130
  rb_capng_clear(VALUE self, VALUE rb_select_name_or_enum)
107
131
  {
108
132
  capng_select_t select = 0;
109
133
 
110
134
  switch (TYPE(rb_select_name_or_enum)) {
111
- case T_SYMBOL:
112
- select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
113
- break;
114
- case T_STRING:
115
- select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
116
- break;
117
- case T_FIXNUM:
118
- select = NUM2INT(rb_select_name_or_enum);
119
- break;
120
- default:
121
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
135
+ case T_SYMBOL:
136
+ select =
137
+ select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
138
+ break;
139
+ case T_STRING:
140
+ select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
141
+ break;
142
+ case T_FIXNUM:
143
+ select = NUM2INT(rb_select_name_or_enum);
144
+ break;
145
+ default:
146
+ rb_raise(rb_eArgError,
147
+ "Expected a String or a Symbol instance, or a capability type constant");
122
148
  }
123
149
 
124
150
  capng_clear(select);
@@ -126,23 +152,34 @@ rb_capng_clear(VALUE self, VALUE rb_select_name_or_enum)
126
152
  return Qnil;
127
153
  }
128
154
 
155
+ /*
156
+ * Fill capabilities on specified target.
157
+ *
158
+ * @param rb_select_name_or_enum [Symbol or String or Fixnum] targets are CAPS, BOUNDS,
159
+ * BOTH, and AMBIENT for supported platform.
160
+ *
161
+ * @return [nil]
162
+ *
163
+ */
129
164
  static VALUE
130
165
  rb_capng_fill(VALUE self, VALUE rb_select_name_or_enum)
131
166
  {
132
167
  capng_select_t select = 0;
133
168
 
134
169
  switch (TYPE(rb_select_name_or_enum)) {
135
- case T_SYMBOL:
136
- select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
137
- break;
138
- case T_STRING:
139
- select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
140
- break;
141
- case T_FIXNUM:
142
- select = NUM2INT(rb_select_name_or_enum);
143
- break;
144
- default:
145
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
170
+ case T_SYMBOL:
171
+ select =
172
+ select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
173
+ break;
174
+ case T_STRING:
175
+ select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
176
+ break;
177
+ case T_FIXNUM:
178
+ select = NUM2INT(rb_select_name_or_enum);
179
+ break;
180
+ default:
181
+ rb_raise(rb_eArgError,
182
+ "Expected a String or a Symbol instance, or a capability type constant");
146
183
  }
147
184
 
148
185
  capng_fill(select);
@@ -150,6 +187,14 @@ rb_capng_fill(VALUE self, VALUE rb_select_name_or_enum)
150
187
  return Qnil;
151
188
  }
152
189
 
190
+ /*
191
+ * Specify process ID to retrieve other process capabilities.
192
+ *
193
+ * @param rb_pid [Fixnum] Process ID.
194
+ *
195
+ * @return [nil]
196
+ *
197
+ */
153
198
  static VALUE
154
199
  rb_capng_setpid(VALUE self, VALUE rb_pid)
155
200
  {
@@ -160,6 +205,13 @@ rb_capng_setpid(VALUE self, VALUE rb_pid)
160
205
  return Qnil;
161
206
  }
162
207
 
208
+ /*
209
+ * Specify process ID to retrieve process capabilities. If not
210
+ * calling #setpid before, it returns current process' capabilities.
211
+ *
212
+ * @return [Boolean]
213
+ *
214
+ */
163
215
  static VALUE
164
216
  rb_capng_get_caps_process(VALUE self)
165
217
  {
@@ -172,55 +224,82 @@ rb_capng_get_caps_process(VALUE self)
172
224
  return Qfalse;
173
225
  }
174
226
 
227
+ /*
228
+ * Update capabilities.
229
+ *
230
+ * @param rb_action_name_or_action [Symbol or String or Fixnum] ADD or DROP.
231
+ * @param rb_capability_name_or_type [Symbol or String or Fixnum]
232
+ * Effective/Inheritable/Permitted/Ambient (If supported) or their combinations
233
+ * @param rb_capability_or_name [Symbol or String or Fixnum] Capability name or constants.
234
+ *
235
+ * @see: [CapNG::Capability])
236
+ *
237
+ * @return [Boolean]
238
+ */
175
239
  static VALUE
176
- rb_capng_update(VALUE self,
177
- VALUE rb_action_name_or_action, VALUE rb_capability_name_or_type, VALUE rb_capability_or_name)
240
+ rb_capng_update(VALUE self, VALUE rb_action_name_or_action,
241
+ VALUE rb_capability_name_or_type, VALUE rb_capability_or_name)
178
242
  {
179
243
  int result = 0;
180
- unsigned int capability = 0;
244
+ int capability = 0;
181
245
  capng_type_t capability_type = 0;
182
246
  capng_act_t action = 0;
183
247
 
184
248
  switch (TYPE(rb_action_name_or_action)) {
185
- case T_SYMBOL:
186
- action = action_name_to_action_type(RSTRING_PTR(rb_sym2str(rb_action_name_or_action)));
187
- break;
188
- case T_STRING:
189
- action = action_name_to_action_type(StringValuePtr(rb_action_name_or_action));
190
- break;
191
- case T_FIXNUM:
192
- action = NUM2INT(rb_action_name_or_action);
193
- break;
194
- default:
195
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
249
+ case T_SYMBOL:
250
+ action =
251
+ action_name_to_action_type(RSTRING_PTR(rb_sym2str(rb_action_name_or_action)));
252
+ break;
253
+ case T_STRING:
254
+ action = action_name_to_action_type(StringValuePtr(rb_action_name_or_action));
255
+ break;
256
+ case T_FIXNUM:
257
+ action = NUM2INT(rb_action_name_or_action);
258
+ break;
259
+ default:
260
+ rb_raise(rb_eArgError,
261
+ "Expected a String or a Symbol instance, or a capability type constant");
196
262
  }
197
263
 
198
264
  switch (TYPE(rb_capability_name_or_type)) {
199
- case T_SYMBOL:
200
- capability_type = capability_type_name_to_capability_type(RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
201
- break;
202
- case T_STRING:
203
- capability_type = capability_type_name_to_capability_type(StringValuePtr(rb_capability_name_or_type));
204
- break;
205
- case T_FIXNUM:
206
- capability_type = NUM2INT(rb_capability_name_or_type);
207
- break;
208
- default:
209
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
265
+ case T_SYMBOL:
266
+ capability_type = capability_type_name_to_capability_type(
267
+ RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
268
+ break;
269
+ case T_STRING:
270
+ capability_type = capability_type_name_to_capability_type(
271
+ StringValuePtr(rb_capability_name_or_type));
272
+ break;
273
+ case T_FIXNUM:
274
+ capability_type = NUM2INT(rb_capability_name_or_type);
275
+ break;
276
+ default:
277
+ rb_raise(rb_eArgError,
278
+ "Expected a String or a Symbol instance, or a capability type constant");
210
279
  }
211
280
 
212
281
  switch (TYPE(rb_capability_or_name)) {
213
- case T_SYMBOL:
214
- capability = capng_name_to_capability(RSTRING_PTR(rb_sym2str(rb_capability_or_name)));
215
- break;
216
- case T_STRING:
217
- capability = capng_name_to_capability(StringValuePtr(rb_capability_or_name));
218
- break;
219
- case T_FIXNUM:
220
- capability = NUM2INT(rb_capability_or_name);
221
- break;
222
- default:
223
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability constant");
282
+ case T_SYMBOL:
283
+ capability =
284
+ capng_name_to_capability(RSTRING_PTR(rb_sym2str(rb_capability_or_name)));
285
+ if (capability == -1) {
286
+ rb_raise(rb_eRuntimeError, "Unknown capability: %s",
287
+ RSTRING_PTR(rb_sym2str(rb_capability_or_name)));
288
+ }
289
+ break;
290
+ case T_STRING:
291
+ capability = capng_name_to_capability(StringValuePtr(rb_capability_or_name));
292
+ if (capability == -1) {
293
+ rb_raise(rb_eRuntimeError, "Unknown capability: %s",
294
+ StringValuePtr(rb_capability_or_name));
295
+ }
296
+ break;
297
+ case T_FIXNUM:
298
+ capability = NUM2INT(rb_capability_or_name);
299
+ break;
300
+ default:
301
+ rb_raise(rb_eArgError,
302
+ "Expected a String or a Symbol instance, or a capability constant");
224
303
  }
225
304
 
226
305
  result = capng_update(action, capability_type, capability);
@@ -231,6 +310,15 @@ rb_capng_update(VALUE self,
231
310
  return Qfalse;
232
311
  }
233
312
 
313
+ /*
314
+ * Apply capabilities on specified target.
315
+ *
316
+ * @param rb_select_name_or_enum [Symbol or String or Fixnum]
317
+ * targets are CAPS, BOUNDS, BOTH, and AMBIENT for supported platform.
318
+ *
319
+ * @return [Boolean]
320
+ *
321
+ */
234
322
  static VALUE
235
323
  rb_capng_apply(VALUE self, VALUE rb_select_name_or_enum)
236
324
  {
@@ -238,17 +326,19 @@ rb_capng_apply(VALUE self, VALUE rb_select_name_or_enum)
238
326
  capng_select_t select = 0;
239
327
 
240
328
  switch (TYPE(rb_select_name_or_enum)) {
241
- case T_SYMBOL:
242
- select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
243
- break;
244
- case T_STRING:
245
- select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
246
- break;
247
- case T_FIXNUM:
248
- select = NUM2INT(rb_select_name_or_enum);
249
- break;
250
- default:
251
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
329
+ case T_SYMBOL:
330
+ select =
331
+ select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
332
+ break;
333
+ case T_STRING:
334
+ select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
335
+ break;
336
+ case T_FIXNUM:
337
+ select = NUM2INT(rb_select_name_or_enum);
338
+ break;
339
+ default:
340
+ rb_raise(rb_eArgError,
341
+ "Expected a String or a Symbol instance, or a capability type constant");
252
342
  }
253
343
 
254
344
  result = capng_apply(select);
@@ -259,6 +349,12 @@ rb_capng_apply(VALUE self, VALUE rb_select_name_or_enum)
259
349
  return Qfalse;
260
350
  }
261
351
 
352
+ /*
353
+ * Lock capabilities.
354
+ *
355
+ * @return [Boolean]
356
+ *
357
+ */
262
358
  static VALUE
263
359
  rb_capng_lock(VALUE self)
264
360
  {
@@ -272,6 +368,14 @@ rb_capng_lock(VALUE self)
272
368
  return Qfalse;
273
369
  }
274
370
 
371
+ /*
372
+ * Change the credentials retaining capabilities.
373
+ * @param rb_uid [Fixnum] User ID.
374
+ * @param rb_gid [Fixnum] Group ID.
375
+ * @param rb_flags [Fixnum] CapNG::Flags constants.
376
+ *
377
+ * @see: capng_change_id(3)
378
+ */
275
379
  static VALUE
276
380
  rb_capng_change_id(VALUE self, VALUE rb_uid, VALUE rb_gid, VALUE rb_flags)
277
381
  {
@@ -282,9 +386,20 @@ rb_capng_change_id(VALUE self, VALUE rb_uid, VALUE rb_gid, VALUE rb_flags)
282
386
  if (result == 0)
283
387
  return Qtrue;
284
388
  else
285
- rb_raise(rb_eRuntimeError, "Calling capng_change_id is failed with: (exitcode: %d)\n", result);
389
+ rb_raise(rb_eRuntimeError,
390
+ "Calling capng_change_id is failed with: (exitcode: %d)\n",
391
+ result);
286
392
  }
287
393
 
394
+ /*
395
+ * Check whether capabilities on specified target or not.
396
+ *
397
+ * @param rb_select_name_or_enum [Symbol or String or Fixnum]
398
+ * targets are CAPS, BOUNDS, BOTH, and AMBIENT for supported platform.
399
+ *
400
+ * @return [Integer]
401
+ *
402
+ */
288
403
  static VALUE
289
404
  rb_capng_have_capabilities_p(VALUE self, VALUE rb_select_name_or_enum)
290
405
  {
@@ -292,56 +407,77 @@ rb_capng_have_capabilities_p(VALUE self, VALUE rb_select_name_or_enum)
292
407
  capng_select_t select = 0;
293
408
 
294
409
  switch (TYPE(rb_select_name_or_enum)) {
295
- case T_SYMBOL:
296
- select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
297
- break;
298
- case T_STRING:
299
- select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
300
- break;
301
- case T_FIXNUM:
302
- select = NUM2INT(rb_select_name_or_enum);
303
- break;
304
- default:
305
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
410
+ case T_SYMBOL:
411
+ select =
412
+ select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
413
+ break;
414
+ case T_STRING:
415
+ select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
416
+ break;
417
+ case T_FIXNUM:
418
+ select = NUM2INT(rb_select_name_or_enum);
419
+ break;
420
+ default:
421
+ rb_raise(rb_eArgError,
422
+ "Expected a String or a Symbol instance, or a capability type constant");
306
423
  }
307
424
  result = capng_have_capabilities(select);
308
425
 
309
426
  return INT2NUM(result);
310
427
  }
311
428
 
429
+ /*
430
+ * Check whether capabilities on specified target or not.
431
+ *
432
+ * @param rb_capability_name_or_type [Symbol or String or Fixnum] types are EFFECTIVE,
433
+ * INHERITABLE, PERMITTED, and AMBIENT for supported platform.
434
+ * @param rb_capability_or_name [Symbol or String or Fixnum]
435
+ * Capability name or constants.
436
+ *
437
+ * @see: [CapNG::Capability]
438
+ *
439
+ * @return [Boolean]
440
+ *
441
+ */
312
442
  static VALUE
313
- rb_capng_have_capability_p(VALUE self, VALUE rb_capability_name_or_type, VALUE rb_capability_or_name)
443
+ rb_capng_have_capability_p(VALUE self, VALUE rb_capability_name_or_type,
444
+ VALUE rb_capability_or_name)
314
445
  {
315
446
  int result = 0;
316
447
  unsigned int capability = 0;
317
448
  capng_type_t capability_type = 0;
318
449
 
319
450
  switch (TYPE(rb_capability_name_or_type)) {
320
- case T_SYMBOL:
321
- capability_type = capability_type_name_to_capability_type(RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
322
- break;
323
- case T_STRING:
324
- capability_type = capability_type_name_to_capability_type(StringValuePtr(rb_capability_name_or_type));
325
- break;
326
- case T_FIXNUM:
327
- capability_type = NUM2INT(rb_capability_name_or_type);
328
- break;
329
- default:
330
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
451
+ case T_SYMBOL:
452
+ capability_type = capability_type_name_to_capability_type(
453
+ RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
454
+ break;
455
+ case T_STRING:
456
+ capability_type = capability_type_name_to_capability_type(
457
+ StringValuePtr(rb_capability_name_or_type));
458
+ break;
459
+ case T_FIXNUM:
460
+ capability_type = NUM2INT(rb_capability_name_or_type);
461
+ break;
462
+ default:
463
+ rb_raise(rb_eArgError,
464
+ "Expected a String or a Symbol instance, or a capability type constant");
331
465
  }
332
466
 
333
467
  switch (TYPE(rb_capability_or_name)) {
334
- case T_SYMBOL:
335
- capability = capng_name_to_capability(RSTRING_PTR(rb_sym2str(rb_capability_or_name)));
336
- break;
337
- case T_STRING:
338
- capability = capng_name_to_capability(StringValuePtr(rb_capability_or_name));
339
- break;
340
- case T_FIXNUM:
341
- capability = NUM2INT(rb_capability_or_name);
342
- break;
343
- default:
344
- rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability constant");
468
+ case T_SYMBOL:
469
+ capability =
470
+ capng_name_to_capability(RSTRING_PTR(rb_sym2str(rb_capability_or_name)));
471
+ break;
472
+ case T_STRING:
473
+ capability = capng_name_to_capability(StringValuePtr(rb_capability_or_name));
474
+ break;
475
+ case T_FIXNUM:
476
+ capability = NUM2INT(rb_capability_or_name);
477
+ break;
478
+ default:
479
+ rb_raise(rb_eArgError,
480
+ "Expected a String or a Symbol instance, or a capability constant");
345
481
  }
346
482
 
347
483
  result = capng_have_capability(capability_type, capability);
@@ -352,11 +488,19 @@ rb_capng_have_capability_p(VALUE self, VALUE rb_capability_name_or_type, VALUE r
352
488
  return Qfalse;
353
489
  }
354
490
 
491
+ /*
492
+ * Retrieve capabilities from file.
493
+ *
494
+ * @param rb_file [File] target file object
495
+ *
496
+ * @return [Boolean]
497
+ *
498
+ */
355
499
  static VALUE
356
500
  rb_capng_get_caps_file(VALUE self, VALUE rb_file)
357
501
  {
358
502
  int result = 0, fd = 0;
359
- rb_io_t *fptr = NULL;
503
+ rb_io_t* fptr = NULL;
360
504
 
361
505
  Check_Type(rb_file, T_FILE);
362
506
 
@@ -373,11 +517,19 @@ rb_capng_get_caps_file(VALUE self, VALUE rb_file)
373
517
  return Qfalse;
374
518
  }
375
519
 
520
+ /*
521
+ * Apply capabilities on specified target (file specific version).
522
+ *
523
+ * @param rb_file [File] target file object
524
+ *
525
+ * @return [Boolean]
526
+ *
527
+ */
376
528
  static VALUE
377
529
  rb_capng_apply_caps_file(VALUE self, VALUE rb_file)
378
530
  {
379
531
  int result = 0, fd = 0;
380
- rb_io_t *fptr = NULL;
532
+ rb_io_t* fptr = NULL;
381
533
 
382
534
  Check_Type(rb_file, T_FILE);
383
535
 
@@ -395,16 +547,14 @@ rb_capng_apply_caps_file(VALUE self, VALUE rb_file)
395
547
  return Qfalse;
396
548
  }
397
549
 
398
-
399
550
  void
400
551
  Init_capng(void)
401
552
  {
402
- rb_cCapNG = rb_define_class("CapNG", rb_cObject);
553
+ VALUE rb_cCapNG = rb_define_class("CapNG", rb_cObject);
403
554
 
404
555
  rb_define_alloc_func(rb_cCapNG, rb_capng_alloc);
405
556
 
406
557
  rb_define_method(rb_cCapNG, "initialize", rb_capng_initialize, -1);
407
- rb_define_method(rb_cCapNG, "return_code", rb_capng_return_code, 0);
408
558
  rb_define_method(rb_cCapNG, "clear", rb_capng_clear, 1);
409
559
  rb_define_method(rb_cCapNG, "fill", rb_capng_fill, 1);
410
560
  rb_define_method(rb_cCapNG, "setpid", rb_capng_setpid, 1);