This repository was archived by the owner on Apr 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
66 lines (46 loc) · 1.6 KB
/
Copy pathREADME
File metadata and controls
66 lines (46 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
An implementation of linux ACL (posix1e).
Provides more convenience than ruby-acl, and uses FFI so it requires no
extra compilation of c files, and works with jruby.
License:Ruby's GPL compatible dual license
Install ffi/nice-ffi and libacl
gem install ffi nice-ffi libacl
Usage example:
require 'libacl'
require 'test/unit/assertions'
include Test::Unit::Assertions
require 'fileutils'
include FileUtils
acl= LibACL::ACL.from_text 'user::rwx
group::rx
other::---
mask::rwx
user:root:rwx
group:daemon:rx'
assert acl.valid?
acl_invalid= LibACL::ACL.from_text '
user:nonexiestent_user:---
group:does_not_exist:rx
garbage_entry:user:::*:xyz'
assert !acl_invalid.valid?
#You can write ACL's to and read from directories and files
touch '/tmp/foo'
mkdir '/tmp/dir' unless File.exist? '/tmp/dir'
acl.set_file '/tmp/foo'
acl.set_default '/tmp/dir'
acl_foo = LibACL::ACL.from_file '/tmp/foo'
acl_def = LibACL::ACL.default '/tmp/dir'
assert_equal acl_foo.to_text, acl.to_text
assert_equal acl_def.to_text, acl.to_text
#Operate on each entry
p "Each entry in acl_foo:"
acl_foo.each do |entry|
puts entry
end
#You can query the acl and get a text representation
assert_equal acl_foo.user_obj.permset.to_s, 'rwx'
assert_equal acl_foo.other.permset.to_s, "---"
#Find works as expected, and convenience methods exist
found = acl_foo.find do |entry|
entry.tag_type == :mask
end
assert found == acl_foo.mask