|
The chown() function sets the owner ID and group ID of the file specified by path or referenced by the open file descriptor fildes to owner and group respectively. If owner or group is specified as -1, chown() does not change the corresponding ID of the file.
The lchown() function sets the owner ID and group ID of the named file in the same manner as chown(), unless the named file is a symbolic link. In this case, lchown() changes
the ownership of the symbolic link file itself, while chown() changes the ownership of the file or directory to which the symbolic link refers.
The fchownat() function sets the owner ID and group ID of the named file in the same manner as chown(). If, however, the path argument is relative, the path is resolved relative to the fildes argument rather than
the current working directory. If the fildes argument has the special value FDCWD, the path path resolution reverts back to current working directory relative. If the flag argument is set to SYMLNK, the function behaves
like lchown() with respect to symbolic links. If the path argument is absolute, the fildes argument is ignored. If the path argument is a null pointer, the function behaves like fchown().
If chown(), lchown(), fchown(), or fchownat() is invoked by a process other than super-user, the set-user-ID and set-group-ID bits of the file mode, S_ISUID and S_ISGID respectively, are cleared (see chmod(2)).
The operating system provides a configuration option, {_POSIX_CHOWN_RESTRICTED}, to restrict ownership changes for the chown(), lchown(), and fchown() functions. When {_POSIX_CHOWN_RESTRICTED} is not
in effect, either the effective user ID of the process must match the owner of the file or the process must be the super-user to change the ownership of a file. When {_POSIX_CHOWN_RESTRICTED} is in effect (the default behavior), the chown(), lchown(), and fchown() functions, for users other than super-user, prevent the owner of the file from changing the owner ID of the file and restrict the change of the group of the file to the list of supplementary group
IDs. To set this configuration option, include the following line in /etc/system:
set rstchown = 1
To disable this option, include the following line in /etc/system:
set rstchown = 0
See system(4) and fpathconf(2).
Upon successful completion, chown(), fchown() and lchown() mark for update the st_ctime field of the file.
|