acl_get_fd() — Get ACL by file descriptor

Standards

Standards / Extensions C or C++ Dependencies

z/OS UNIX

both z/OS V1R3

Format

#define _OPEN_SYS	1
#include <sys/acl.h>

int   acl_get_fd (int fd, acl_type_t type_d, lacl_t acl_d, int *num);

General description

Use access control lists (ACLs) in conjunction with permission bits to control access to files and directories. Currently, ACLs are supported by the HFS, TFS, and zFS file systems. You must know whether your security product supports ACLs and what rules are used when determining file access. See z/OS UNIX System Services Planning for details.

The acl_get_fd() function retrieves an ACL based on type_d argument for an object associated with the file descriptor fd. The ACL is retrieved into the supplied working storage pointed to by acl_d. For the type_d = ACL_ACCESS, acl_get_fd() will get both the base ACL entries and extended ACL entries. (The base ACL entries only apply to the ACL_ACCESS ACL.)

The working storage should be allocated using the acl_init() function. If the buffer is not big enough, the acl_get_fd() will fail with errno=E2BIG and num will be filled with the number of ACLs in the ACL pointed to by fd. The user can get a bigger acl_t structure buffer using the num value and reissue the acl_get_fd().

If the object associated with the file descriptor does not have the specified ACL, then an ACL containing zero ACL entries will be returned. If the argument fd refers to an object other than a directory and the value of type_d is a directory/file default, then the function will fail.

The first call to acl_get_entry() following the call to acl_get_fd() obtains the first extended ACL entry in the ACL as ordered by the system.

The result of acl_get_fd() can be used to set that same ACL using acl_set_fd() or acl_set_file() using OpType = ACL_ADD.

Returned value

Upon successful completion, the function returns zero.

If any of the following conditions occur, the acl_get_fd() function returns a value of NULL and sets errno to the corresponding value:

Error Code
Description
EACCES
The required access to the file referred to by fd is denied.
EBADF
The fd argument is not a valid file descriptor.
EINVAL
Argument type_d is not a valid ACL type. Argument acl_d does not point to an ACL structure.
ENOTDIR
The type specified was directory/file default but the argument fd does not refer to a directory.
E2BIG
The supplied buffer is too small for all extended ACL entries. num value has the number of ACL entries that need to fit in the buffer.

Related information