United States-English |
|
|
HP-UX Reference > Ccpacl(3C)HP-UX 11i Version 3: February 2007 |
|
NAMEcpacl(), fcpacl() — copy the access control list (ACL) and mode bits from one file to another (HFS and JFS File Systems only) SYNOPSIS#include <acllib.h> int cpacl( const char *fromfile, const char *tofile, mode_t frommode, uid_t fromuid, gid_t fromgid, uid_t touid, gid_t togid ); int fcpacl( int fromfd, int tofd, mode_t frommode, uid_t fromuid, gid_t fromgid, uid_t touid, gid_t togid ); DESCRIPTIONBoth cpacl() (HFS and JFS file systems) and fcpacl() (HFS file systems only) copy the access control list and mode bits (that is, file access permission bits and miscellaneous mode bits; see chmod(2)) from one file to another, and transfer ownership much like chown(2). cpacl() can only copy HFS ACLs to other HFS files and JFS ACLS to other JFS files; it does not covert HFS ACLs to JFS ACLs or vice versa. cpacl() and fcpacl() take the following parameters:
When both files are local, the cpacl() routines copy the access control list and call chownacl() (HFS only; see chownacl(3C)) to transfer ownership from the fromfile to the tofile, if necessary. cpacl() (fcpacl()) handles remote copying (via NFS) and copying from HFS to JFS or vice versa after recognizing failures of acl(), getacl() (fgetacl()) or setacl() (fsetacl()) (see acl(2) and setacl(2)). When copying the mode from fromfile (fromfd) to tofile (tofd), cpacl() copies the entire frommode (that is, the file miscellaneous mode bits and the file access permission bits) to tofile (tofd) using chmod() (fchmod()). Some of the miscellaneous mode bits can be turned off; see chmod(2). cpacl() (fcpacl()) can copy an access control list from fromfile (fromfd) to tofile (tofd) without transferring ownership, but ensuring error checking and handling of remote files. This is done by passing fromuid equal to touid and fromgid equal to togid (that is, four zeros). For remote files, fromuid, touid, fromgid, and togid are ignored. RETURN VALUEIf successful, cpacl() and fcpacl() return zero. If an error occurs, they set errno to indicate the cause of failure and return a negative value, as follows:
EXAMPLESThe following code fragment gets stat information on oldfile and copies its file miscellaneous bits and access control list to newfile owned by the caller. If either file is remote, only the st_mode on oldfile is copied. #include <sys/types.h> #include <sys/stat.h> struct stat statbuf; if (stat ("oldfile", & statbuf) < 0) error (...); if (cpacl ("oldfile", newfile , statbuf.st_mode, statbuf.st_uid, statbuf.st_gid, geteuid(), getegid()) < 0) { error (...); } DEPENDENCIEScpacl() and fcpacl() are only supported on HFS and JFS file systems on standard HP-UX operating systems. SEE ALSOacl(2), chown(2), getacl(2), getegid(2), geteuid(2), getuid(2), setacl(2), stat(2), acltostr(3C), chownacl(3C), strtoacl(3C), acl(5), aclv(5), thread_safety(5). |
Printable version | ||
|