Open System Services System Calls Reference Manual (G06.28+, H06.05+)

acl(5) OSS System Calls Reference Manual
granted by any additional user:uid: or group:gid: entries. If the chmod() func-
tion is used on an object that does not have optional ACL entries, both the class
ACL entry and the owning group ACL entry permission bits are changed to the
new group permissions value.
chown() If you use the chown() function to change the owner or owning group of a le to
a user ID or group ID that has an existing user:uid: or group:gid: entry in the
ACL for the le, those existing entries are not removed from the ACL. However,
those existing entries no longer have any effect, because the user:: or group::
entries take precedence.
HEADERS
sys/acl.h
The sys/acl.h header le denes the following constants to govern the number of entries per
ACL:
NACLENTRIES
The maximum number of entries per ACL, including base entries
NACLBASE The number of base entries
For compatibility with HP-UX, the variable name NACLVENTRIES is provided as an alias for
NACLENTRIES.
The ACL structure struct acl is also dened and includes these elds:
int a_type; /* type of entry */
uid_t a_id; /* group ID */
unsigned short a_perm; /* see <unistd.h> */
The sys/acl.h header denes the set of valid values for the a_type eld in addition to the valid
values for the cmd parameter of the acl() function.
EXAMPLE PROGRAM
This program provides simple examples of acl(2) and aclsort(3) usage.
/* This program provides simple examples of acl(2) and aclsort(3) usage.
* It adds a GROUP ACL entry (with read permissions) to the ACL of the
* file. The file pathname and group ID number are passed as command
* arguments.
* To run:
* addACLgroup <pathname> <group ID number>
* This program performs the following steps:
* 1. Acquires the count of ACL entries in the ACL on the file
* using acl(ACL_CNT).
* 2. Allocates memory for the ACL buffer using malloc().
* 3. Acquires the existing ACL on the file using acl(ACL_GET).
* 4. Adds a new GROUP ACL entry to the end of the ACL buffer.
* 5. Calls aclsort() to sort the ACL entries in the ACL buffer
* into the proper order.
* 6. Sets the new ACL on the file using acl(ACL_SET).
* If you run this program twice on the same file, it will report
* an error in aclsort() as you are trying to add a second group ACL entry
* for the same group id. aclsort() points to the ACL entry in error.
*/
#include <stdlib.h>
#include <sys/types.h>
1210 Hewlett-Packard Company 527186-007