1SETEUID(2) Linux Programmer's Manual SETEUID(2)
2
3
4
6 seteuid, setegid - set effective user or group ID
7
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(): _BSD_SOURCE || _POSIX_C_SOURCE >= 200112L ||
18 _XOPEN_SOURCE >= 600
19
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
28 On success, zero is returned. On error, -1 is returned, and errno is
29 set appropriately.
30
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
39 4.3BSD, POSIX.1-2001.
40
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. Similar remarks hold for
50 setegid().
51
53 geteuid(2), setresuid(2), setreuid(2), setuid(2), capabilities(7), cre‐
54 dentials(7)
55
57 This page is part of release 3.22 of the Linux man-pages project. A
58 description of the project, and information about reporting bugs, can
59 be found at http://www.kernel.org/doc/man-pages/.
60
61
62
63Linux 2007-07-26 SETEUID(2)