Tizen 2.0 Release
[framework/base/acl.git] / man / man1 / setfacl.1
1 .\" Access Control Lists manual pages
2 .\"
3 .\" (C) 2000 Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
4 .\"
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual.  If not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\"
24 .TH SETFACL 1 "ACL File Utilities" "May 2000" "Access Control Lists"
25 .SH NAME
26 setfacl \- set file access control lists
27 .SH SYNOPSIS
28
29 .B setfacl
30 [\-bkndRLPvh] [{\-m|\-x} acl_spec] [{\-M|\-X} acl_file] file ...
31
32 .B setfacl
33 \-\-restore=file
34
35 .SH DESCRIPTION
36 This utility sets Access Control Lists (ACLs) of files and directories.
37 On the command line, a sequence of commands is followed by a sequence of
38 files (which in turn can be followed by another sequence of commands, ...).
39
40 The options
41 .I \-m,
42 and
43 .I \-x
44 expect an ACL on the command line. Multiple ACL entries are separated
45 by comma characters (`,'). The options
46 .I \-M,
47 and
48 .I \-X
49 read an ACL from a file or from standard input. The ACL entry format is described in Section
50 ACL ENTRIES.
51
52 The
53 .IR "\-\-set" " and " "\-\-set-file"
54 options set the ACL of a file or a directory. The previous ACL is
55 replaced.
56 ACL entries for this operation must include permissions.
57
58 The
59 .IR "\-m (\-\-modify)" " and " "\-M (\-\-modify-file)"
60 options modify the ACL of a file or directory.
61 ACL entries for this operation must include permissions.
62
63 The
64 .IR "\-x (\-\-remove)" " and " "\-X (\-\-remove-file)"
65 options remove ACL enries. Only
66 ACL entries without the
67 .I perms
68 field are accepted as parameters, unless POSIXLY_CORRECT is defined.
69
70 When reading from files using the 
71 .I \-M,
72 and
73 .IR \-X
74 options, setfacl accepts the output getfacl produces.
75 There is at most one ACL entry per line. After a Pound sign (`#'),
76 everything up to the end of the line is treated as a comment.
77
78 If setfacl is used on a file system which does not support ACLs, setfacl
79 operates on the file mode permission bits. If the ACL does not fit completely
80 in the permission bits, setfacl modifies the file mode permission bits to reflect the ACL as closely as possible, writes an error message to standard error, and returns with an exit status greater than 0.
81
82 .SS PERMISSIONS
83 The file owner and processes capable of CAP_FOWNER are granted the right
84 to modify ACLs of a file. This is analogous to the permissions required
85 for accessing the file mode. (On current Linux systems, root is the only
86 user with the CAP_FOWNER capability.)
87
88 .SS OPTIONS
89 .TP 4
90 .I \-b, \-\-remove-all
91 Remove all extended ACL entries. The base ACL entries of the owner, group and others are retained.
92 .TP 4
93 .I \-k, \-\-remove-default
94 Remove the Default ACL. If no Default ACL exists, no warnings are issued.
95 .TP 4
96 .I \-n, \-\-no-mask
97 Do not recalculate the effective rights mask. The default behavior of
98 setfacl is to recalculate the ACL mask entry, unless a mask entry was explicitly given.
99 The mask entry is set to the union of all permissions of the owning group, and all named user and group entries. (These are exactly the entries affected by the mask entry).
100 .TP 4
101 .I \-\-mask
102 Do recalculate the effective rights mask, even if an ACL mask entry was explicitly given. (See the
103 .IR "\-n " option.)
104 .TP 4
105 .I \-d, \-\-default
106 All operations apply to the Default ACL. Regular ACL entries in the
107 input set are promoted to Default ACL entries. Default ACL entries in
108 the input set are discarded. (A warning is issued if that happens).
109 .TP 4
110 .I \-\-restore=file
111 Restore a permission backup created by `getfacl \-R' or similar. All permissions
112 of a complete directory subtree are restored using this mechanism. If the input
113 contains owner comments or group comments, setfacl attempts to restore the
114 owner and owning group. If the input contains flags comments (which define the setuid,
115 setgid, and sticky bits), setfacl sets those three bits accordingly; otherwise,
116 it clears them. This option cannot be mixed with other options except `\-\-test'.
117 .TP 4
118 .I \-\-test
119 Test mode. Instead of changing the ACLs of any files, the resulting ACLs are listed.
120 .TP 4
121 .I \-R, \-\-recursive
122 Apply operations to all files and directories recursively. This option cannot be mixed with `\-\-restore'.
123 .TP 4
124 .I \-L, \-\-logical
125 Logical walk, follow symbolic links to directories. The default behavior is to follow
126 symbolic link arguments, and skip symbolic links encountered in subdirectories.
127 Only effective in combination with \-R.
128 This option cannot be mixed with `\-\-restore'.
129 .TP 4
130 .I \-P, \-\-physical
131 Physical walk, do not follow symbolic links to directories.
132 This also skips symbolic link arguments.
133 Only effective in combination with \-R.
134 This option cannot be mixed with `\-\-restore'.
135 .TP 4
136 .I \-v, \-\-version
137 Print the version of setfacl and exit.
138 .TP 4
139 .I \-h, \-\-help
140 Print help explaining the command line options.
141 .TP 4
142 .I \-\-
143 End of command line options. All remaining parameters are interpreted as file names, even if they start with a dash.
144 .TP 4
145 .I \-
146 If the file name parameter is a single dash, setfacl reads a list of files from standard input.
147
148 .SS ACL ENTRIES
149 The setfacl utility recognizes the following ACL entry formats (blanks
150 inserted for clarity):
151
152 .fam C
153 .TP
154 .RI "[d[efault]:] [u[ser]:]" "uid " [: perms ]
155 .fam T
156 Permissions of a named user. Permissions of the file owner if
157 .I uid
158 is empty.
159 .fam C
160 .TP
161 .RI "[d[efault]:] g[roup]:" "gid " [: perms ]
162 .fam T
163 Permissions of a named group. Permissions of the owning group if
164 .I gid
165 is empty.
166 .fam C
167 .TP
168 .RI "[d[efault]:] m[ask][:] [:" perms ]
169 .fam T
170 Effective rights mask
171 .fam C
172 .TP
173 .RI "[d[efault]:] o[ther][:] [:" perms ]
174 .fam T
175 Permissions of others.
176 .PP
177 Whitespace between delimiter characters and non-delimiter characters is ignored.
178 .PP
179 .PP
180 Proper ACL entries including permissions are used in modify and set operations. (options
181 .IR \-m ", " \-M ", " \-\-set " and " \-\-set-file ).
182 Entries without the
183 .I perms
184 field are used for
185 .I deletion
186 of entries (options
187 .IR \-x " and " \-X ).
188 .PP
189 For
190 .I uid
191 and
192 .I gid
193 you can specify either a name or a number.
194 .PP
195 The
196 .I perms
197 field is a combination of characters that indicate the permissions: read
198 .IR (r) ,
199 write
200 .IR (w) ,
201 execute
202 .IR (x) ,
203 execute only if the file is a directory or already has execute permission
204 for some user
205 .IR (X) .
206 Alternatively, the
207 .I perms
208 field can be an octal digit (0\-7).
209 .PP
210 .SS AUTOMATICALLY CREATED ENTRIES
211 Initially, files and directories contain only the three base ACL entries
212 for the owner, the group, and others. There are some rules that
213 need to be satisfied in order for an ACL to be valid:
214 .IP * 4
215 The three base entries cannot be removed. There must be exactly one
216 entry of each of these base entry types.
217 .IP * 4
218 Whenever an ACL contains named user entries or named group objects,
219 it must also contain an effective rights mask.
220 .IP * 4
221 Whenever an ACL contains any Default ACL entries, the three Default ACL
222 base entries (default owner, default group, and default others) must also exist.
223 .IP * 4
224 Whenever a Default ACL contains named user entries or named group objects,
225 it must also contain a default effective rights mask.
226 .PP
227 To help the user ensure these rules, setfacl creates entries from existing
228 entries under the following conditions:
229 .IP * 4
230 If an ACL contains named user or named group entries, and
231 no mask entry exists, a mask entry containing the same permissions as
232 the group entry is created. Unless the
233 .I \-n
234 option is given, the permissions of the mask entry are further adjusted to include the union of all permissions affected by the mask entry. (See the
235 .I \-n
236 option description).
237 .IP * 4
238 If a Default ACL entry is created, and the Default ACL contains no
239 owner, owning group, or others entry, a copy of the ACL owner, owning group, or others entry is added to the Default ACL.
240 .IP * 4
241 If a Default ACL contains named user entries or named group entries, and no mask entry exists, a mask entry containing the same permissions as the default Default ACL's group entry is added. Unless the
242 .I \-n
243 option is given, the permissions of the mask entry are further adjusted to inclu
244 de the union of all permissions affected by the mask entry. (See the
245 .I \-n
246 option description).
247 .PP
248 .SH EXAMPLES
249 .PP
250 Granting an additional user read access
251 .RS
252 .fam C
253 setfacl \-m u:lisa:r file
254 .fam T
255 .RE
256 .PP
257 Revoking write access from all groups and all named users (using the effective rights mask)
258 .RS
259 .fam C
260 setfacl \-m m::rx file
261 .fam T
262 .RE
263 .PP
264 Removing a named group entry from a file's ACL
265 .RS
266 .fam C
267 setfacl \-x g:staff file
268 .fam T
269 .RE
270 .PP
271 Copying the ACL of one file to another
272 .RS
273 .fam C
274 getfacl file1 | setfacl \-\-set-file=\- file2
275 .fam T
276 .RE
277 .PP
278 Copying the access ACL into the Default ACL
279 .RS
280 .fam C
281 getfacl \-\-access dir | setfacl \-d \-M\- dir
282 .fam T
283 .RE
284 .SH CONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17
285 If the environment variable POSIXLY_CORRECT is defined, the default behavior of setfacl changes as follows: All non-standard options are disabled.
286 The ``default:'' prefix is disabled.
287 The
288 .IR \-x " and " \-X
289 options also accept permission fields (and ignore them). 
290 .SH AUTHOR
291 Andreas Gruenbacher,
292 .RI < a.gruenbacher@bestbits.at >.
293
294 Please send your bug reports, suggested features and comments to the
295 above address.
296 .SH SEE ALSO
297 .BR getfacl "(1), " chmod "(1), " umask "(1), " acl (5)