|CHOWN(2)||System Calls Manual||CHOWN(2)|
change owner and group of a file or link
char *path, uid_t
char *path, uid_t
fd, uid_t owner,
fd, const char
*path, uid_t owner,
The owner ID and group ID of the file (or link) named by path or referenced by fd is changed as specified by the arguments owner and group. The owner of a file may change the group to a group of which he or she is a member, but the change owner capability is restricted to the superuser.
clears the set-user-ID and set-group-ID bits on the file to prevent
accidental or mischievous creation of set-user-ID and set-group-ID programs.
This behaviour can be overridden by setting the
fs.posix.setuid to zero.
operates similarly to how
chown() operated on older
systems, and does not follow symbolic links. It allows the owner and group
of a symbolic link to be set.
function is equivalent to either the
lchown() function depending on the value of
flag (see below), except that where
path specifies a relative path, the file whose
ownership is changed is determined relative to the directory associated with
file descriptor fd instead of the current working
is passed the special value
AT_FDCWD (defined in
<fcntl.h>) in the
fd parameter, the current working directory is used
and the behavior is identical to a call to
lchown(), depending on whether or not the
AT_SYMLINK_NOFOLLOW bit is set in
The flag argument is the bitwise OR of zero or more of the following values:
One of the owner or group IDs may be left unchanged by specifying it as -1.
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
fchownat() will fail and the file or link will
be unchanged if:
NAME_MAXcharacters, or an entire pathname (including the terminating NUL) exceeded
fchownat() will fail if:
AT_FDCWDnor a valid file descriptor.
fchown() will fail if:
lchown() functions are expected to conform to
IEEE Std 1003.1-2008 (“POSIX.1”).
chown() system call first appeared in
Version 1 AT&T UNIX. Since
Version 6 AT&T UNIX it supports changing
the group as well, and in Version 7 AT&T
UNIX group was made a separate argument.
fchown() system call first appeared in
fchown() system calls were changed to follow
symbolic links in 4.4BSD; therefore, and for
compatibility with AT&T System V
Release 4 UNIX, the
call was added to OpenBSD 2.1.
fchownat() system call has been
available since OpenBSD 5.0.
|September 10, 2015||OpenBSD-6.0|