*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> setgid (2)              
Title
Content
Arch
Section
 

Contents


 setuid(2)                                                         setuid(2)




 NAME    [Toc]    [Back]
      setuid, setgid - set user and group IDs

 SYNOPSIS    [Toc]    [Back]
      #include <unistd.h>

      int setuid(uid_t uid);

      int setgid(gid_t gid);

 DESCRIPTION    [Toc]    [Back]
      setuid() sets the real-user-ID (ruid), effective-user-ID (euid),
      and/or saved-user-ID (suid) of the calling process.  The super-user's
      euid is zero.  The following conditions govern setuid's behavior:

           +  If the euid is zero, setuid() sets the ruid, euid, and suid to
              uid.

           +  If the euid is not zero, but the argument uid is equal to the
              ruid or the suid, setuid() sets the euid to uid; the ruid and
              suid remain unchanged.  (If a set-user-ID program is not
              running as super-user, it can change its euid to match its
              ruid and reset itself to the previous euid value.)

           +  If euid is not zero, but the argument uid is equal to the
              euid, and the calling process is a member of a group that has
              the PRIV_SETRUGID privilege (see privgrp(4)), setuid() sets
              the ruid to uid; the euid and suid remain unchanged.

      setgid() sets the real-group-ID (rgid), effective-group-ID (egid),
      and/or saved-group-ID (sgid) of the calling process.  The following
      conditions govern setgid()'s behavior:

           +  If euid is zero, setgid() sets the rgid and egid to gid.

           +  If euid is not zero, but the argument gid is equal to the rgid
              or the sgid, setgid() sets the egid to gid; the rgid and sgid
              remain unchanged.

           +  If euid is not zero, but the argument gid is equal to the
              egid, and the calling process is a member of a group that has
              the PRIV_SETRUGID privilege (see privgrp(4)), setgid() sets
              the rgid to gid; the egid and sgid remain unchanged.

 RETURN VALUE    [Toc]    [Back]
      Upon successful completion, setuid() and setgid() returned 0;
      otherwise, they return -1 and set errno to indicate the error.

 ERRORS    [Toc]    [Back]
      setuid() and setgid() fail and return -1 if any of the following
      conditions are encountered:



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 setuid(2)                                                         setuid(2)




           [EPERM]        None of the conditions above are met.

           [EINVAL]       uid (gid) is not a valid user (group) ID.

 WARNINGS    [Toc]    [Back]
      It is recommended that the PRIV_SETRUGID capability be avoided, as it
      is provided for backward compatibility.  This feature may be modified
      or dropped from future HP-UX releases.  When changing the real user ID
      and real group ID, use of setresuid() and setresgid() (see
      setresuid(2)) are recommended instead.

 AUTHOR    [Toc]    [Back]
      setuid() was developed by AT&T, the University of California,
      Berkeley, and HP.

      setgid() was developed by AT&T.

 SEE ALSO    [Toc]    [Back]
      exec(2), getprivgrp(2), getuid(2), setresuid(2) privgrp(4).

 STANDARDS CONFORMANCE    [Toc]    [Back]
      setuid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1

      setgid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1


 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
setruid FreeBSD set user and group ID
setegid NetBSD set user and group ID
seteuid NetBSD set user and group ID
setgid NetBSD set user and group ID
setruid NetBSD set user and group ID
setrgid NetBSD set user and group ID
setgid OpenBSD set user and group ID
seteuid OpenBSD set user and group ID
setegid OpenBSD set user and group ID
setuid NetBSD set user and group ID
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service