1SETREUID(2) Linux Programmer's Manual SETREUID(2)
2
3
4
6 setreuid, setregid - set real and/or effective user or group ID
7
9 #include <sys/types.h>
10 #include <unistd.h>
11
12 int setreuid(uid_t ruid, uid_t euid);
13 int setregid(gid_t rgid, gid_t egid);
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 setreuid(), setregid(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
18
20 setreuid() sets real and effective user IDs of the calling process.
21
22 Supplying a value of -1 for either the real or effective user ID forces
23 the system to leave that ID unchanged.
24
25 Unprivileged processes may only set the effective user ID to the real
26 user ID, the effective user ID or the saved set-user-ID.
27
28 POSIX: It is unspecified whether unprivileged processes may set the
29 real user ID to the real user ID, the effective user ID or the saved
30 set-user-ID.
31
32 Linux: Unprivileged users may only set the real user ID to the real
33 user ID or the effective user ID.
34
35 Linux: If the real user ID is set or the effective user ID is set to a
36 value not equal to the previous real user ID, the saved set-user-ID
37 will be set to the new effective user ID.
38
39 Completely analogously, setregid() sets real and effective group ID's
40 of the calling process, and all of the above holds with "group" instead
41 of "user".
42
44 On success, zero is returned. On error, -1 is returned, and errno is
45 set appropriately.
46
48 EPERM The calling process is not privileged (Linux: does not have the
49 CAP_SETUID capability in the case of setreuid(), or the CAP_SET‐
50 GID capability in the case of setregid()) and a change other
51 than (i) swapping the effective user (group) ID with the real
52 user (group) ID, or (ii) setting one to the value of the other
53 or (iii) setting the effective user (group) ID to the value of
54 the saved set-user-ID (saved set-group-ID) was specified.
55
57 POSIX.1-2001, 4.3BSD (the setreuid() and setregid() function calls
58 first appeared in 4.2BSD).
59
61 Setting the effective user (group) ID to the saved set-user-ID (saved
62 set-group-ID) is possible since Linux 1.1.37 (1.1.38).
63
65 getgid(2), getuid(2), seteuid(2), setgid(2), setresuid(2), setuid(2),
66 capabilities(7)
67
69 This page is part of release 3.22 of the Linux man-pages project. A
70 description of the project, and information about reporting bugs, can
71 be found at http://www.kernel.org/doc/man-pages/.
72
73
74
75Linux 2007-07-26 SETREUID(2)