#include <sys/stat.h>
int chmod(path, mode) char *path; mode_t mode;
int fchmod(fd, mode) int fd, mode;
chmod() sets the mode of the file referred to by path or the descriptor fd according to mode. mode is the inclusive OR of the file mode bits (see stat.2v for a description of these bits).
The effective user ID of the process must match the owner of the file or be super-user to change the mode of a file.
If the effective user ID of the process is not super-user and the process attempts to set the set group ID bit on a file owned by a group which is not in its supplementary group IDs, the S_ISGID bit (set group ID on execution) is cleared.
If the S_ISVTX (sticky) bit is set on a directory, an unprivileged user may not delete or rename files of other users in that directory.
If a user other than the super-user writes to a file, the set user ID and set group ID bits are turned off. This makes the system somewhat more secure by protecting set-user-ID (set-group-ID) files from remaining set-user-ID (set-group-ID) if they are modified, at the expense of a degree of compatibility.
chmod() returns:
chmod() will fail and the file mode will be unchanged if:
A pathname component is longer than {NAME_MAX} while {_POSIX_NO_TRUNC} is in effect (see pathconf.2v
fchmod() will fail if:
In addition to the above, the following may also occur:
S_ISVTX, the ``sticky bit'', is a misnomer, and is overloaded to mean different things for different file types.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97