LCHOWN(3)                  POSIX Programmer's Manual                 LCHOWN(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       lchown -- change the owner and group of a symbolic link

SSYYNNOOPPSSIISS
       #include <unistd.h>

       int lchown(const char *_p_a_t_h, uid_t _o_w_n_e_r, gid_t _g_r_o_u_p);

DDEESSCCRRIIPPTTIIOONN
       The _l_c_h_o_w_n() function shall be equivalent to _c_h_o_w_n(), except in the
       case where the named file is a symbolic link. In this case, _l_c_h_o_w_n()
       shall change the ownership of the symbolic link file itself, while
       _c_h_o_w_n() changes the ownership of the file or directory to which the
       symbolic link refers.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _l_c_h_o_w_n() shall return 0. Otherwise, it
       shall return -1 and set _e_r_r_n_o to indicate an error.

EERRRROORRSS
       The _l_c_h_o_w_n() function shall fail if:

       EEAACCCCEESS Search permission is denied on a component of the path prefix of
              _p_a_t_h.

       EEIINNVVAALL The owner or group ID is not a value supported by the
              implementation.

       EELLOOOOPP  A loop exists in symbolic links encountered during resolution of
              the _p_a_t_h argument.

       EENNAAMMEETTOOOOLLOONNGG
              The length of a component of a pathname is longer than
              {NAME_MAX}.

       EENNOOEENNTT A component of _p_a_t_h does not name an existing file or _p_a_t_h is an
              empty string.

       EENNOOTTDDIIRR
              A component of the path prefix names an existing file that is
              neither a directory nor a symbolic link to a directory, or the
              _p_a_t_h argument contains at least one non-<slash> character and
              ends with one or more trailing <slash> characters and the last
              pathname component names an existing file that is neither a
              directory nor a symbolic link to a directory.

       EEPPEERRMM  The effective user ID does not match the owner of the file and
              the process does not have appropriate privileges.

       EERROOFFSS  The file resides on a read-only file system.

       The _l_c_h_o_w_n() function may fail if:

       EEIIOO    An I/O error occurred while reading or writing to the file
              system.

       EEIINNTTRR  A signal was caught during execution of the function.

       EELLOOOOPP  More than {SYMLOOP_MAX} symbolic links were encountered during
              resolution of the _p_a_t_h argument.

       EENNAAMMEETTOOOOLLOONNGG
              The length of a pathname exceeds {PATH_MAX}, or pathname
              resolution of a symbolic link produced an intermediate result
              with a length that exceeds {PATH_MAX}.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
   CChhaannggiinngg tthhee CCuurrrreenntt OOwwnneerr ooff aa FFiillee
       The following example shows how to change the ownership of the symbolic
       link named //mmoodduulleess//ppaassss11 to the user ID associated with ``jones'' and
       the group ID associated with ``cnd''.

       The numeric value for the user ID is obtained by using the _g_e_t_p_w_n_a_m()
       function. The numeric value for the group ID is obtained by using the
       _g_e_t_g_r_n_a_m() function.


           #include <sys/types.h>
           #include <unistd.h>
           #include <pwd.h>
           #include <grp.h>

           struct passwd *pwd;
           struct group  *grp;
           char          *path = "/modules/pass1";
           ...
           pwd = getpwnam("jones");
           grp = getgrnam("cnd");
           lchown(path, pwd->pw_uid, grp->gr_gid);

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       On implementations which support symbolic links as directory entries
       rather than files, _l_c_h_o_w_n() may fail.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _c_h_o_w_n(), _s_y_m_l_i_n_k()

       The Base Definitions volume of POSIX.1-2017, <<uunniissttdd..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                            LCHOWN(3)
