rcaps 0.9.9 → 0.9.10
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.
- data/rcaps.c +16 -16
- data/rcaps.h +0 -3
- metadata +1 -1
data/rcaps.c
CHANGED
@@ -126,17 +126,17 @@ static void caps_free (cap_t caps) {
|
|
126
126
|
*/
|
127
127
|
static VALUE caps_new (int argc, VALUE *argv, VALUE klass) {
|
128
128
|
cap_t caps;
|
129
|
-
VALUE cdata;
|
129
|
+
VALUE cdata, capstring;
|
130
|
+
|
131
|
+
rb_scan_args(argc, argv, "01", &capstring);
|
130
132
|
|
131
|
-
if (
|
133
|
+
if (NIL_P(capstring)) {
|
132
134
|
caps = cap_init();
|
133
|
-
} else if (argc > 1) {
|
134
|
-
rb_raise(rb_eArgError, "More than one argument to new()");
|
135
135
|
} else {
|
136
|
-
Check_Type(
|
137
|
-
caps = cap_from_text(StringValuePtr(
|
136
|
+
Check_Type(capstring, T_STRING);
|
137
|
+
caps = cap_from_text(StringValuePtr(capstring));
|
138
138
|
if (!caps)
|
139
|
-
|
139
|
+
rb_sys_fail("Bad capability text argument");
|
140
140
|
}
|
141
141
|
|
142
142
|
cdata = Data_Wrap_Struct(klass, 0, caps_free, caps);
|
@@ -155,7 +155,7 @@ static VALUE caps_get_proc (VALUE klass) {
|
|
155
155
|
VALUE argv[1];
|
156
156
|
|
157
157
|
if ((caps = cap_get_proc()) == NULL)
|
158
|
-
|
158
|
+
rb_sys_fail("Error retrieving active capabilties");
|
159
159
|
|
160
160
|
//as this is just a convenience wrapper instead of new(), we still
|
161
161
|
//want to call initialize.
|
@@ -204,7 +204,7 @@ static VALUE caps_clear (VALUE self) {
|
|
204
204
|
Data_Get_Struct(self, struct _cap_struct, caps);
|
205
205
|
|
206
206
|
if (cap_clear(caps) != 0)
|
207
|
-
|
207
|
+
rb_sys_fail("Error clearing capability set.");
|
208
208
|
|
209
209
|
return self;
|
210
210
|
}
|
@@ -219,7 +219,7 @@ static VALUE caps_set_proc (VALUE self) {
|
|
219
219
|
Data_Get_Struct(self, struct _cap_struct, caps);
|
220
220
|
|
221
221
|
if (cap_set_proc(caps) != 0)
|
222
|
-
|
222
|
+
rb_sys_fail("Error activating capabilities.");
|
223
223
|
|
224
224
|
return self;
|
225
225
|
}
|
@@ -241,10 +241,10 @@ static VALUE captoggle(VALUE self, VALUE caplist, cap_flag_t type, cap_flag_valu
|
|
241
241
|
case T_FIXNUM:
|
242
242
|
listsize = FIX2INT(arrsize);
|
243
243
|
if (listsize > CAP_LEASE)
|
244
|
-
rb_raise(rb_eArgError, "Too many capabilities to set at once
|
244
|
+
rb_raise(rb_eArgError, "Too many capabilities to set at once");
|
245
245
|
|
246
246
|
if ((set = malloc(listsize * sizeof(cap_value_t))) == NULL)
|
247
|
-
|
247
|
+
rb_sys_fail("Error allocating memory for capability array");
|
248
248
|
|
249
249
|
for (i = 0; i < listsize; i++) {
|
250
250
|
arrelem = rb_funcall(caplist, rb_intern("[]"), 1, INT2FIX(i));
|
@@ -252,20 +252,20 @@ static VALUE captoggle(VALUE self, VALUE caplist, cap_flag_t type, cap_flag_valu
|
|
252
252
|
arrval = FIX2INT(arrelem);
|
253
253
|
if (arrval < CAP_CHOWN || arrval > CAP_LEASE) {
|
254
254
|
free(set);
|
255
|
-
rb_raise(rb_eArgError, "Invalid capability
|
255
|
+
rb_raise(rb_eArgError, "Invalid capability in list argument");
|
256
256
|
}
|
257
257
|
|
258
258
|
set[i] = arrval;
|
259
259
|
}
|
260
260
|
break;
|
261
261
|
default: //if we're a bignum, we're way too large...
|
262
|
-
rb_raise(rb_eArgError, "Too many capabilities to set at once
|
262
|
+
rb_raise(rb_eArgError, "Too many capabilities to set at once");
|
263
263
|
break;
|
264
264
|
}
|
265
265
|
|
266
266
|
if (cap_set_flag(caps, type, listsize, set, toggle) != 0) {
|
267
267
|
free(set);
|
268
|
-
|
268
|
+
rb_sys_fail("Error making capability flag change");
|
269
269
|
}
|
270
270
|
|
271
271
|
if (set) free(set);
|
@@ -348,7 +348,7 @@ static VALUE capisset (VALUE self, VALUE cap, cap_flag_t flag) {
|
|
348
348
|
Check_Type(cap, T_FIXNUM);
|
349
349
|
|
350
350
|
if (cap_get_flag(caps, FIX2INT(cap), flag, &val) != 0)
|
351
|
-
|
351
|
+
rb_sys_fail("Error retrieving capability status");
|
352
352
|
|
353
353
|
return (val == CAP_SET ? Qtrue : Qfalse);
|
354
354
|
}
|
data/rcaps.h
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
#include <sys/capability.h>
|
2
2
|
|
3
|
-
/* prototypes */
|
4
3
|
static void caps_setup_flags (void); //define EFFECTIVE, PERMITTED, etc.
|
5
4
|
static void caps_setup_constants (void); //define names for capabilities
|
6
5
|
|
7
6
|
/* the standard c extension housekeeping methods */
|
8
|
-
//static VALUE caps_allocate (VALUE);
|
9
|
-
//static void caps_mark (cap_t);
|
10
7
|
static void caps_free (cap_t);
|
11
8
|
|
12
9
|
/* Caps class methods */
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rcaps
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
6
|
+
version: 0.9.10
|
7
7
|
date: 2008-09-27 00:00:00 -04:00
|
8
8
|
summary: A library for manipulating capabilities using the POSIX 1003.1e interfaces
|
9
9
|
require_paths:
|