solaris-file 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,108 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: solaris-file
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 7
10
- version: 0.3.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel J. Berger
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-30 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: test-unit
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 9
29
- segments:
30
- - 2
31
- - 1
32
- - 1
33
- version: 2.1.1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.5.0
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: sys-filesystem
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.5.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: sys-filesystem
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 17
45
- segments:
46
- - 0
47
- - 3
48
- - 1
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
49
37
  version: 0.3.1
50
38
  type: :development
51
- version_requirements: *id002
52
- description: " The solaris-file library provides Solaris-specific access control\n methods to the File class. It also provides methods for identifying\n trivial and door files, interfaces for the realpath() and resolvepath()\n functions, and an overloaded ftype method.\n"
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.1
46
+ description: ! " The solaris-file library provides Solaris-specific access control\n
47
+ \ methods to the File class. It also provides methods for identifying\n trivial
48
+ and door files, an interfaces for the resolvepath()\n function, and an overloaded
49
+ ftype method.\n"
53
50
  email: djberg96@gmail.com
54
51
  executables: []
55
-
56
- extensions:
57
- - ext/extconf.rb
58
- extra_rdoc_files:
52
+ extensions: []
53
+ extra_rdoc_files:
59
54
  - README
60
55
  - CHANGES
61
56
  - MANIFEST
62
- - ext/solaris/sfile.c
63
- files:
57
+ files:
64
58
  - CHANGES
65
59
  - MANIFEST
66
60
  - README
67
61
  - Rakefile
68
62
  - examples/example_solaris_file.rb
69
- - ext/extconf.rb
70
- - ext/solaris/sfile.c
71
- - ext/solaris/sfile.h
72
63
  - solaris-file.gemspec
73
64
  - test/test_solaris_file.rb
74
- homepage: http://www.rubyforge.org/projects/solarisutils
75
- licenses:
65
+ - lib/solaris/file.rb
66
+ - lib/solaris/file/stat.rb
67
+ - lib/solaris/file/structs.rb
68
+ - lib/solaris/file/constants.rb
69
+ - lib/solaris/file/functions.rb
70
+ homepage: http://www.github.com/djberg96/solaris-file
71
+ licenses:
76
72
  - Artistic 2.0
77
73
  post_install_message:
78
74
  rdoc_options: []
79
-
80
- require_paths:
75
+ require_paths:
81
76
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
83
78
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
91
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
84
  none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
100
89
  requirements: []
101
-
102
90
  rubyforge_project: solarisutils
103
- rubygems_version: 1.8.5
91
+ rubygems_version: 1.8.24
104
92
  signing_key:
105
93
  specification_version: 3
106
94
  summary: ACL and other methods for the File class on Solaris
107
- test_files:
95
+ test_files:
108
96
  - test/test_solaris_file.rb
data/ext/extconf.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'mkmf'
2
- require 'fileutils'
3
-
4
- dir_config('file')
5
-
6
- $INCFLAGS += " -Isolaris"
7
-
8
- have_library('sec')
9
- create_makefile('solaris/file', 'solaris')
data/ext/solaris/sfile.c DELETED
@@ -1,498 +0,0 @@
1
- #include <ruby.h>
2
- #include <rubyio.h>
3
- #include <sys/acl.h>
4
- #include <sys/param.h>
5
- #include <sys/stat.h>
6
- #include <unistd.h>
7
- #include <fcntl.h>
8
- #include <sfile.h>
9
-
10
- /*
11
- * call-seq:
12
- * File.acl_count(file_name)
13
- *
14
- * Returns the number of ACL entries for +file_name+. Returns 0 if +file_name+
15
- * is a trivial file.
16
- */
17
- static VALUE acl_count(VALUE klass, VALUE v_path){
18
- int num_acls = 0;
19
- char pathp[PATH_MAX];
20
-
21
- SafeStringValue(v_path);
22
-
23
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
24
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
25
-
26
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
27
- rb_sys_fail(0);
28
-
29
- if(num_acls == MIN_ACL_ENTRIES)
30
- num_acls = 0;
31
-
32
- return INT2FIX(num_acls);
33
- }
34
-
35
- /*
36
- * call-seq:
37
- * File#acl_count
38
- *
39
- * Returns the number of ACL entries for the current handle. Returns 0 if
40
- * the file is a trivial file.
41
- */
42
- static VALUE acl_icount(VALUE self){
43
- int num_acls = 0;
44
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
45
-
46
- if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
47
- rb_sys_fail(0);
48
-
49
- if(num_acls == MIN_ACL_ENTRIES)
50
- num_acls = 0;
51
-
52
- return INT2FIX(num_acls);
53
- }
54
-
55
- /*
56
- * call-seq:
57
- * File.acl_read(file_name)
58
- *
59
- * Returns an array of ACLStruct's that contain three members each:
60
- *
61
- * - acl_type (String)
62
- * - acl_id (Integer)
63
- * - acl_perm (Integer)
64
- *
65
- * Returns nil if +file_name+ is a trivial file.
66
- */
67
- static VALUE acl_read(VALUE klass, VALUE v_path){
68
- int num_acls = 0;
69
- char pathp[PATH_MAX];
70
- VALUE v_array = Qnil;
71
- int i;
72
-
73
- SafeStringValue(v_path);
74
-
75
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
76
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
77
-
78
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
79
- rb_sys_fail(0);
80
-
81
- if(num_acls != MIN_ACL_ENTRIES){
82
- aclent_t* acl_buf;
83
- v_array = rb_ary_new();
84
-
85
- if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
86
- rb_sys_fail(0);
87
-
88
- if(acl(pathp, GETACL, num_acls, acl_buf) != num_acls)
89
- rb_sys_fail(0);
90
-
91
- for(i = 0; i < num_acls; i++){
92
- rb_ary_push(v_array,
93
- rb_struct_new(sACLStruct,
94
- acl_type_string(acl_buf[i].a_type),
95
- INT2FIX(acl_buf[i].a_id),
96
- INT2FIX(acl_buf[i].a_perm)
97
- )
98
- );
99
- }
100
-
101
- free(acl_buf);
102
- }
103
-
104
- return v_array;
105
- }
106
-
107
- /*
108
- * call-seq:
109
- * File#acl_read
110
- *
111
- * Returns an array of ACLStruct's that contain three members each:
112
- *
113
- * - acl_type (String)
114
- * - acl_id (Integer)
115
- * - acl_perm (Integer)
116
- *
117
- * Returns nil if the file is a trivial file.
118
- */
119
- static VALUE acl_iread(VALUE self){
120
- int i;
121
- int num_acls = 0;
122
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
123
- VALUE v_array = Qnil;
124
-
125
- if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
126
- rb_sys_fail(0);
127
-
128
- if(num_acls != MIN_ACL_ENTRIES){
129
- aclent_t* acl_buf;
130
- v_array = rb_ary_new();
131
-
132
- if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
133
- rb_sys_fail(0);
134
-
135
- if(facl(fd, GETACL, num_acls, acl_buf) != num_acls)
136
- rb_sys_fail(0);
137
-
138
- for(i = 0; i < num_acls; i++){
139
- rb_ary_push(v_array,
140
- rb_struct_new(sACLStruct,
141
- acl_type_string(acl_buf[i].a_type),
142
- INT2FIX(acl_buf[i].a_id),
143
- INT2FIX(acl_buf[i].a_perm)
144
- )
145
- );
146
- }
147
-
148
- free(acl_buf);
149
- }
150
-
151
- return v_array;
152
- }
153
-
154
- /*
155
- * call-seq:
156
- * File.acl_read_text(file_name)
157
- *
158
- * Returns a textual representation of the ACL for +file_name+. If +file_name+
159
- * is a trivial file, nil is returned.
160
- */
161
- static VALUE acl_read_text(VALUE klass, VALUE v_path){
162
- aclent_t* acl_buf;
163
- int num_acls = 0;
164
- char* acl_text;
165
- char pathp[PATH_MAX];
166
- VALUE v_text = Qnil;
167
-
168
- SafeStringValue(v_path);
169
-
170
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
171
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
172
-
173
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
174
- rb_sys_fail(0);
175
-
176
- if(num_acls != MIN_ACL_ENTRIES){
177
- if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
178
- rb_sys_fail(0);
179
-
180
- if(acl(pathp, GETACL, num_acls, acl_buf) != num_acls)
181
- rb_sys_fail(0);
182
-
183
- acl_text = acltotext(acl_buf, num_acls);
184
-
185
- free(acl_buf);
186
- v_text = rb_str_new2(acl_text);
187
- }
188
-
189
- return v_text;
190
- }
191
-
192
- /*
193
- * call-seq:
194
- * File.acl_write_text(file_name, acl_text)
195
- *
196
- * Sets the ACL for +file_name+ using +acl_text+. The +acl_text+ argument is a
197
- * human readable ACL text String.
198
- *
199
- * If +acl_text+ is invalid then a Solaris::File::Error is raised, and in most
200
- * cases the offending entry number will be identified.
201
- */
202
- static VALUE acl_write_text(VALUE klass, VALUE v_path, VALUE v_text){
203
- aclent_t* acl_buf;
204
- int num_acls, which, rv;
205
- char pathp[PATH_MAX];
206
- char* acl_text = StringValuePtr(v_text);
207
-
208
- SafeStringValue(v_path);
209
- SafeStringValue(v_text);
210
-
211
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
212
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
213
-
214
- if((acl_buf = aclfromtext(acl_text, &num_acls)) == NULL)
215
- rb_raise(cSolarisFileError, "invalid ACL text");
216
-
217
- rv = aclcheck(acl_buf, num_acls, &which);
218
- do_acl_check(rv, which);
219
-
220
- if(acl(pathp, SETACL, num_acls, acl_buf) == -1){
221
- free(acl_text);
222
- rb_sys_fail(0);
223
- }
224
-
225
- free(acl_text);
226
- free(acl_buf);
227
-
228
- return klass;
229
- }
230
-
231
- /*
232
- * call-seq:
233
- * File.resolvepath(path)
234
- *
235
- * Resolves all symbolic links in +path+. All "." components are removed, as
236
- * well as all nonleading ".." components and their preceding directory
237
- * component. If leading ".." components resolve to the root directory, they
238
- * are replaced by "/".
239
- */
240
- static VALUE solaris_resolvepath(VALUE klass, VALUE v_path){
241
- char pathp[PATH_MAX];
242
-
243
- SafeStringValue(v_path);
244
- memset(pathp, 0, PATH_MAX);
245
-
246
- if(resolvepath(StringValuePtr(v_path), pathp, PATH_MAX) == -1)
247
- rb_sys_fail(0);
248
-
249
- return rb_str_new2(pathp);
250
- }
251
-
252
- /*
253
- * call-seq:
254
- * File.realpath(path)
255
- *
256
- * Resolves all symbolic links in +path+. Resolves to an absolute pathname
257
- * where possible.
258
- *
259
- * The difference between this method and File.resolvepath is that this method
260
- * will resolve to an absolute pathname where possible.
261
- */
262
- static VALUE solaris_realpath(VALUE klass, VALUE v_path){
263
- char pathp[PATH_MAX];
264
-
265
- SafeStringValue(v_path);
266
-
267
- if(realpath(StringValuePtr(v_path), pathp) == NULL)
268
- rb_sys_fail(0);
269
-
270
- return rb_str_new2(pathp);
271
- }
272
-
273
- /* Instance Methods */
274
-
275
- /*
276
- * call-seq:
277
- * File#acl_write_text(acl_text)
278
- *
279
- * Sets the ACL for the file using +acl_text+. The +acl_text+ argument is a
280
- * human readable ACL text String.
281
- *
282
- * If +acl_text+ is invalid then a File::Solaris::Error is raised, and in most
283
- * cases the offending entry number will be identified.
284
- */
285
- static VALUE acl_iwrite_text(VALUE self, VALUE v_text){
286
- aclent_t* acl_buf;
287
- int num_acls, which, rv;
288
- char* acl_text = StringValuePtr(v_text);
289
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
290
-
291
- SafeStringValue(v_text);
292
-
293
- if((acl_buf = aclfromtext(acl_text, &num_acls)) == NULL)
294
- rb_raise(cSolarisFileError, "invalid ACL text");
295
-
296
- rv = aclcheck(acl_buf, num_acls, &which);
297
- do_acl_check(rv, which);
298
-
299
- if(facl(fd, SETACL, num_acls, acl_buf) == -1){
300
- free(acl_text);
301
- rb_sys_fail(0);
302
- }
303
-
304
- free(acl_text);
305
- free(acl_buf);
306
-
307
- return self;
308
- }
309
-
310
-
311
- /*
312
- * call-seq:
313
- * File#acl_read_text
314
- *
315
- * Returns a textual representation of the ACL for the current handle. If
316
- * the file is a trivial file, nil is returned.
317
- */
318
- static VALUE acl_iread_text(VALUE self){
319
- char* acl_text;
320
- int num_acls = 0;
321
- int fd = FIX2INT(rb_funcall(self,rb_intern("fileno"),0,0));
322
- VALUE v_text = Qnil;
323
-
324
- if((num_acls = facl(fd,GETACLCNT,0,NULL)) == -1)
325
- rb_sys_fail(0);
326
-
327
- if(num_acls != MIN_ACL_ENTRIES){
328
- aclent_t* acl_buf;
329
-
330
- if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
331
- rb_sys_fail(0);
332
-
333
- if(facl(fd, GETACL, num_acls, acl_buf) != num_acls)
334
- rb_sys_fail(0);
335
-
336
- acl_text = acltotext(acl_buf,num_acls);
337
-
338
- free(acl_buf);
339
- v_text = rb_str_new2(acl_text);
340
- }
341
-
342
- return v_text;
343
- }
344
-
345
- /*
346
- * call-seq:
347
- * File.trivial?(file_name)
348
- *
349
- * Returns true if +file_name+ is a trivial file, i.e. has no additional ACL
350
- * entries. Otherwise, it returns false.
351
- */
352
- static VALUE acl_is_trivial(VALUE klass, VALUE v_path){
353
- char pathp[PATH_MAX];
354
- int num_acls = 0;
355
- VALUE v_bool = Qfalse;
356
-
357
- SafeStringValue(v_path);
358
-
359
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
360
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
361
-
362
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
363
- rb_sys_fail(0);
364
-
365
- if(num_acls == MIN_ACL_ENTRIES)
366
- v_bool = Qtrue;
367
-
368
- return v_bool;
369
- }
370
-
371
- /*
372
- * call-seq:
373
- * File#trivial?
374
- *
375
- * Returns true if the current file is a trivial file, i.e. has no additional
376
- * ACL entries. Otherwise, it returns false.
377
- */
378
- static VALUE acl_itrivial(VALUE self){
379
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
380
- int num_acls = 0;
381
- VALUE v_bool = Qfalse;
382
-
383
- if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
384
- rb_sys_fail(0);
385
-
386
- if(num_acls == MIN_ACL_ENTRIES)
387
- v_bool = Qtrue;
388
-
389
- return v_bool;
390
- }
391
-
392
- /* File::Stat Additions */
393
-
394
- /*
395
- * call-seq:
396
- * statfile.door?
397
- *
398
- * Returns true if +statfile+ is a door, false otherwise.
399
- */
400
- static VALUE solaris_stat_is_door(VALUE self){
401
- VALUE v_bool = Qtrue;
402
- int mode = FIX2INT(rb_funcall(self, rb_intern("mode"), 0, 0));
403
-
404
- if(S_ISDOOR(mode) == 0)
405
- v_bool = Qfalse;
406
-
407
- return v_bool;
408
- }
409
-
410
- /*
411
- * call-seq:
412
- * statfile.ftype
413
- *
414
- * Returns the file type. This method is identical to the core Ruby method
415
- * except that it returns "door" if the file is a door file.
416
- */
417
- static VALUE solaris_stat_ftype(VALUE self){
418
- int mode = FIX2INT(rb_funcall(self, rb_intern("mode"), 0, 0));
419
-
420
- if(S_ISDOOR(mode))
421
- return rb_str_new2("door");
422
- else
423
- return rb_funcall(self, rb_intern("old_ftype"), 0, 0);
424
- }
425
-
426
- /*
427
- * call-seq:
428
- * File.door?(file)
429
- *
430
- * Returns true if +file+ is a door file, false otherwise.
431
- */
432
- static VALUE solaris_file_is_door(VALUE klass, VALUE v_file){
433
- VALUE v_stat = rb_funcall(rb_cStat, rb_intern("new"), 1, v_file);
434
- return solaris_stat_is_door(v_stat);
435
- }
436
-
437
- /*
438
- * call-seq:
439
- * File.ftype(file)
440
- *
441
- * The File.ftype method was modified so that 'door' is returned if the
442
- * +file+ is a door file.
443
- */
444
- static VALUE solaris_file_ftype(VALUE klass, VALUE v_file){
445
- VALUE v_stat = rb_funcall(rb_cStat, rb_intern("new"), 1, v_file);
446
- return solaris_stat_ftype(v_stat);
447
- }
448
-
449
- /*
450
- * Adds ACL support for the File class on Solaris
451
- */
452
- void Init_file(){
453
- /* Error raised if an error occurs when reading or writing ACL properties */
454
- cSolarisFileError = rb_define_class_under(
455
- rb_cFile,
456
- "SolarisError",
457
- rb_eStandardError
458
- );
459
-
460
- // Remove these methods temporarily to avoid warnings.
461
- rb_undef_method(CLASS_OF(rb_cFile), "ftype");
462
- rb_undef_method(CLASS_OF(rb_cFile), "realpath");
463
-
464
- // Singleton Methods
465
-
466
- rb_define_singleton_method(rb_cFile, "acl_count", acl_count, 1);
467
- rb_define_singleton_method(rb_cFile, "acl_read", acl_read, 1);
468
- rb_define_singleton_method(rb_cFile, "acl_read_text", acl_read_text, 1);
469
- rb_define_singleton_method(rb_cFile, "acl_write_text", acl_write_text, 2);
470
- rb_define_singleton_method(rb_cFile, "door?", solaris_file_is_door, 1);
471
- rb_define_singleton_method(rb_cFile, "ftype", solaris_file_ftype, 1);
472
- rb_define_singleton_method(rb_cFile, "realpath", solaris_realpath, 1);
473
- rb_define_singleton_method(rb_cFile, "resolvepath", solaris_resolvepath, 1);
474
- rb_define_singleton_method(rb_cFile, "trivial?", acl_is_trivial, 1);
475
-
476
- // File Instance Methods
477
-
478
- rb_define_method(rb_cFile, "acl_count", acl_icount, 0);
479
- rb_define_method(rb_cFile, "acl_read", acl_iread, 0);
480
- rb_define_method(rb_cFile, "acl_read_text", acl_iread_text, 0);
481
- rb_define_method(rb_cFile, "acl_write_text", acl_iwrite_text, 1);
482
- rb_define_method(rb_cFile, "trivial?", acl_itrivial, 0);
483
-
484
- // File::Stat Instance Methods
485
-
486
- rb_define_alias(rb_cStat, "old_ftype", "ftype");
487
- rb_define_method(rb_cStat, "door?", solaris_stat_is_door, 0);
488
- rb_define_method(rb_cStat, "ftype", solaris_stat_ftype, 0);
489
-
490
- // Structs
491
-
492
- sACLStruct = rb_struct_define("ACLStruct",
493
- "acl_type", "acl_id", "acl_perm", NULL
494
- );
495
-
496
- /* 0.3.7: The version of the solaris-file library */
497
- rb_define_const(rb_cFile, "SOLARIS_VERSION", rb_str_new2(SOLARIS_VERSION));
498
- }