2 .\" Copyright 2014 Nexenta Systems, Inc. All rights reserved.
3 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH ACL 5 "Nov 24, 2014"
9 acl \- Access Control Lists
12 Access control lists (ACLs) are discretionary access control mechanisms that
13 grant and deny access to files and directories. Two different ACL models are
14 supported in the Solaris release: POSIX-draft ACLs and NFSv4 ACLs.
17 The older, POSIX-draft model is supported by the UFS file system. This model is
18 based on a withdrawn ACL POSIX specification that was never standardized. It
19 was subsequently withdrawn by the POSIX committee.
22 The other model is based on the standards of the NFSv4 working group and is an
23 approved standard from the Internet Engineering Task Force (IETF). The ZFS file
24 system uses the NFSv4 model, and provides richer semantics and finer grained
25 permission capabilities than the POSIX-draft model.
26 .SS "\fBPOSIX\fR-draft \fBACL\fRs"
28 POSIX-draft ACLs provide an alternative security mechanism to basic UNIX file
29 permissions in the Solaris release. Their purpose is to further restrict access
30 to files and directories or to extend permissions to a particular user. ACLs
31 can be used to change the permissions for the standard owner, group and other
32 class bits of a file's mode. ACLs can give additional users and groups access
33 to the file. A directory can also have a special kind of ACL called a
34 \fBdefault\fR ACL, which defines ACL entries to be inherited by descendents of
35 the directory. POSIX-draft ACLs have an ACL entry called \fBmask\fR. The mask
36 defines the maximum permissions that can be granted to additional user and
37 group entries. Whenever a file is created or its mode is changed by
38 \fBchmod\fR(1) or \fBchmod\fR(2), the mask is recomputed. It is recomputed to
39 be the group permission defined in the mode passed to \fBchmod\fR(2).
42 The POSIX-draft ACL model uses the standard \fBrwx\fR model of traditional UNIX
46 An ACL is represented as follows:
50 \fIacl_entry\fR[,\fIacl_entry\fR]...
57 Each \fIacl_entry\fR contains one ACL entry. An ACL entry is represented by two
58 or three colon-separated(\fB:\fR) fields.
62 \fB\fIuser\fR:[\fIuid\fR]:\fIperms\fR\fR
65 If \fIuid\fR blank, it represents the file owner.
71 \fB\fIgroup\fR:[\fIgid\fR]:\fIperms\fR\fR
74 If \fIgid\fR is blank, it represents the owning group.
80 \fB\fIother\fR:\fIperms\fR\fR
83 Represents the file other class.
89 \fB\fImask\fR:\fIperms\fR\fR
92 Defines the \fBMAX\fR permission to hand out.
97 For example to give user \fBjoe\fR read and write permissions, the ACL entry is
107 .SS "\fBNFS\fRv4 \fBACL\fRs"
109 NFSv4 ACL model is based loosely on the Windows NT ACL model. NFSv4 ACLs
110 provide a much richer ACL model than POSIX-draft ACLs.
113 The major differences between NFSv4 and POSIX-draft ACLs are as follows:
118 NFSv4 ACLs provide finer grained permissions than the \fBrwx\fR model.
124 NFSv4 ACLs allow for both \fBALLOW\fR and \fBDENY\fR entries.
130 NFSv4 ACLs provide a rich set of inheritance semantics. POSIX ACLs also have
131 inheritance, but with the NFSv4 model you can control the following inheritance
137 Whether inheritance cascades to both files and directories or only to files or
144 In the case of directories, you can indicate whether inheritance is applied to
145 the directory itself, to just one level of subdirectories, or cascades to all
146 subdirectories of the directory.
153 NFSv4 ACLs provide a mechanism for hooking into a system's audit trail.
154 Currently, Solaris does not support this mechanism.
160 NFSv4 ACLs enable adminstrators to specify the order in which ACL entries are
161 checked. With POSIX-draft ACLs the file system reorders ACL entries into a well
162 defined, strict access, checking order.
166 POSIX-draft ACL semantics can be achieved with NFSv4 ACLs. However, only some
167 NFSv4 ACLs can be translated to equivalent POSIX-draft ACLs.
170 Permissions can be specified in three different \fBchmod\fR ACL formats:
171 verbose, compact, or positional. The verbose format uses words to indicate that
172 the permissions are separated with a forward slash (\fB/\fR) character. Compact
173 format uses the permission letters and positional format uses the permission
174 letters or the hypen (\fB-\fR) to identify no permissions.
177 The permissions for verbose mode and their abbreviated form in parentheses for
178 compact and positional mode are described as follows:
182 \fBread_data (\fBr\fR)\fR
185 Permission to read the data of the file
191 \fBlist_directory (\fBr\fR)\fR
194 Permission to list the contents of a directory.
200 \fBwrite_data (\fBw\fR)\fR
203 Permission to modify a file's data anywhere in the file's offset range. This
204 includes the ability to grow the file or write to any arbitrary offset.
210 \fBadd_file (\fBw\fR)\fR
213 Permission to add a new file to a directory.
219 \fBappend_data (\fBp\fR)\fR
222 The ability to modify the file's data, but only starting at EOF. Currently,
223 this permission is not supported.
229 \fBadd_subdirectory (\fBp\fR)\fR
232 Permission to create a subdirectory to a directory.
238 \fBread_xattr (\fBR\fR)\fR
241 The ability to read the extended attributes of a file or do a lookup in the
242 extended attributes directory.
248 \fBwrite_xattr (\fBW\fR)\fR
251 The ability to create extended attributes or write to the extended attributes
258 \fBexecute (\fBx\fR)\fR
261 Permission to execute a file.
267 \fBread_attributes (\fBa\fR)\fR
270 The ability to read basic attributes (non-ACLs) of a file. Basic attributes are
271 considered to be the stat level attributes. Allowing this access mask bit means
272 that the entity can execute \fBls\fR(1) and \fBstat\fR(2).
278 \fBwrite_attributes (\fBA\fR)\fR
281 Permission to change the times associated with a file or directory to an
288 \fBdelete (\fBd\fR)\fR
291 Permission to delete the file.
297 \fBdelete_child (\fBD\fR)\fR
300 Permission to delete a file within a directory.
306 \fBread_acl (\fBc\fR)\fR
309 Permission to read the ACL.
315 \fBwrite_acl (\fBC\fR)\fR
318 Permission to write the ACL or the ability to execute \fBchmod\fR(1) or
325 \fBwrite_owner (\fBo\fR)\fR
328 Permission to change the owner or the ability to execute \fBchown\fR(1) or
335 \fBsynchronize (\fBs\fR)\fR
338 Permission to access a file locally at the server with synchronous reads and
339 writes. Currently, this permission is not supported.
344 The following inheritance flags are supported by NFSv4 ACLs:
348 \fBfile_inherit (\fBf\fR)\fR
351 Inherit to all newly created files in a directory.
357 \fBdir_inherit (\fBd\fR)\fR
360 Inherit to all newly created directories in a directory.
366 \fBinherit_only (\fBi\fR)\fR
369 Placed on a directory, but does not apply to the directory itself, only to
370 newly created files and directories. This flag requires file_inherit
371 and/or dir_inherit to indicate what to inherit.
377 \fBno_propagate (\fBn\fR)\fR
380 Placed on directories and indicates that ACL entries should only be inherited
381 one level of the tree. This flag requires file_inherit and/or dir_inherit to
382 indicate what to inherit.
388 \fBsuccessful_access (\fBS\fR)\fR
391 Indicates whether an alarm or audit record should be initiated upon successful
392 accesses. Used with audit/alarm ACE types.
398 \fBfailed_access (\fBF\fR)\fR
401 Indicates whether an alarm or audit record should be initiated when access
402 fails. Used with audit/alarm ACE types.
408 \fBinherited (\fBI\fR)\fR
420 No permission granted.
425 An NFSv4 ACL is expressed using the following syntax:
429 \fIacl_entry\fR[,\fIacl_entry\fR]...
431 owner@:<perms>[:inheritance flags]:<allow|deny>
432 group@:<perms>[:inheritance flags]:<allow|deny>
433 everyone@:<perms>[:inheritance flags]:<allow|deny>
434 user:<username>:<perms>[:inheritance flags]:<allow|deny>
435 usersid:<sid string>:<perms>[:inheritance flags]:<allow|deny>
436 group:<groupname>:<perms>[:inheritance flags]:<allow|deny>
437 groupsid:<sid string>:<perms>[:inheritance flags]:<allow|deny>
438 sid:<sid string>:<perms>[:inheritance flags]:<allow|deny>
466 Permissions for a specific user
475 Permissions for a specific group
480 Permission and inheritance flags are separated by a \fB/\fR character.
483 ACL specification examples:
487 user:fred:read_data/write_data/read_attributes:file_inherit:allow
488 owner@:read_data:allow,group@:read_data:allow,user:tom:read_data:deny
495 Using the compact ACL format, permissions are specified by using 14 unique
496 letters to indicate permissions.
499 Using the positional ACL format, permissions are specified as positional
500 arguments similar to the \fBls -V\fR format. The hyphen (\fB-\fR), which
501 indicates that no permission is granted at that position, can be omitted and
502 only the required letters have to be specified.
505 The letters above are listed in the order they would be specified in positional
509 With these letters you can specify permissions in the following equivalent
514 user:fred:rw------R------:file_inherit:allow
521 Or you can remove the \fB-\fR and scrunch it together.
525 user:fred:rwR:file_inherit:allow
532 The inheritance flags can also be specified in a more compact manner, as
537 user:fred:rwR:f:allow
538 user:fred:rwR:f------:allow
543 .SS "Shell-level Solaris \fBAPI\fR"
545 The Solaris command interface supports the manipulation of ACLs. The following
546 Solaris utilities accommodate both ACL models:
553 The \fBchmod\fR utility has been enhanced to allow for the setting and deleting
554 of ACLs. This is achieved by extending the symbolic-mode argument to support
555 ACL manipulation. See \fBchmod\fR(1) for details.
564 When a file is compressed any ACL associated with the original file is
565 preserved with the compressed file.
574 By default, \fBcp\fR ignores ACLs, unless the \fB-p\fR option is specified.
575 When \fB-p\fR is specified the owner and group id, permission modes,
576 modification and access times, ACLs, and extended attributes if applicable are
586 ACLs are preserved when the \fB-P\fR option is specified.
595 Find locates files with ACLs when the \fB-acl\fR flag is specified.
604 By default \fBls\fR does not display ACL information. When the \fB-v\fR option
605 is specified, a file's ACL is displayed.
614 When a file is moved, all attributes are carried along with the renamed file.
615 When a file is moved across a file system boundary, the ACLs are replicated. If
616 the ACL information cannot be replicated, the move fails and the source file is
626 When a file is packed, any ACL associated with the original file is preserved
627 with the packed file.
636 \fBrcp\fR has been enhanced to support copying. A file's ACL is only preserved
637 when the remote host supports ACLs.
646 ACLs are preserved when the \fB-p\fR option is specified.
655 When a file with an ACL is unpacked, the unpacked file retains the ACL
659 .SS "Application-level \fBAPI\fR"
661 The primary interfaces required to access file system ACLs at the programmatic
662 level are the \fBacl_get()\fR and \fBacl_set()\fR functions. These functions
663 support both POSIX draft ACLs and NFSv4 ACLs.
664 .SS "Retrieving a file's \fBACL\fR"
667 int acl_get(const char *path, int flag, acl_t **aclp);
668 int facl_get(int fd, int flag, acl_t **aclp);
674 The \fBacl_get\fR(3SEC) and \fBfacl_get\fR(3SEC) functions retrieves an ACL on
675 a file whose name is given by path or referenced by the open file descriptor
676 fd. The flag argument specifies whether a trivial ACL should be retrieved. When
677 the flag argument equals \fBACL_NO_TRIVIAL\fR then only ACLs that are not
678 trivial are retrieved. The ACL is returned in the \fBaclp\fR argument.
679 .SS "Freeing \fBACL\fR structure"
682 void acl_free(acl_t *aclp)s;
688 The \fBacl_free()\fR function frees up memory allocated for the argument
690 .SS "Setting an \fBACL\fR on a file"
693 int acl_set(const char *path, acl_t *aclp);
694 int facl_set(int fd, acl_t *aclp);
700 The \fBacl_set\fR(3SEC) and \fBfacl_get\fR(3SEC) functions are used for setting
701 an ACL on a file whose name is given by path or referenced by the open file
702 descriptor \fBfd\fR. The \fBaclp\fR argument specifies the ACL to set. The
703 \fBacl_set\fR(3SEC) translates an POSIX-draft ACL into a NFSv4 ACL when the
704 target file systems supports NFSv4 ACLs. No translation is performed when
705 trying to set an NFSv4 ACL on a POSIX-draft ACL supported file system.
706 .SS "Determining an \fBACL\fR's trivialness"
709 int acl_trivial(const char *path);
715 The \fBacl_trivial()\fR function is used to determine whether a file has a
717 .SS "Removing all \fBACL\fRs from a file"
720 int acl_strip(const char *path, uid_t uid, gid_t gid, mode_t mode);
726 The \fBacl_strip()\fR function removes all ACLs from a file and replaces them
727 with a trivial ACL based off of the passed in argument mode. After replacing
728 the ACL the owner and group of the file are set to the values specified in the
729 uid and gid parameters.
730 .SS "Converting \fBACL\fRs to/from external representation"
733 int acl_fromtext(const char *path, acl_t **aclp);
734 char *acl_totext(acl_t *aclp, int flags);
740 The \fBacl_totext()\fR function converts an internal ACL representation pointed
741 to by aclp into an external representation. See \fBDESCRIPTION\fR for details
742 about external representation.
745 The \fBacl_fromtext()\fR functions converts and external representation into an
746 internal representation. See \fBDESCRIPTION\fR for details about external
750 The following examples demonstrate how the API can be used to perform basic
753 \fBExample 1 \fRRetrieving and Setting an ACL
756 Use the following to retrieve an ACL and set it on another file:
761 error = acl_get("file", ACL_NO_TRIVIAL, &aclp);
763 if (error == 0 && aclp != NULL) {
765 error = acl_set("file2", aclp);
774 \fBExample 2 \fRRetrieving and Setting Any ACLs
777 Use the following to retrieve any ACL, including trivial ACLs, and set it on
783 error = acl_get("file3", 0, &aclp);
786 error = acl_set("file4", aclp);
795 \fBExample 3 \fRDetermining if a File has a Trivial ACL
798 Use the following to determine if a file has a trivial ACL:
803 char *file = "file5";
804 istrivial = acl_trivial(file);
808 printf("file %s has a trivial ACL\en", file);
812 printf("file %s has a NON-trivial ACL\en", file);
819 \fBExample 4 \fRRemoving all ACLs from a File
822 Use the following to remove all ACLs from a file, and set a new mode, owner,
828 error = acl_strip("file", 10, 100, 0644);
835 \fBchgrp\fR(1), \fBchmod\fR(1), \fBchown\fR(1), \fBcp\fR(1), \fBcpio\fR(1),
836 \fBfind\fR(1), \fBls\fR(1), \fBmv\fR(1), \fBtar\fR(1), \fBsetfacl\fR(1),
837 \fBchmod\fR(2), \fBacl\fR(2), \fBstat\fR(2), \fBacl_get\fR(3SEC),
838 \fBaclsort\fR(3SEC), \fBacl_fromtext\fR(3SEC), \fBacl_free\fR(3SEC),
839 \fBacl_strip\fR(3SEC), \fBacl_trivial\fR(3SEC)