chown(2) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

chown(2)

chown(2)                         System Calls                         chown(2)



NAME
       chown, lchown, fchown, fchownat - change owner and group of a file

SYNOPSIS
       #include <unistd.h>
       #include <sys/types.h>

       int chown(const char *path, uid_t owner, gid_t group);


       int lchown(const char *path, uid_t owner, gid_t group);


       int fchown(int fildes, uid_t owner, gid_t group);


       int fchownat(int fildes, const char *path, uid_t owner,
            gid_t group, int flag);

DESCRIPTION
       The chown() and fchown() functions set 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,
       these functions do 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 direc‐
       tory 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 spe‐
       cial value AT_FDCWD, the path resolution reverts back to current  work‐
       ing  directory  relative.  If the path argument is absolute, the fildes
       argument is ignored. If the path argument is a null pointer, the  func‐
       tion behaves like fchown().


       Values for flag are constructed by a bitwise-inclusive OR of flags from
       the following list, defined in <fcntl.h>:

       AT_SYMLINK_NOFOLLOW    If path names a symbolic link, then ownership of
                              the symbolic link is changed, as in lchown().



       If  chown(),  lchown(), fchown(), or fchownat() is invoked by a process
       that does not have {PRIV_FILE_SETID} asserted in its effective set, the
       set-user-ID and set-group-ID bits of the file mode, S_ISUID and S_ISGID
       respectively, are cleared (see chmod(2)). Additional restrictions apply
       when changing the ownership to uid 0.


       The  operating  system  defines several privileges to override restric‐
       tions on the chown() family of functions.  When  the  {PRIV_FILE_CHOWN}
       privilege  is  asserted  in  the  effective set of the current process,
       there are no restrictions except in the special circumstances of chang‐
       ing  ownership to or from uid 0. When the {PRIV_FILE_CHOWN_SELF} privi‐
       lege is asserted, ownership changes are  restricted  to  the  files  of
       which  the  ownership  matches  the  effective  user  ID of the current
       process. If neither privilege is asserted in the effective set  of  the
       calling  process, ownership changes are limited to changes of the group
       of the file to the list of supplementary group IDs  and  the  effective
       group ID.


       The  file system provides mount options rstchown and norstchown to con‐
       trol the default chown() behavior of the file system and NFS server. If
       rstchown  is  not  in  effect,  the privilege {PRIV_FILE_CHOWN_SELF} is
       implicitly granted to the user when  attempting  to  give  away  files,
       except  for  files  owned  by uid 0. The _POSIX_CHOWN_RESTRICTED option
       will be reported as true for paths  on  filesystems  mounted  with  the
       rstchown option, when checked with fpathconf(2) or getconf(1).


       Upon successful completion, chown(), fchown(), fchownat(), and lchown()
       mark for update the st_ctime field of the file.

RETURN VALUES
       Upon successful completion, 0 is returned. Otherwise, −1  is  returned,
       the  owner  and  group of the named file remain unchanged, and errno is
       set to indicate the error.

ERRORS
       All of these functions will fail if:

       EPERM    The effective user ID does not match the owner of the file and
                the  {PRIV_FILE_CHOWN} privilege is not asserted in the effec‐
                tive set of the calling process, or the {PRIV_FILE_CHOWN_SELF}
                privilege  is not asserted in the effective set of the calling
                process.



       The chown(), lchown(), and fchownat() functions will fail if:

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


       EFAULT          The  path argument points to an illegal address and for
                       fchownat(), the file descriptor has the value AT_FDCWD.


       EINTR           A signal was caught during the execution of the chown()
                       or lchown() function.


       EINVAL          The group or owner argument is out of range.


       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}, or
                       the length of a path component exceeds {NAME_MAX} while
                       {_POSIX_NO_TRUNC} is in effect.


       ENOLINK         The  path  argument  points to a remote machine and the
                       link to that machine is no longer active.


       ENOENT          Either a component of  the  path  prefix  or  the  file
                       referred  to  by path does not exist or is a null path‐
                       name.


       ENOTDIR         A component of the path prefix of path is not a  direc‐
                       tory,  or  the  path supplied to fchownat() is relative
                       and the file descriptor provided does not  refer  to  a
                       valid directory.


       EROFS           The named file resides on a read-only file system.



       The fchown() and fchownat() functions will fail if:

       EBADF      For  fchown()  the  fildes  argument  is  not  an  open file
                  descriptor and.

                  For fchownat(), the path argument is not  absolute  and  the
                  fildes argument is not AT_FDCWD or an open file descriptor.


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


       EINTR      A signal was caught during execution of the function.


       ENOLINK    The fildes argument points to a remote machine and the  link
                  to that machine is no longer active.


       EINVAL     The group or owner argument is out of range.


       EROFS      The  named file referred to by fildes resides on a read-only
                  file system.


USAGE
       The ability to specify a null path argument to the fchownat()  function
       is  a  Solaris extension not specified by the standards, and may not be
       portable to other systems. Use the fchown() function for greater porta‐
       bility when changing the ownership of an open file descriptor.

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _  MT-LevelSee  below.   _
       StandardSee below.



       The chown() and fchownat() functions are Async-Signal-Safe.


       See standards(7) for descriptions of the following standards:


       tab()  box;  cw(2.2i) |cw(3.3i) lw(2.2i) |lw(3.3i) INTERFACESAPPLICABLE
       STANDARDS _
         chown()
       T{
         POSIX.1-1990 through 2008,
         SUS through SUSv4,
         XPG1 through XPG7

       T} _ T{
         fchown()
         lchown()

       T}T{
         POSIX.1-2001 through 2008,
         SUS through SUSv4,
         XPG4v2 through XPG7

       T} _
         fchownat()
       T{
         POSIX.1-2008,
         SUSv4,
         XPG7

       T}


SEE ALSO
       chgrp(1),  chown(1),  getconf(1),  chmod(2),  fpathconf(2),  system(5),
       attributes(7), privileges(7), standards(7)

HISTORY
       The chown(), fchown(), and lchown() functions have been included in all
       Sun and Oracle releases of Solaris.


       The fchownat() function was added to Solaris in the Solaris 9 release.



Oracle Solaris 11.4               3 Nov 2021                          chown(2)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3