HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)

g
getaccess(2) getaccess(2)
access() getaccess()
checks all ACL entries same
(HFS and JFS File Systems only)
uses real uid, real gid, and uses specified uid and groups list;
supplementary groups list macros available for typical values
checks specific mode value, returns all mode bits, each on or off
returns succeed or fail
checks path to file using caller’s effective IDs same
W_OK false if shared-text file same
currently being executed
W_OK false if file on same
read-only file system
X_OK not modified for file same
currently open for writing
R_OK and W_OK always true for superuser same
(except as above)
X_OK always true for superuser X_OK true for super-user if file is not a regular
file or execute is set in any
ACL entry
RETURN VALUE
Upon successful completion, getaccess() returns a non-negative value representing the access rights
of the specified user to the specified file. If an error occurs, a value of
-1 is returned and errno is set
to indicate the error.
ERRORS
getaccess() fails if any of the following conditions are encountered:
[EACCES] A component of the path prefix denies search permission to the caller.
[EFAULT] path or gidset points outside the allocated address space of the process. The reli-
able detection of this error is implementation dependent.
[EINVAL] ngroups is invalid; ngroups is either zero, an unrecognized negative value, or a
value larger than NGROUPS +1.
[EINVAL] gidset contains an invalid group ID value.
[EINVAL] The value of label or privs is not a null pointer.
[ELOOP] Too many symbolic links were encountered in translating the path name.
[ENAMETOOLONG]
The length of the specified path name exceeds PATH_MAX bytes, or the length of a
component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC
is in effect.
[ENOENT] The named file does not exist (for example, path is null or a component of path does
not exist).
[ENOTDIR] A component of the path prefix is not a directory.
[EOPNOTSUPP] getaccess() is not supported on some types of remote files.
EXAMPLES
The following call determines the caller’s effective access rights to file ‘‘test,’’ and succeeds if the user
has read access:
#include <unistd.h>
#include <sys/getaccess.h>
int mode;
mode = getaccess ("test", UID_EUID, NGROUPS_EGID_SUPP,
(int ) 0, (void ) 0, (void ) 0);
if ((mode >= 0) && (mode & R_OK)) ...
Here is one way to test access rights to file /tmp/hold for user
ID 23, group ID 109:
Section 282 Hewlett-Packard Company 2 HP-UX 11i Version 2: September 2004