capng_c 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/capng/capng.c +146 -16
- data/ext/capng/capng.h +8 -0
- data/ext/capng/print.c +68 -8
- data/ext/capng/utils.c +80 -0
- data/lib/capng.rb +20 -1
- data/lib/capng/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 255863aedacdc832b5ff8da87fb0d97a2916a65b1385c6f8072281967039d632
|
4
|
+
data.tar.gz: e145914ff785ff35cf7df36e86e9fca56a6de5228139b4e9ef586888be20bad3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e401c25553011b8e922b1f7c80574fef9d9890464905b29513485c7a1627091fa26532d6f461d86aeb202e82b64eddca7f31edde1e48f07a00bf8cb3fe67ab01
|
7
|
+
data.tar.gz: 6d6f3fbf99fc67ea2ec32f5803a453782d2f10e6773d7db1905eba33d01c657cb7a3a238d7cc65f910f5ad361398964b44135f4bf79c256d0edb35222f2cdb8d
|
data/ext/capng/capng.c
CHANGED
@@ -46,27 +46,100 @@ rb_capng_alloc(VALUE klass)
|
|
46
46
|
}
|
47
47
|
|
48
48
|
static VALUE
|
49
|
-
rb_capng_initialize(VALUE self)
|
49
|
+
rb_capng_initialize(int argc, VALUE *argv, VALUE self)
|
50
50
|
{
|
51
|
+
VALUE rb_target, rb_pid_or_file;
|
52
|
+
int result = 0;
|
53
|
+
char *target = NULL;
|
54
|
+
int pid = 0, fd = 0;
|
55
|
+
rb_io_t *fptr = NULL;
|
56
|
+
|
57
|
+
rb_scan_args(argc, argv, "02", &rb_target, &rb_pid_or_file);
|
58
|
+
|
59
|
+
if (NIL_P(rb_target)) {
|
60
|
+
return Qnil;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (RB_TYPE_P(rb_target, T_SYMBOL)) {
|
64
|
+
target = RSTRING_PTR(rb_sym2str(rb_target));
|
65
|
+
} else if (RB_TYPE_P(rb_target, T_STRING)) {
|
66
|
+
target = StringValuePtr(rb_target);
|
67
|
+
} else {
|
68
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance for tagret argument");
|
69
|
+
}
|
70
|
+
|
71
|
+
if (strcmp(target, "current_process") == 0) {
|
72
|
+
result = capng_get_caps_process();
|
73
|
+
if (result != 0) {
|
74
|
+
rb_raise(rb_eRuntimeError, "Couldn't get current process' capability");
|
75
|
+
}
|
76
|
+
} else if (strcmp(target, "other_process") == 0) {
|
77
|
+
Check_Type(rb_pid_or_file, T_FIXNUM);
|
78
|
+
|
79
|
+
pid = NUM2INT(rb_pid_or_file);
|
80
|
+
capng_setpid(pid);
|
81
|
+
result = capng_get_caps_process();
|
82
|
+
if (result != 0) {
|
83
|
+
rb_raise(rb_eRuntimeError, "Couldn't get current process' capability");
|
84
|
+
}
|
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
|
+
if (result != 0) {
|
92
|
+
rb_raise(rb_eRuntimeError, "Couldn't get current file capability");
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
51
96
|
return Qnil;
|
52
97
|
}
|
53
98
|
|
54
99
|
static VALUE
|
55
|
-
rb_capng_clear(VALUE self, VALUE
|
100
|
+
rb_capng_clear(VALUE self, VALUE rb_select_name_or_enum)
|
56
101
|
{
|
57
|
-
|
102
|
+
capng_select_t select = 0;
|
58
103
|
|
59
|
-
|
104
|
+
switch (TYPE(rb_select_name_or_enum)) {
|
105
|
+
case T_SYMBOL:
|
106
|
+
select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
|
107
|
+
break;
|
108
|
+
case T_STRING:
|
109
|
+
select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
|
110
|
+
break;
|
111
|
+
case T_FIXNUM:
|
112
|
+
select = NUM2INT(rb_select_name_or_enum);
|
113
|
+
break;
|
114
|
+
default:
|
115
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
116
|
+
}
|
117
|
+
|
118
|
+
capng_clear(select);
|
60
119
|
|
61
120
|
return Qnil;
|
62
121
|
}
|
63
122
|
|
64
123
|
static VALUE
|
65
|
-
rb_capng_fill(VALUE self, VALUE
|
124
|
+
rb_capng_fill(VALUE self, VALUE rb_select_name_or_enum)
|
66
125
|
{
|
67
|
-
|
126
|
+
capng_select_t select = 0;
|
127
|
+
|
128
|
+
switch (TYPE(rb_select_name_or_enum)) {
|
129
|
+
case T_SYMBOL:
|
130
|
+
select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
|
131
|
+
break;
|
132
|
+
case T_STRING:
|
133
|
+
select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
|
134
|
+
break;
|
135
|
+
case T_FIXNUM:
|
136
|
+
select = NUM2INT(rb_select_name_or_enum);
|
137
|
+
break;
|
138
|
+
default:
|
139
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
140
|
+
}
|
68
141
|
|
69
|
-
capng_fill(
|
142
|
+
capng_fill(select);
|
70
143
|
|
71
144
|
return Qnil;
|
72
145
|
}
|
@@ -94,13 +167,41 @@ rb_capng_get_caps_process(VALUE self)
|
|
94
167
|
}
|
95
168
|
|
96
169
|
static VALUE
|
97
|
-
rb_capng_update(VALUE self,
|
170
|
+
rb_capng_update(VALUE self,
|
171
|
+
VALUE rb_action_name_or_action, VALUE rb_capability_name_or_type, VALUE rb_capability_or_name)
|
98
172
|
{
|
99
173
|
int result = 0;
|
100
174
|
unsigned int capability = 0;
|
175
|
+
capng_type_t capability_type = 0;
|
176
|
+
capng_act_t action = 0;
|
101
177
|
|
102
|
-
|
103
|
-
|
178
|
+
switch (TYPE(rb_action_name_or_action)) {
|
179
|
+
case T_SYMBOL:
|
180
|
+
action = action_name_to_action_type(RSTRING_PTR(rb_sym2str(rb_action_name_or_action)));
|
181
|
+
break;
|
182
|
+
case T_STRING:
|
183
|
+
action = action_name_to_action_type(StringValuePtr(rb_action_name_or_action));
|
184
|
+
break;
|
185
|
+
case T_FIXNUM:
|
186
|
+
action = NUM2INT(rb_action_name_or_action);
|
187
|
+
break;
|
188
|
+
default:
|
189
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
190
|
+
}
|
191
|
+
|
192
|
+
switch (TYPE(rb_capability_name_or_type)) {
|
193
|
+
case T_SYMBOL:
|
194
|
+
capability_type = capability_type_name_to_capability_type(RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
|
195
|
+
break;
|
196
|
+
case T_STRING:
|
197
|
+
capability_type = capability_type_name_to_capability_type(StringValuePtr(rb_capability_name_or_type));
|
198
|
+
break;
|
199
|
+
case T_FIXNUM:
|
200
|
+
capability_type = NUM2INT(rb_capability_name_or_type);
|
201
|
+
break;
|
202
|
+
default:
|
203
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
204
|
+
}
|
104
205
|
|
105
206
|
switch (TYPE(rb_capability_or_name)) {
|
106
207
|
case T_SYMBOL:
|
@@ -116,7 +217,7 @@ rb_capng_update(VALUE self, VALUE rb_action_set, VALUE rb_update_type, VALUE rb_
|
|
116
217
|
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability constant");
|
117
218
|
}
|
118
219
|
|
119
|
-
result = capng_update(
|
220
|
+
result = capng_update(action, capability_type, capability);
|
120
221
|
|
121
222
|
if (result == 0)
|
122
223
|
return Qtrue;
|
@@ -166,20 +267,49 @@ rb_capng_change_id(VALUE self, VALUE rb_uid, VALUE rb_gid, VALUE rb_flags)
|
|
166
267
|
}
|
167
268
|
|
168
269
|
static VALUE
|
169
|
-
rb_capng_have_capabilities_p(VALUE self, VALUE
|
270
|
+
rb_capng_have_capabilities_p(VALUE self, VALUE rb_select_name_or_enum)
|
170
271
|
{
|
171
272
|
int result = 0;
|
273
|
+
capng_select_t select = 0;
|
172
274
|
|
173
|
-
|
275
|
+
switch (TYPE(rb_select_name_or_enum)) {
|
276
|
+
case T_SYMBOL:
|
277
|
+
select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
|
278
|
+
break;
|
279
|
+
case T_STRING:
|
280
|
+
select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
|
281
|
+
break;
|
282
|
+
case T_FIXNUM:
|
283
|
+
select = NUM2INT(rb_select_name_or_enum);
|
284
|
+
break;
|
285
|
+
default:
|
286
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
287
|
+
}
|
288
|
+
result = capng_have_capabilities(select);
|
174
289
|
|
175
290
|
return INT2NUM(result);
|
176
291
|
}
|
177
292
|
|
178
293
|
static VALUE
|
179
|
-
rb_capng_have_capability_p(VALUE self, VALUE
|
294
|
+
rb_capng_have_capability_p(VALUE self, VALUE rb_capability_name_or_type, VALUE rb_capability_or_name)
|
180
295
|
{
|
181
296
|
int result = 0;
|
182
297
|
unsigned int capability = 0;
|
298
|
+
capng_type_t capability_type = 0;
|
299
|
+
|
300
|
+
switch (TYPE(rb_capability_name_or_type)) {
|
301
|
+
case T_SYMBOL:
|
302
|
+
capability_type = capability_type_name_to_capability_type(RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
|
303
|
+
break;
|
304
|
+
case T_STRING:
|
305
|
+
capability_type = capability_type_name_to_capability_type(StringValuePtr(rb_capability_name_or_type));
|
306
|
+
break;
|
307
|
+
case T_FIXNUM:
|
308
|
+
capability_type = NUM2INT(rb_capability_name_or_type);
|
309
|
+
break;
|
310
|
+
default:
|
311
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
312
|
+
}
|
183
313
|
|
184
314
|
switch (TYPE(rb_capability_or_name)) {
|
185
315
|
case T_SYMBOL:
|
@@ -195,7 +325,7 @@ rb_capng_have_capability_p(VALUE self, VALUE rb_update_type, VALUE rb_capability
|
|
195
325
|
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability constant");
|
196
326
|
}
|
197
327
|
|
198
|
-
result = capng_have_capability(
|
328
|
+
result = capng_have_capability(capability_type, capability);
|
199
329
|
|
200
330
|
if (result == 1)
|
201
331
|
return Qtrue;
|
@@ -254,7 +384,7 @@ Init_capng(void)
|
|
254
384
|
|
255
385
|
rb_define_alloc_func(rb_cCapNG, rb_capng_alloc);
|
256
386
|
|
257
|
-
rb_define_method(rb_cCapNG, "initialize", rb_capng_initialize,
|
387
|
+
rb_define_method(rb_cCapNG, "initialize", rb_capng_initialize, -1);
|
258
388
|
rb_define_method(rb_cCapNG, "clear", rb_capng_clear, 1);
|
259
389
|
rb_define_method(rb_cCapNG, "fill", rb_capng_fill, 1);
|
260
390
|
rb_define_method(rb_cCapNG, "setpid", rb_capng_setpid, 1);
|
data/ext/capng/capng.h
CHANGED
@@ -20,6 +20,9 @@
|
|
20
20
|
|
21
21
|
#include <cap-ng.h>
|
22
22
|
#include <stdio.h>
|
23
|
+
#include <sys/types.h>
|
24
|
+
#include <sys/stat.h>
|
25
|
+
#include <fcntl.h>
|
23
26
|
|
24
27
|
VALUE rb_cCapNG;
|
25
28
|
VALUE rb_cCapNGPrint;
|
@@ -32,6 +35,11 @@ VALUE rb_mResult;
|
|
32
35
|
VALUE rb_mPrint;
|
33
36
|
VALUE rb_mFlags;
|
34
37
|
|
38
|
+
capng_select_t select_name_to_select_type(char *select_name);
|
39
|
+
capng_act_t action_name_to_action_type(char *action_name);
|
40
|
+
capng_print_t print_name_to_print_type(char *print_name);
|
41
|
+
capng_type_t capability_type_name_to_capability_type(char *capability_name);
|
42
|
+
|
35
43
|
void Init_capng_capability(VALUE);
|
36
44
|
void Init_capng_enum(VALUE);
|
37
45
|
void Init_capng_print(VALUE);
|
data/ext/capng/print.c
CHANGED
@@ -52,16 +52,46 @@ rb_capng_print_initialize(VALUE self)
|
|
52
52
|
}
|
53
53
|
|
54
54
|
static VALUE
|
55
|
-
rb_capng_print_caps_text(VALUE self, VALUE
|
55
|
+
rb_capng_print_caps_text(VALUE self, VALUE rb_where_name_or_type, VALUE rb_capability_name_or_type)
|
56
56
|
{
|
57
57
|
char *result = NULL;
|
58
|
+
capng_type_t capability_type = 0;
|
59
|
+
capng_print_t print_type = 0;
|
58
60
|
|
59
|
-
switch (
|
61
|
+
switch (TYPE(rb_capability_name_or_type)) {
|
62
|
+
case T_SYMBOL:
|
63
|
+
capability_type = capability_type_name_to_capability_type(RSTRING_PTR(rb_sym2str(rb_capability_name_or_type)));
|
64
|
+
break;
|
65
|
+
case T_STRING:
|
66
|
+
capability_type = capability_type_name_to_capability_type(StringValuePtr(rb_capability_name_or_type));
|
67
|
+
break;
|
68
|
+
case T_FIXNUM:
|
69
|
+
capability_type = NUM2INT(rb_capability_name_or_type);
|
70
|
+
break;
|
71
|
+
default:
|
72
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
73
|
+
}
|
74
|
+
|
75
|
+
switch (TYPE(rb_where_name_or_type)) {
|
76
|
+
case T_SYMBOL:
|
77
|
+
print_type = print_name_to_print_type(RSTRING_PTR(rb_sym2str(rb_where_name_or_type)));
|
78
|
+
break;
|
79
|
+
case T_STRING:
|
80
|
+
print_type = print_name_to_print_type(StringValuePtr(rb_where_name_or_type));
|
81
|
+
break;
|
82
|
+
case T_FIXNUM:
|
83
|
+
print_type = NUM2INT(rb_where_name_or_type);
|
84
|
+
break;
|
85
|
+
default:
|
86
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a print type constant");
|
87
|
+
}
|
88
|
+
|
89
|
+
switch (print_type) {
|
60
90
|
case CAPNG_PRINT_STDOUT:
|
61
|
-
capng_print_caps_text(CAPNG_PRINT_STDOUT,
|
91
|
+
capng_print_caps_text(CAPNG_PRINT_STDOUT, capability_type);
|
62
92
|
break;
|
63
93
|
case CAPNG_PRINT_BUFFER:
|
64
|
-
result = capng_print_caps_text(CAPNG_PRINT_BUFFER,
|
94
|
+
result = capng_print_caps_text(CAPNG_PRINT_BUFFER, capability_type);
|
65
95
|
}
|
66
96
|
|
67
97
|
if (result)
|
@@ -71,16 +101,46 @@ rb_capng_print_caps_text(VALUE self, VALUE rb_where, VALUE rb_select_set)
|
|
71
101
|
}
|
72
102
|
|
73
103
|
static VALUE
|
74
|
-
rb_capng_print_caps_numeric(VALUE self, VALUE
|
104
|
+
rb_capng_print_caps_numeric(VALUE self, VALUE rb_where_name_or_type, VALUE rb_select_name_or_enum)
|
75
105
|
{
|
76
106
|
char *result = NULL;
|
107
|
+
capng_select_t select = 0;
|
108
|
+
capng_print_t print_type = 0;
|
109
|
+
|
110
|
+
switch (TYPE(rb_where_name_or_type)) {
|
111
|
+
case T_SYMBOL:
|
112
|
+
print_type = print_name_to_print_type(RSTRING_PTR(rb_sym2str(rb_where_name_or_type)));
|
113
|
+
break;
|
114
|
+
case T_STRING:
|
115
|
+
print_type = print_name_to_print_type(StringValuePtr(rb_where_name_or_type));
|
116
|
+
break;
|
117
|
+
case T_FIXNUM:
|
118
|
+
print_type = NUM2INT(rb_where_name_or_type);
|
119
|
+
break;
|
120
|
+
default:
|
121
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a print type constant");
|
122
|
+
}
|
123
|
+
|
124
|
+
switch (TYPE(rb_select_name_or_enum)) {
|
125
|
+
case T_SYMBOL:
|
126
|
+
select = select_name_to_select_type(RSTRING_PTR(rb_sym2str(rb_select_name_or_enum)));
|
127
|
+
break;
|
128
|
+
case T_STRING:
|
129
|
+
select = select_name_to_select_type(StringValuePtr(rb_select_name_or_enum));
|
130
|
+
break;
|
131
|
+
case T_FIXNUM:
|
132
|
+
select = NUM2INT(rb_select_name_or_enum);
|
133
|
+
break;
|
134
|
+
default:
|
135
|
+
rb_raise(rb_eArgError, "Expected a String or a Symbol instance, or a capability type constant");
|
136
|
+
}
|
77
137
|
|
78
|
-
switch (
|
138
|
+
switch (print_type) {
|
79
139
|
case CAPNG_PRINT_STDOUT:
|
80
|
-
capng_print_caps_numeric(CAPNG_PRINT_STDOUT,
|
140
|
+
capng_print_caps_numeric(CAPNG_PRINT_STDOUT, select);
|
81
141
|
break;
|
82
142
|
case CAPNG_PRINT_BUFFER:
|
83
|
-
result = capng_print_caps_numeric(CAPNG_PRINT_BUFFER,
|
143
|
+
result = capng_print_caps_numeric(CAPNG_PRINT_BUFFER, select);
|
84
144
|
}
|
85
145
|
|
86
146
|
if (result)
|
data/ext/capng/utils.c
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
/* capng_c */
|
2
|
+
/* Copyright 2020- Hiroshi Hatake*/
|
3
|
+
/* */
|
4
|
+
/* Licensed under the Apache License, Version 2.0 (the "License"); */
|
5
|
+
/* you may not use this file except in compliance with the License. */
|
6
|
+
/* You may obtain a copy of the License at */
|
7
|
+
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
8
|
+
/* Unless required by applicable law or agreed to in writing, software */
|
9
|
+
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
10
|
+
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
11
|
+
/* See the License for the specific language governing permissions and */
|
12
|
+
/* limitations under the License. */
|
13
|
+
|
14
|
+
#include <capng.h>
|
15
|
+
|
16
|
+
capng_select_t
|
17
|
+
select_name_to_select_type(char *select_name)
|
18
|
+
{
|
19
|
+
if (strcmp(select_name, "caps") == 0) {
|
20
|
+
return CAPNG_SELECT_CAPS;
|
21
|
+
} else if (strcmp(select_name, "bounds") == 0) {
|
22
|
+
return CAPNG_SELECT_BOUNDS;
|
23
|
+
} else if (strcmp(select_name, "both") == 0) {
|
24
|
+
return CAPNG_SELECT_BOTH;
|
25
|
+
#if defined(CAPNG_SELECT_AMBIENT)
|
26
|
+
} else if (strcmp(select_name, "ambient") == 0) {
|
27
|
+
return CAPNG_SELECT_AMBIENT;
|
28
|
+
#endif
|
29
|
+
#if defined(CAPNG_SELECT_ALL)
|
30
|
+
} else if (strcmp(select_name, "all") == 0) {
|
31
|
+
return CAPNG_SELECT_ALL;
|
32
|
+
#endif
|
33
|
+
} else {
|
34
|
+
rb_raise(rb_eArgError, "unknown select name %s", select_name);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
capng_act_t
|
39
|
+
action_name_to_action_type(char *action_name)
|
40
|
+
{
|
41
|
+
if (strcmp(action_name, "drop") == 0) {
|
42
|
+
return CAPNG_DROP;
|
43
|
+
} else if (strcmp(action_name, "add") == 0) {
|
44
|
+
return CAPNG_ADD;
|
45
|
+
} else {
|
46
|
+
rb_raise(rb_eArgError, "unknown action name %s", action_name);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
capng_print_t
|
51
|
+
print_name_to_print_type(char *print_name)
|
52
|
+
{
|
53
|
+
if (strcmp(print_name, "stdout") == 0) {
|
54
|
+
return CAPNG_PRINT_STDOUT;
|
55
|
+
} else if (strcmp(print_name, "buffer") == 0) {
|
56
|
+
return CAPNG_PRINT_BUFFER;
|
57
|
+
} else {
|
58
|
+
rb_raise(rb_eArgError, "unknown print name %s", print_name);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
capng_type_t
|
63
|
+
capability_type_name_to_capability_type(char *capability_name)
|
64
|
+
{
|
65
|
+
if (strcmp(capability_name, "effective") == 0) {
|
66
|
+
return CAPNG_EFFECTIVE;
|
67
|
+
} else if (strcmp(capability_name, "permitted") == 0) {
|
68
|
+
return CAPNG_PERMITTED;
|
69
|
+
} else if (strcmp(capability_name, "inheritable") == 0) {
|
70
|
+
return CAPNG_INHERITABLE;
|
71
|
+
} else if (strcmp(capability_name, "bounding_set") == 0) {
|
72
|
+
return CAPNG_BOUNDING_SET;
|
73
|
+
#if defined(CAPNG_AMBIENT)
|
74
|
+
} else if (strcmp(capability_name, "ambient") == 0) {
|
75
|
+
return CAPNG_AMBIENT;
|
76
|
+
#endif
|
77
|
+
} else {
|
78
|
+
rb_raise(rb_eArgError, "unknown capability name: %s", capability_name);
|
79
|
+
}
|
80
|
+
}
|
data/lib/capng.rb
CHANGED
@@ -7,6 +7,21 @@ class CapNG
|
|
7
7
|
alias_method :caps_file_raw, :caps_file
|
8
8
|
alias_method :apply_caps_file_raw, :apply_caps_file
|
9
9
|
alias_method :update_raw, :update
|
10
|
+
alias_method :initialize_raw, :initialize
|
11
|
+
|
12
|
+
def initialize(target = nil, pid_or_path = nil)
|
13
|
+
if target.nil?
|
14
|
+
initialize_raw
|
15
|
+
elsif target && pid_or_path.is_a?(Integer)
|
16
|
+
initialize_raw(target, pid_or_path)
|
17
|
+
elsif target && pid_or_path.is_a?(String) && File.exist?(pid_or_path)
|
18
|
+
File.open(pid_or_path) do
|
19
|
+
initialize_raw(target, pid_or_path);
|
20
|
+
end
|
21
|
+
else
|
22
|
+
initialize_raw
|
23
|
+
end
|
24
|
+
end
|
10
25
|
|
11
26
|
def caps_file(file_or_string_path)
|
12
27
|
if file_or_string_path.is_a?(String) && File.exist?(file_or_string_path)
|
@@ -34,9 +49,13 @@ class CapNG
|
|
34
49
|
|
35
50
|
def update(action, type, capability_or_capability_array)
|
36
51
|
if capability_or_capability_array.is_a?(Array) && !capability_or_capability_array.empty?
|
52
|
+
results = []
|
37
53
|
capability_or_capability_array.each do |capability|
|
38
|
-
update_raw(action, type, capability)
|
54
|
+
result = update_raw(action, type, capability)
|
55
|
+
results << result
|
56
|
+
return results if !result
|
39
57
|
end
|
58
|
+
results
|
40
59
|
else
|
41
60
|
update_raw(action, type, capability_or_capability_array)
|
42
61
|
end
|
data/lib/capng/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capng_c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Hatake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- ext/capng/extconf.rb
|
97
97
|
- ext/capng/print.c
|
98
98
|
- ext/capng/state.c
|
99
|
+
- ext/capng/utils.c
|
99
100
|
- lib/capng.rb
|
100
101
|
- lib/capng/version.rb
|
101
102
|
homepage: https://github.com/cosmo0920/cap-ng_c
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.1.4
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: libcap-ng bindings for Ruby.
|