'\" te .\" Copyright (c) 20068 Sun Microsystems, Inc. All Rights Reserved. .\" 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. .\" 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. .\" 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] .TH acl_totext 3SEC "16 Jun 2008" "SunOS 5.11" "File Access Control Library Functions" .SH NAME acl_totext, acl_fromtext \- convert internal representation to or from external representation .SH SYNOPSIS .LP .nf cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lsec\fR [ \fIlibrary\fR\&.\|.\|. ] #include \fBchar *\fR\fBacl_totext\fR(\fBacl_t *\fR\fIaclp\fR, \fBint\fR \fIflags\fR); .fi .LP .nf \fBint\fR \fBacl_fromtext\fR(\fBchar *\fR\fIacltextp\fR, \fBacl_t **\fR\fIaclp\fR); .fi .SH DESCRIPTION .sp .LP The \fBacl_totext()\fR function converts an internal ACL representation pointed to by \fIaclp\fR into an external ACL representation. The memory for the external text string is obtained using \fBmalloc\fR(3C). The caller is responsible for freeing the memory upon completion. .sp .LP The format of the external ACL is controlled by the \fIflags\fR argument. Values for \fIflags\fR are constructed by a bitwise-inclusive-OR of \fIflags\fR from the following list, defined in <\fBsys/acl.h\fR>. .sp .ne 2 .mk .na \fB\fBACL_COMPACT_FMT\fR\fR .ad .RS 19n .rt For NFSv4 ACLs, the ACL entries will be formatted using the compact ACL format detailed in \fBls\fR(1) for the \fB-V\fR option. .RE .sp .ne 2 .mk .na \fB\fBACL_APPEND_ID\fR\fR .ad .RS 19n .rt Append the \fBuid\fR or \fBgid\fR for additional user or group entries. This flag is used to construt ACL entries in a manner that is suitable for archive utilities such as \fBtar\fR(1). When the ACL is translated from the external format to internal representation using \fBacl_fromtext()\fR, the appended ID will be used to populate the \fBuid\fR or \fBgid\fR field of the ACL entry when the user or group name does not exist on the host system. The appended id will be ignored when the user or group name does exist on the system. .RE .sp .ne 2 .mk .na \fB\fBACL_SID_FMT\fR\fR .ad .RS 19n .rt For NFSv4 ACLs, the ACL entries for user or group entries will use the \fBusersid\fR or \fBgroupsid\fR format when the "id" field in the ACL entry is an ephemeral \fBuid\fR or \fBgid\fR. The raw \fBsid\fR format will only be used when the "id" cannot be resolved to a windows name. .RE .sp .LP The \fBacl_fromtext()\fR function converts an external ACL representation pointed to by \fIacltextp\fR into an internal ACL representation. The memory for the list of ACL entries is obtained using \fBmalloc\fR(3C). The caller is responsible for freeing the memory upon completion. Depending on type of ACLs a file system supports, one of two external external representations are possible. For POSIX draft file systems such as ufs, the external representation is described in \fBacltotext\fR(3SEC). The external ACL representation For NFSv4-style ACLs is detailed as follows. .sp .LP Each \fBacl_entry\fR contains one ACL entry. The external representation of an ACL entry contains three, four or five colon separated fields. The first field contains the ACL entry type. The entry type keywords are defined as: .sp .ne 2 .mk .na \fB\fBeveryone@\fR\fR .ad .RS 13n .rt This ACL entry specifies the access granted to any user or group that does not match any previous ACL entry. .RE .sp .ne 2 .mk .na \fB\fBgroup\fR\fR .ad .RS 13n .rt This ACL entry with a GID specifies the access granted to a additional group of the object. .RE .sp .ne 2 .mk .na \fB\fBgroup@\fR\fR .ad .RS 13n .rt This ACL entry with no GID specified in the ACL entry field specifies the access granted to the owning group of the object. .RE .sp .ne 2 .mk .na \fB\fBgroupsid\fR\fR .ad .RS 13n .rt This ACL entry with a SID or Windows name specifies the access granted to a Windows group. This type of entry is for a CIFS server created file. .RE .sp .ne 2 .mk .na \fB\fBowner@\fR\fR .ad .RS 13n .rt This ACL entry with no UID specified in the ACL entry field specifies the access granted to the owner of the object. .RE .sp .ne 2 .mk .na \fB\fBsid\fR\fR .ad .RS 13n .rt This ACL entry with a SID or Windows name when the entry could be either a group or a user. .RE .sp .ne 2 .mk .na \fB\fBuser\fR\fR .ad .RS 13n .rt This ACL entry with a UID specifies the access granted to a additional user of the object. .RE .sp .ne 2 .mk .na \fB\fBusersid\fR\fR .ad .RS 13n .rt This ACL entry with a SID or Windows name specifies the access granted to a Windows user. This type of entry is for a CIFS server created file. .RE .sp .LP The second field contains the ACL entry ID, and is used only for user or group ACL entries. This field is not used for \fBowner@\fR, \fBgroup@\fR, or \fBeveryone@\fR entries. .sp .ne 2 .mk .na \fB\fBuid\fR\fR .ad .RS 7n .rt This field contains a user-name or user-ID. If the user-name cannot be resolved to a UID, then the entry is assumed to be a numeric UID. .RE .sp .ne 2 .mk .na \fB\fBgid\fR\fR .ad .RS 7n .rt This field contains a group-name or group-ID. If the group-name can't be resolved to a GID, then the entry is assumed to be a numeric GID. .RE .sp .LP The third field contains the discretionary access permissions. The format of the permissions depends on whether \fBACL_COMPACT_FMT\fR is specified. When the \fIflags\fR field does not request \fBACL_COMPACT_FMT\fR, the following format is used with a forward slash (/) separating the permissions. .sp .ne 2 .mk .na \fB\fBadd_file\fR\fR .ad .RS 20n .rt Add a file to a directory. .RE .sp .ne 2 .mk .na \fB\fBadd_subdirectory\fR\fR .ad .RS 20n .rt Add a subdirectory. .RE .sp .ne 2 .mk .na \fB\fBappend\fR\fR .ad .RS 20n .rt Append data. .RE .sp .ne 2 .mk .na \fB\fBdelete\fR\fR .ad .RS 20n .rt Delete. .RE .sp .ne 2 .mk .na \fB\fBdelete_child\fR\fR .ad .RS 20n .rt Delete child. .RE .sp .ne 2 .mk .na \fB\fBexecute\fR\fR .ad .RS 20n .rt Execute permission. .RE .sp .ne 2 .mk .na \fB\fBlist_directory\fR\fR .ad .RS 20n .rt List a directory. .RE .sp .ne 2 .mk .na \fB\fBread_acl\fR\fR .ad .RS 20n .rt Read ACL. .RE .sp .ne 2 .mk .na \fB\fBread_data\fR\fR .ad .RS 20n .rt Read permission. .RE .sp .ne 2 .mk .na \fB\fBread_attributes\fR\fR .ad .RS 20n .rt Read attributes. .RE .sp .ne 2 .mk .na \fB\fBread_xattr\fR\fR .ad .RS 20n .rt Read named attributes. .RE .sp .ne 2 .mk .na \fB\fBsynchronize\fR\fR .ad .RS 20n .rt Synchronize. .RE .sp .ne 2 .mk .na \fB\fBwrite_acl\fR\fR .ad .RS 20n .rt Write ACL. .RE .sp .ne 2 .mk .na \fB\fBwrite_attributes\fR\fR .ad .RS 20n .rt Write attributes. .RE .sp .ne 2 .mk .na \fB\fBwrite_data\fR\fR .ad .RS 20n .rt Write permission. .RE .sp .ne 2 .mk .na \fB\fBwrite_owner\fR\fR .ad .RS 20n .rt Write owner. .RE .sp .ne 2 .mk .na \fB\fBwrite_xattr\fR\fR .ad .RS 20n .rt Write named attributes. .RE .sp .LP This format allows permissions to be specified as, for example: \fBread_data\fR/\fBread_xattr\fR/\fBread_attributes\fR. .sp .LP When \fBACL_COMPACT_FMT\fR is specified, the permissions consist of 14 unique letters. A hyphen (-) character is used to indicate that the permission at that position is not specified. .sp .ne 2 .mk .na \fB\fBa\fR\fR .ad .RS 5n .rt read attributes .RE .sp .ne 2 .mk .na \fB\fBA\fR\fR .ad .RS 5n .rt write attributes .RE .sp .ne 2 .mk .na \fB\fBc\fR\fR .ad .RS 5n .rt read ACL .RE .sp .ne 2 .mk .na \fB\fBC\fR\fR .ad .RS 5n .rt write ACL .RE .sp .ne 2 .mk .na \fB\fBd\fR\fR .ad .RS 5n .rt delete .RE .sp .ne 2 .mk .na \fB\fBD\fR\fR .ad .RS 5n .rt delete child .RE .sp .ne 2 .mk .na \fB\fBo\fR\fR .ad .RS 5n .rt write owner .RE .sp .ne 2 .mk .na \fB\fBp\fR\fR .ad .RS 5n .rt append .RE .sp .ne 2 .mk .na \fB\fBr\fR\fR .ad .RS 5n .rt read_data .RE .sp .ne 2 .mk .na \fB\fBR\fR\fR .ad .RS 5n .rt read named attributes .RE .sp .ne 2 .mk .na \fB\fBs\fR\fR .ad .RS 5n .rt synchronize .RE .sp .ne 2 .mk .na \fB\fBw\fR\fR .ad .RS 5n .rt write_data .RE .sp .ne 2 .mk .na \fB\fBW\fR\fR .ad .RS 5n .rt write named attributes .RE .sp .ne 2 .mk .na \fB\fBx\fR\fR .ad .RS 5n .rt execute .RE .sp .LP This format allows compact permissions to be represented as, for example: \fBrw--d-a-------\fR .sp .LP The fourth field is optional when \fBACL_COMPACT_FMT\fR is not specified, in which case the field will be present only when the ACL entry has inheritance flags set. The following is the list of inheritance flags separated by a slash (/) character. .sp .ne 2 .mk .na \fB\fBdir_inherit\fR\fR .ad .RS 16n .rt \fBACE_DIRECTORY_INHERIT_ACE\fR .RE .sp .ne 2 .mk .na \fB\fBfile_inherit\fR\fR .ad .RS 16n .rt \fBACE_FILE_INHERIT_ACE\fR .RE .sp .ne 2 .mk .na \fB\fBinherit_only\fR\fR .ad .RS 16n .rt \fBACE_INHERIT_ONLY_ACE\fR .RE .sp .ne 2 .mk .na \fB\fBno_propagate\fR\fR .ad .RS 16n .rt \fBACE_NO_PROPAGATE_INHERIT_ACE\fR .RE .sp .LP When \fBACL_COMPACT_FMT\fR is specified the inheritance will always be present and is represented as positional arguments. A hyphen (-) character is used to indicate that the inheritance flag at that position is not specified. .sp .ne 2 .mk .na \fB\fBd\fR\fR .ad .RS 5n .rt \fBdir_inherit\fR .RE .sp .ne 2 .mk .na \fB\fBf\fR\fR .ad .RS 5n .rt \fBfile_inherit\fR .RE .sp .ne 2 .mk .na \fB\fBF\fR\fR .ad .RS 5n .rt failed access (not currently supported) .RE .sp .ne 2 .mk .na \fB\fBi\fR\fR .ad .RS 5n .rt \fBinherit_only\fR .RE .sp .ne 2 .mk .na \fB\fBn\fR\fR .ad .RS 5n .rt \fBno_propagate\fR .RE .sp .ne 2 .mk .na \fB\fBS\fR\fR .ad .RS 5n .rt successful access (not currently supported) .RE .sp .LP The fifth field contains the type of the ACE (\fBallow\fR or \fBdeny\fR): .sp .ne 2 .mk .na \fB\fBallow\fR\fR .ad .RS 9n .rt The mask specified in field three should be allowed. .RE .sp .ne 2 .mk .na \fB\fBdeny\fR\fR .ad .RS 9n .rt The mask specified in field three should be denied. .RE .SH RETURN VALUES .sp .LP Upon successful completion, the \fBacl_totext()\fR function returns a pointer to a text string. Otherwise, it returns \fINULL\fR. .sp .LP Upon successful completion, the \fBacl_fromtext()\fR function returns 0. Otherwise, the return value is set to one of the following: .sp .ne 2 .mk .na \fB\fBEACL_FIELD_NOT_BLANK\fR\fR .ad .RS 28n .rt A field that should be blank is not blank. .RE .sp .ne 2 .mk .na \fB\fBEACL_FLAGS_ERROR\fR\fR .ad .RS 28n .rt An invalid ACL flag was specified. .RE .sp .ne 2 .mk .na \fB\fBEACL_INHERIT_ERROR\fR\fR .ad .RS 28n .rt An invalid inheritance field was specified. .RE .sp .ne 2 .mk .na \fB\fBEACL_INVALID_ACCESS_TYPE\fR\fR .ad .RS 28n .rt An invalid access type was specified. .RE .sp .ne 2 .mk .na \fB\fBEACL_INVALID_STR\fR\fR .ad .RS 28n .rt The string is \fINULL\fR. .RE .sp .ne 2 .mk .na \fB\fBEACL_INVALID_USER_GROUP\fR\fR .ad .RS 28n .rt The required user or group name not found. .RE .sp .ne 2 .mk .na \fB\fBEACL_MISSING_FIELDS\fR\fR .ad .RS 28n .rt The ACL needs more fields to be specified. .RE .sp .ne 2 .mk .na \fB\fBEACL_PERM_MASK_ERROR\fR\fR .ad .RS 28n .rt The permission mask is invalid. .RE .sp .ne 2 .mk .na \fB\fBEACL_UNKNOWN_DATA\fR\fR .ad .RS 28n .rt Unknown data was found in the ACL. .RE .SH EXAMPLES .LP \fBExample 1 \fRExamples of permissions when \fBACL_COMPACT_FMT\fR is not specified. .sp .in +2 .nf user:joe:read_data/write_data:file_inherit/dir_inherit:allow .fi .in -2 .sp .sp .in +2 .nf owner@:read_acl:allow,user:tom:read_data:file_inherit/inherit_only:deny .fi .in -2 .sp .LP \fBExample 2 \fRExamples of permissions when \fBACL_COMPACT_FMT\fR is specified. .sp .in +2 .nf user:joe:rw------------:fd----:allow .fi .in -2 .sp .sp .in +2 .nf owner@:----------c---:------allow,user:tom:r-------------:f-i---:deny .fi .in -2 .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelSafe .TE .SH SEE ALSO .sp .LP \fBls\fR(1), \fBtar\fR(1), \fBacl\fR(2), \fBmalloc\fR(3C), \fBaclfromtext\fR(3SEC), \fBacl\fR(5), \fBattributes\fR(5)