| manpages.info - online man pages | ![]() |
|||
|
chmod (2) Table of Contents
Namechmod, fchmod - change mode of file
Synopsis
#include <sys/types.h>
int
int
Description
The function chmod() sets the file permission bits of the file specified
by the pathname path to mode. Fchmod() sets the permission bits of the
specified file descriptor fd. Chmod() verifies that the process owner
(user) either owns the file specified by path (or fd), or is the superuser.
A mode is created from or'd permission bit masks defined in
<sys/stat.h>:
The ISVTX (the sticky bit) indicates to the system which executable files are shareable (the default) and the system maintains the program text of the files in the swap area. The sticky bit may only be set by the super user on shareable executable files.
If mode ISVTX (the `sticky bit') is set on a directory, an unprivileged user may not delete or rename files of other users in that directory. The sticky bit may be set by any user on a directory which the user owns or has appropriate permissions. For more details of the properties of the sticky bit, see sticky(8) .
Writing or changing the owner of a file turns off the set-user-id and set-group-id bits unless the user is the super-user. 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 ValuesUpon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
ErrorsChmod() will fail and the file mode will be unchanged if:
Fchmod() will fail if:
See Alsochmod(1) , open(2) , chown(2) , stat(2) , sticky(8)
StandardsThe chmod() function is expected to conform to IEEE Std 1003.1-1988 (``POSIX.1'').
HistoryThe fchmod() function call appeared in 4.2BSD.
|