HP-UX Reference (11i v2 04/09) - 3 Library Functions N-Z (vol 7)
s
strtoacl(3C) strtoacl(3C)
error (...);
}
if (setacl ("../myfile2", nentries, acl) < 0)
error (...);
The following code fragment calls strtoacl() with special values of fuid and fgid, then checks to see if
they show up in
acl[].
#include <acllib.h>
int perfile = 0; /* need to stat() and reparse per file? */
int entry;
if ((nentries = strtoacl (string, 0, NACLENTRIES, acl,
ACL_FILEOWNER, ACL_FILEGROUP)) < 0)
{
error (...);
}
for (entry = 0; entry < nentries; entry++)
{
if ((acl[entry].uid == ACL_FILEOWNER)
|| (acl[entry].gid == ACL_FILEGROUP))
{
perfile = 1;
break;
}
}
The following code fragment converts an ACL pattern from a string to an array of pattern entries.
#include <acllib.h>
int nentries;
struct acl_entry_patt acl [NACLENTRIES];
if ((nentries = strtoaclpatt (string, NACLENTRIES, acl)) < 0)
error (...);
The following code fragment inside a for loop checks an entry pattern (p*, onmask
, and offmask vari-
able names) against an entry in a file’s ACL (
a* variable names) using the file’s user and group IDs (
f*
variable names).
include <unistd.h>
if (((puid == ACL_FILEOWNER) && (fuid != auid))
|| ((puid != ACL_ANYUSER) && (puid != auid)))
{
continue;
}
if (((pgid == ACL_FILEGROUP) && (fgid != agid))
|| ((pgid != ACL_ANYGROUP) && (pgid != agid)))
{
continue;
}
if (((( amode) & MODEMASK & onmask ) != onmask)
|| (((˜ amode) & MODEMASK & offmask) != offmask))
{
continue;
}
DEPENDENCIES
strtoacl() and strtoaclpatt() are only supported on HFS file system on standalone HP-UX
operating system.
HP-UX 11i Version 2: September 2004 − 4 − Hewlett-Packard Company Section 3−−1029