up | Inhaltsverzeichniss | Kommentar

Manual page for CHMOD(2V)

chmod, fchmod - change mode of file

SYNOPSIS

#include <sys/stat.h>

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 VALUES

chmod() returns:

0
on success.
-1
on failure and sets errno to indicate the error.

ERRORS

chmod() will fail and the file mode will be unchanged if:

EACCES
Search permission is denied for a component of the path prefix of path.
EFAULT
path points outside the process's allocated address space.
EINVAL
fd refers to a socket, not to a file.
EIO
An I/O error occurred while reading from or writing to the file system.
ELOOP
Too many symbolic links were encountered in translating path.
ENAMETOOLONG
The length of the path argument exceeds {PATH_MAX}.

A pathname component is longer than {NAME_MAX} while {_POSIX_NO_TRUNC} is in effect (see pathconf.2v

ENOENT
The file referred to by path does not exist.
ENOTDIR
A component of the path prefix of path is not a directory.
EPERM
The effective user ID does not match the owner of the file and the effective user ID is not the super-user.
EROFS
The file referred to by path resides on a read-only file system.

fchmod() will fail if:

EBADF
The descriptor is not valid.
EIO
An I/O error occurred while reading from or writing to the file system.
EPERM
The effective user ID does not match the owner of the file and the effective user ID is not the super-user.
EROFS
The file referred to by fd resides on a read-only file system.

SYSTEM V ERRORS

In addition to the above, the following may also occur:

ENOENT
path points to a null pathname.

SEE ALSO

chown.2v open.2v stat.2v sticky.8

BUGS

S_ISVTX, the ``sticky bit'', is a misnomer, and is overloaded to mean different things for different file types.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97