HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)
c
chmod(2) chmod(2)
Access Control Lists - JFS File Systems Only
The effective permissions granted by optional entries in a file’s access control list may be changed when
chmod() is executed. In particular, using chmod() to remove read, write and execute permissions
from a file’s owner, owning group, and all others works as expected, because
chmod() affects the
class entry in the ACL, limiting any access that can be granted to additional users or groups via
optional ACL entries. The effect can be verified by doing a getacl (1) on the file after the
chmod(), and
noting that all optional (non-default) ACL entries with nonzero permissions also have the comment
#
effective:---
.
To set the permission bits of access control list entries, use
setacl() instead of chmod().
For more information on access control list entries, see acl (5) and aclv (5).
RETURN VALUE
chmod() returns the following values:
0 Successful completion.
-1 Failure.
errno is set to indicate the error.
ERRORS
If
chmod() fails, the file mode is unchanged.
errno is set to one of the following values:
[EACCES] Search permission is denied on a component of the path prefix.
[EFAULT] path points outside the allocated address space of the process. The reliable
detection of this error is implementation dependent.
[EINVAL] path or fildes descriptor does not refer to an appropriate file.
[ELOOP] Too many symbolic links were encountered in translating path .
[ENAMETOOLONG]
A component of path exceeds
NAME_MAX bytes while _POSIX_NO_TRUNC
is
in effect or path exceeds
PATH_MAX bytes.
[ENOENT] A component of path or the file named by path does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[EPERM] The effective user ID does not match that of the owner of the file, and the
effective user ID is not that of a user with appropriate privileges.
[EROFS] The named file resides on a read-only file system.
If
fchmod() fails, the file mode is unchanged. errno is set to one of the following values:
[EBADF] fildes is not a valid file descriptor.
[EPERM] The effective user ID does not match that of the owner of the file, and the
effective user ID is not that of a user with appropriate privileges.
[EINVAL] path or fildes descriptor does not refer to an appropriate file.
[EROFS] The named file resides on a read-only file system.
AUTHOR
chmod() was developed by AT&T, the University of California, Berkeley, and HP.
fchmod() was developed by the University of California, Berkeley.
SEE ALSO
chmod(1), getacl(1), chown(2), creat(2), fcntl(2), getacl(2), read(2), lockf(2), mknod(2), open(2), setacl(2),
write(2), acl(5), aclv(5).
STANDARDS CONFORMANCE
chmod(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
fchmod(): AES, SVID3
HP-UX 11i Version 2: September 2004 − 2 − Hewlett-Packard Company Section 2−−37