1SETRESUID(2) Linux Programmer's Manual SETRESUID(2)
2
3
4
6 setresuid, setresgid - set real, effective and saved user or group ID
7
9 #define _GNU_SOURCE
10 #include <unistd.h>
11
12 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
13 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
14
16 setresuid() sets the real user ID, the effective user ID, and the saved
17 set-user-ID of the calling process.
18
19 Unprivileged user processes may change the real UID, effective UID, and
20 saved set-user-ID, each to one of: the current real UID, the current
21 effective UID or the current saved set-user-ID.
22
23 Privileged processes (on Linux, those having the CAP_SETUID capability)
24 may set the real UID, effective UID, and saved set-user-ID to arbitrary
25 values.
26
27 If one of the arguments equals -1, the corresponding value is not
28 changed.
29
30 Regardless of what changes are made to the real UID, effective UID, and
31 saved set-user-ID, the file system UID is always set to the same value
32 as the (possibly new) effective UID.
33
34 Completely analogously, setresgid() sets the real GID, effective GID,
35 and saved set-group-ID of the calling process (and always modifies the
36 file system GID to be the same as the effective GID), with the same
37 restrictions for unprivileged processes.
38
40 On success, zero is returned. On error, -1 is returned, and errno is
41 set appropriately.
42
44 EAGAIN uid does not match the current UID and this call would bring
45 that user ID over its RLIMIT_NPROC resource limit.
46
47 EPERM The calling process is not privileged (did not have the
48 CAP_SETUID capability) and tried to change the IDs to values
49 that are not permitted.
50
52 These calls are available under Linux since Linux 2.1.44.
53
55 These calls are nonstandard; they also appear on HP-UX and some of the
56 BSDs.
57
59 Under HP-UX and FreeBSD the prototype is found in <unistd.h>. Under
60 Linux the prototype is provided by glibc since version 2.3.2.
61
63 getresuid(2), getuid(2), setfsgid(2), setfsuid(2), setreuid(2),
64 setuid(2), capabilities(7), credentials(7), feature_test_macros(7)
65
67 This page is part of release 3.25 of the Linux man-pages project. A
68 description of the project, and information about reporting bugs, can
69 be found at http://www.kernel.org/doc/man-pages/.
70
71
72
73Linux 2007-07-26 SETRESUID(2)