getaccess.2 (2010 09)
g
getaccess(2) getaccess(2)
[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:
int gid = 109;
int mode;
mode = getaccess ("/tmp/hold", 23, 1, & gid,
(void *) 0, (void *) 0);
Should the need arise, the following code builds a gidset that includes the process’s effective group ID:
#include <sys/types.h>
#include <unistd.h>
gid_t *gidset;
int ngroups;
int ngroups_max;
ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
gidset = (gid_t *)malloc(ngroups_max * sizeof(gid_t));
gidset[0] = getegid();
ngroups = 1 + getgroups (ngroups_max - 1, &gidset[1]);
AUTHOR
getaccess() was developed by HP.
SEE ALSO
access(2), acl(2), chmod(2), getacl(2), setacl(2), stat(2), acl(5), aclv(5), privileges(5), unistd(5).
HP-UX 11i Version 3: September 2010 − 3 − Hewlett-Packard Company 3