1SETEUID(2)                 Linux Programmer's Manual                SETEUID(2)
2
3
4

NAME

6       seteuid, setegid - set effective user or group ID
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <unistd.h>
11
12       int seteuid(uid_t euid);
13       int setegid(gid_t egid);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       seteuid(), setegid():
18           _BSD_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
19

DESCRIPTION

21       seteuid()  sets the effective user ID of the calling process.  Unprivi‐
22       leged user processes may only set the effective user  ID  to  the  real
23       user ID, the effective user ID or the saved set-user-ID.
24
25       Precisely the same holds for setegid() with "group" instead of "user".
26

RETURN VALUE

28       On  success,  zero is returned.  On error, -1 is returned, and errno is
29       set appropriately.
30

ERRORS

32       EPERM  The calling process is not privileged (Linux: does not have  the
33              CAP_SETUID  capability in the case of seteuid(), or the CAP_SET‐
34              GID capability in the case of setegid()) and euid (respectively,
35              egid)  is  not  the  real  user  (group)  ID, the effective user
36              (group) ID, or the saved set-user-ID (saved set-group-ID).
37

CONFORMING TO

39       4.3BSD, POSIX.1-2001.
40

NOTES

42       Setting the effective user (group) ID to the saved  set-user-ID  (saved
43       set-group-ID) is possible since Linux 1.1.37 (1.1.38).  On an arbitrary
44       system one should check _POSIX_SAVED_IDS.
45
46       Under libc4,  libc5  and  glibc  2.0  seteuid(euid)  is  equivalent  to
47       setreuid(-1,  euid)  and hence may change the saved set-user-ID.  Under
48       glibc 2.1 and later it is equivalent to  setresuid(-1,  euid,  -1)  and
49       hence  does  not  change the saved set-user-ID.  Analogous remarks hold
50       for setegid(), with the difference that the  change  in  implementation
51       from  setregid(-1,  egid)  to setresgid(-1, egid, -1) occurred in glibc
52       2.2 or 2.3 (dependeing on the hardware architecture).
53
54       According to POSIX.1, seteuid() (setegid()) need not permit euid (egid)
55       to be the same value as the current effective user (group) ID, and some
56       implementations do not permit this.
57

SEE ALSO

59       geteuid(2), setresuid(2), setreuid(2), setuid(2), capabilities(7), cre‐
60       dentials(7)
61

COLOPHON

63       This  page  is  part of release 3.53 of the Linux man-pages project.  A
64       description of the project, and information about reporting  bugs,  can
65       be found at http://www.kernel.org/doc/man-pages/.
66
67
68
69Linux                             2012-07-02                        SETEUID(2)
Impressum