HPUX chmod[2]

chmod in anderen Kapiteln des hpux Handbuch:
chmod.3f
chmod.1
chmod(2) chmod(2)
NAME
chmod, fchmod - change access mode of file
SYNOPSIS
#include <sys/stat.h>
int chmod(const char *path, mode_t mode);
int fchmod(int fildes, mode_t mode);
DESCRIPTION
chmod() and fchmod() set the access permission portion of the file's
mode according to the bit pattern contained in mode. path points to a
path name naming a file. fildes is a file descriptor.
The following symbolic constants representing the access permission
bits are defined with the indicated values in <sys/stat.h> and are
used to construct the mode argument. The value of mode is the bit-
wise inclusive OR of the values for the desired permissions.
S_ISUID 04000 Set user ID on execution.
S_ISGID 02000 Set group ID on execution.
S_ENFMT 02000 Record locking enforced.
S_ISVTX 01000 Save text image after execution.
S_IRUSR 00400 Read by owner.
S_IWUSR 00200 Write by owner.
S_IXUSR 00100 Execute (search) by owner.
S_IRGRP 00040 Read by group.
S_IWGRP 00020 Write by group.
S_IXGRP 00010 Execute (search) by group.
S_IROTH 00004 Read by others (that is, anybody else).
S_IWOTH 00002 Write by others.
S_IXOTH 00001 Execute (search) by others.
To change the mode of a file, the effective user ID of the process
must match that of the owner of the file or a user with appropriate
privileges.
If the effective user ID of the process is not that of a user with
appropriate privileges and the file is a regular file, S_ISVTX (mode
bit 01000, save text image on execution) is cleared.
If the effective user ID of the process is not that of a user with
appropriate privileges, and the effective group ID of the process does
not match the group ID of the file and none of the group ID s in the
supplementary groups list match the group ID of the file, S_ISGIDR,
S_ENFMT (mode bit 02000, set group ID on execution and enforced file
locking mode) is cleared.
The set-group-ID on execution bit is also used to enforce file-locking
mode (see lockf(2) and fcntl(2)) on files that are not group
Hewlett-Packard Company - 1 - HP-UX Release 9.0: August 1992
chmod(2) chmod(2)
executable. This might affect future calls to open(), creat(),
read(), and write() on such files (see open(2), creat(2), read(2), and
write(2)).
If an executable file is prepared for sharing, S_ISVTX (mode bit
01000) prevents the system from abandoning the swap-space image of the
program-text portion of the file when its last user terminates. Then,
when the next user of the file executes it, the text need not be read
from the file system but can simply be swapped in, thus saving time.
If mode S_ISVTX (mode bit 01000) is set on a directory, an
unprivileged user cannot delete or rename others' files in that
directory.
Access Control Lists
All optional entries in a file's access control list are deleted when
chmod() is executed. (This behavior conforms to the IEEE Standard
POSIX 1003.1-1988.) To preserve optional entries in a file's access
control list, it is necessary to save and restore them using getacl()
and setacl() (see getacl(2) and setacl(2)).
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).
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
ERRORS
chmod() and fchmod() fail and the file mode is unchanged if one or
more of the following is true:
[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.
[ELOOP] Too many symbolic links are 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 does not exist.
Hewlett-Packard Company - 2 - HP-UX Release 9.0: August 1992
chmod(2) chmod(2)
[ENOENT] 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.
[EINVAL] Attempted to make a root directory into a
context-dependent file (see DEPENDENCIES).
WARNINGS
Access Control Lists
Access control list descriptions in this entry apply only to standard
HP-UX operating systems. If HP-UX BLS software has been installed,
access control lists are handled differently. Refer to HP-UX BLS
documentation for information about access control lists in the HP-UX
BLS environment.
DEPENDENCIES
HP Clustered Environment:
If the file is a directory, the access permission bit S_CDF
(04000) indicates a hidden directory (context-dependent file -
see cdf(4)). A root directory cannot be made into a context-
dependent file.
NFS fchmod() is not supported on remote files.
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), chown(2), creat(2), fcntl(2), read(2), lockf(2), mknod(2),
open(2), getacl(2), setacl(2), write(2), cdf(4), acl(5).
STANDARDS CONFORMANCE
chmod(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
fchmod(): AES
Hewlett-Packard Company - 3 - HP-UX Release 9.0: August 1992