| CHMOD(2V) | 21 January 1990 | CHMOD(2V) |
| NAME |
| chmod, fchmod - change mode of file |
| SYNOPSIS |
|
int chmod(path, mode) char *path; mode_t mode; int fchmod(fd, mode) int fd, mode; |
| DESCRIPTION |
|
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. |
| RETURN |
|
chmod() returns:
|
| ERRORS |
|
chmod() will fail and the file mode will be unchanged if:
fchmod() will fail if:
|
| SYSTEM |
|
In addition to the above, the following may also occur:
|
| SEE ALSO |
| BUGS |
|
S_ISVTX, the (sticky bit), is a misnomer, and is overloaded to mean different things for different file types. |
| CHMOD(2V) | 21 January 1990 | CHMOD(2V) |