File: ACL.pm

package info (click to toggle)
liblinux-acl-perl 0.05-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 74; makefile: 3
file content (202 lines) | stat: -rw-r--r-- 4,216 bytes parent folder | download | duplicates (2)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package Linux::ACL;

use warnings;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw(getfacl setfacl);
our $VERSION = '0.05';

require XSLoader;
XSLoader::load('Linux::ACL', $VERSION);

1;
=head1 NAME

Linux::ACL - Perl extension for reading and setting Access Control Lists for files by libacl linux library.

=head1 VERSION

Version 0.05

=cut




=head1 SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

  use Linux::ACL;
  ($acl, $default_acl) = getfacl("path/to/file");
  setfacl("path/to/file", $acl [, $default_acl]);

=head1 EXPORT

=over

=item setfacl($$;$)

Set the ACL of the file or directory named by C<$path> to that
specified by C<$acl>.  If C<$path> names a directory, then the optional
C<$default_acl> argument can also be passed to specify the default ACL
for the directory.  See L<"ACL structure"> for information on how the
C<$acl> and C<$default_acl> hashes should be constructed.

=item getfacl($)

Return a reference to a hash containing information about the file's
ACL.  If the file is a directory with a default ACL, then a list is
returned, with the first entry being a hash reference to the ACL, and
the second being a hash reference to the default ACL.  See L<"Accessing
ACL structures"> for information on how to access these hashes, and
L<"ACL structure"> for information on how these hashes are internally
constructed.

=back

=head1 RETURN VALUES

=over

=item setfacl

returns TRUE if successful and FALSE if unsuccessful.

=item getfacl

if successful, returns a list containing a reference to
the hash describing an acl, and, if there is a default acl, a
reference to the hash describing the default acl.  If unsuccessful,
C<getfacl> returns a null list.

=back

=head1 Examples

getfacl example

  use Linux::ACL;
  use Data::Dumper;
  my @a = getfacl("/tmp");
  print Dumper \@a;

prints:

  $VAR1 = [
          {
            'uperm' => {
                         'w' => 1,
                         'r' => 1,
                         'x' => 1
                       },
            'gperm' => {
                         'w' => 1,
                         'r' => 1,
                         'x' => 1
                       },
            'other' => {
                         'w' => 1,
                         'r' => 1,
                         'x' => 1
                       }
          }
        ];

setfacl example

  use Linux::ACL;
  setfacl("/mnt/testacl/d", {
  	uperm=>{r=>1,w=>1,x=>1},
  	gperm=>{r=>1,w=>1,x=>1},
  	other=>{r=>1,w=>0,x=>1},
  	mask=>{r=>1,w=>1,x=>1},
  	group=>{
  		123456=>{r=>1,w=>1,x=>1}
  	}
  }, {
  	uperm=>{r=>1,w=>1,x=>1},
  	gperm=>{r=>1,w=>1,x=>1},
  	other=>{r=>1,w=>1,x=>1},
  	mask=>{r=>1,w=>1,x=>1}
  });
  system("getfacl /mnt/testacl/d");

prints:

  $ getfacl d
  # file: d
  # owner: user
  # group: user
  user::rwx
  group::rwx
  group:123456:rwx
  mask::rwx
  other::r-x
  default:user::rwx
  default:group::rwx
  default:mask::rwx
  default:other::rwx

=head1 AUTHOR

Yuriy Nazarov, C<< <nazarov at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-linux-acl at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Linux-ACL>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.


=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Linux::ACL


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Linux-ACL>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Linux-ACL>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/Linux-ACL>

=item * Search CPAN

L<http://search.cpan.org/dist/Linux-ACL/>

=back


=head1 ACKNOWLEDGEMENTS


=head1 LICENSE AND COPYRIGHT

Copyright 2013 Yuriy Nazarov.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


=cut