man(1) Manual page archive


     GETUID(2)                                               GETUID(2)

     NAME
          getuid, getgid, geteuid, getegid, getlogname, getpid,
          getppid, getpgrp, setuid, setgid, setruid, setlogname,
          setpgrp - get or set user, group, or process identity

     SYNOPSIS
          int getuid()                    int pid;

          int geteuid()                   int setuid(uid)

          int getgid()                    int setgid(gid)

          int getegid()                   int setruid(uid)

          int getlogname(buf)             int setlogname(buf)
          char *buf;                      char buf[8];

          int getpid()                    int setpgrp(pid, pgrp)
                                          int pid, pgrp;
          int getppid()
    DESCRIPTION
         Gienttuigdetrpegtrupr(npsidt)he real userid of the current process,
         geteuid the effective userid.  The real userid identifies
         the person who is logged in, rather than the effective
         userid, which determines access permission at the moment.
         It is thus useful to set-userid programs to find out who
         invoked them.

         Getgid returns the real groupid, getegid the effective
         groupid.

         Getlogname copies the login name of the current process into
         the buffer pointed to by buf, which must be at least eight
         characters long.

         Getpid returns the process id of the current process,
         getppid that of its parent process.

         Getpgrp returns the process group id of process pid; 0 means
         the current process.

         Setuid (setgid) sets the effective and real userid (groupid)
         of the current process to uid (gid).  Both the effective and
         the real userid (groupid) are set.  These calls are permit-
         ted only if the process is super-user or if the argument is
         the real or effective userid (groupid).

    GETUID(2)                                               GETUID(2)

         Setruid sets the real userid only.  It may only be used by
         the super-user.

         Setlogname sets the login name returned by getlogname. It
         may only be used by the super-user.

         Setpgrp sets the process group id of process pid to pgrp.
         Pid 0 is the current process.  Only the super-user may set
         the process group of processes with other userids or set a
         process group to 0.

    SEE ALSO
         getuid(1), getlogin(3)

    DIAGNOSTICS
         getlogname: EFAULT
         setlogname: EFAULT, EPERM
         setuid, setgid, setruid, setpgrp: EPERM

    BUGS
         Non-super-user processes may set the process group of
         descendant processes; only certain unsupported shells use
         this, and the facility may vanish presently.