|
Packit |
7cfc04 |
'\" et
|
|
Packit |
7cfc04 |
.TH LCHOWN "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH PROLOG
|
|
Packit |
7cfc04 |
This manual page is part of the POSIX Programmer's Manual.
|
|
Packit |
7cfc04 |
The Linux implementation of this interface may differ (consult
|
|
Packit |
7cfc04 |
the corresponding Linux manual page for details of Linux behavior),
|
|
Packit |
7cfc04 |
or the interface may not be implemented on Linux.
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
lchown
|
|
Packit |
7cfc04 |
\(em change the owner and group of a symbolic link
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
#include <unistd.h>
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
int lchown(const char *\fIpath\fP, uid_t \fIowner\fP, gid_t \fIgroup\fP);
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIlchown\fR()
|
|
Packit |
7cfc04 |
function shall be equivalent to
|
|
Packit |
7cfc04 |
\fIchown\fR(),
|
|
Packit |
7cfc04 |
except in the case where the named file is a symbolic link. In this
|
|
Packit |
7cfc04 |
case,
|
|
Packit |
7cfc04 |
\fIlchown\fR()
|
|
Packit |
7cfc04 |
shall change the ownership of the symbolic link file itself, while
|
|
Packit |
7cfc04 |
\fIchown\fR()
|
|
Packit |
7cfc04 |
changes the ownership of the file or directory to which the symbolic
|
|
Packit |
7cfc04 |
link refers.
|
|
Packit |
7cfc04 |
.SH "RETURN VALUE"
|
|
Packit |
7cfc04 |
Upon successful completion,
|
|
Packit |
7cfc04 |
\fIlchown\fR()
|
|
Packit |
7cfc04 |
shall return 0. Otherwise, it shall return \(mi1 and set
|
|
Packit |
7cfc04 |
.IR errno
|
|
Packit |
7cfc04 |
to indicate an error.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIlchown\fR()
|
|
Packit |
7cfc04 |
function shall fail if:
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EACCES
|
|
Packit |
7cfc04 |
Search permission is denied on a component of the path prefix of
|
|
Packit |
7cfc04 |
.IR path .
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EINVAL
|
|
Packit |
7cfc04 |
The owner or group ID is not a value supported by the implementation.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ELOOP
|
|
Packit |
7cfc04 |
A loop exists in symbolic links encountered during resolution of the
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENAMETOOLONG
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
The length of a component of a pathname is longer than
|
|
Packit |
7cfc04 |
{NAME_MAX}.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENOENT
|
|
Packit |
7cfc04 |
A component of
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
does not name an existing file or
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
is an empty string.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENOTDIR
|
|
Packit |
7cfc04 |
A component of the path prefix names an existing file that is neither
|
|
Packit |
7cfc04 |
a directory nor a symbolic link to a directory, or the
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument contains at least one non-\c
|
|
Packit |
7cfc04 |
<slash>
|
|
Packit |
7cfc04 |
character and ends with one or more trailing
|
|
Packit |
7cfc04 |
<slash>
|
|
Packit |
7cfc04 |
characters and the last pathname component names an existing file
|
|
Packit |
7cfc04 |
that is neither a directory nor a symbolic link to a directory.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EPERM
|
|
Packit |
7cfc04 |
The effective user ID does not match the owner of the file and the
|
|
Packit |
7cfc04 |
process does not have appropriate privileges.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EROFS
|
|
Packit |
7cfc04 |
The file resides on a read-only file system.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIlchown\fR()
|
|
Packit |
7cfc04 |
function may fail if:
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EIO
|
|
Packit |
7cfc04 |
An I/O error occurred while reading or writing to the file system.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EINTR
|
|
Packit |
7cfc04 |
A signal was caught during execution of the function.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ELOOP
|
|
Packit |
7cfc04 |
More than
|
|
Packit |
7cfc04 |
{SYMLOOP_MAX}
|
|
Packit |
7cfc04 |
symbolic links were encountered during resolution of the
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENAMETOOLONG
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
The length of a pathname exceeds
|
|
Packit |
7cfc04 |
{PATH_MAX},
|
|
Packit |
7cfc04 |
or pathname resolution of a symbolic link produced an intermediate
|
|
Packit |
7cfc04 |
result with a length that exceeds
|
|
Packit |
7cfc04 |
{PATH_MAX}.
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.IR "The following sections are informative."
|
|
Packit |
7cfc04 |
.SH EXAMPLES
|
|
Packit |
7cfc04 |
.SS "Changing the Current Owner of a File"
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The following example shows how to change the ownership of the symbolic
|
|
Packit |
7cfc04 |
link named
|
|
Packit |
7cfc04 |
.BR /modules/pass1
|
|
Packit |
7cfc04 |
to the user ID associated with ``jones'' and the group ID associated
|
|
Packit |
7cfc04 |
with ``cnd''.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The numeric value for the user ID is obtained by using the
|
|
Packit |
7cfc04 |
\fIgetpwnam\fR()
|
|
Packit |
7cfc04 |
function. The numeric value for the group ID is obtained by using the
|
|
Packit |
7cfc04 |
\fIgetgrnam\fR()
|
|
Packit |
7cfc04 |
function.
|
|
Packit |
7cfc04 |
.sp
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
\fB
|
|
Packit |
7cfc04 |
#include <sys/types.h>
|
|
Packit |
7cfc04 |
#include <unistd.h>
|
|
Packit |
7cfc04 |
#include <pwd.h>
|
|
Packit |
7cfc04 |
#include <grp.h>
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
struct passwd *pwd;
|
|
Packit |
7cfc04 |
struct group *grp;
|
|
Packit |
7cfc04 |
char *path = "/modules/pass1";
|
|
Packit |
7cfc04 |
\&...
|
|
Packit |
7cfc04 |
pwd = getpwnam("jones");
|
|
Packit |
7cfc04 |
grp = getgrnam("cnd");
|
|
Packit |
7cfc04 |
lchown(path, pwd->pw_uid, grp->gr_gid);
|
|
Packit |
7cfc04 |
.fi \fR
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.SH "APPLICATION USAGE"
|
|
Packit |
7cfc04 |
On implementations which support symbolic links as directory entries
|
|
Packit |
7cfc04 |
rather than files,
|
|
Packit |
7cfc04 |
\fIlchown\fR()
|
|
Packit |
7cfc04 |
may fail.
|
|
Packit |
7cfc04 |
.SH RATIONALE
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH "FUTURE DIRECTIONS"
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH "SEE ALSO"
|
|
Packit |
7cfc04 |
.IR "\fIchown\fR\^(\|)",
|
|
Packit |
7cfc04 |
.IR "\fIsymlink\fR\^(\|)"
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The Base Definitions volume of POSIX.1\(hy2008,
|
|
Packit |
7cfc04 |
.IR "\fB<unistd.h>\fP"
|
|
Packit |
7cfc04 |
.SH COPYRIGHT
|
|
Packit |
7cfc04 |
Portions of this text are reprinted and reproduced in electronic form
|
|
Packit |
7cfc04 |
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
|
|
Packit |
7cfc04 |
-- Portable Operating System Interface (POSIX), The Open Group Base
|
|
Packit |
7cfc04 |
Specifications Issue 7, Copyright (C) 2013 by the Institute of
|
|
Packit |
7cfc04 |
Electrical and Electronics Engineers, Inc and The Open Group.
|
|
Packit |
7cfc04 |
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
|
|
Packit |
7cfc04 |
event of any discrepancy between this version and the original IEEE and
|
|
Packit |
7cfc04 |
The Open Group Standard, the original IEEE and The Open Group Standard
|
|
Packit |
7cfc04 |
is the referee document. The original Standard can be obtained online at
|
|
Packit |
7cfc04 |
http://www.unix.org/online.html .
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
Any typographical or formatting errors that appear
|
|
Packit |
7cfc04 |
in this page are most likely
|
|
Packit |
7cfc04 |
to have been introduced during the conversion of the source files to
|
|
Packit |
7cfc04 |
man page format. To report such errors, see
|
|
Packit |
7cfc04 |
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|