1setreuid(2) System Calls setreuid(2)
2
3
4
6 setreuid - set real and effective user IDs
7
9 #include <unistd.h>
10
11 int setreuid(uid_t ruid, uid_t euid);
12
13
15 The setreuid() function is used to set the real and effective user IDs
16 of the calling process. If ruid is −1, the real user ID is not changed;
17 if euid is −1, the effective user ID is not changed. The real and
18 effective user IDs may be set to different values in the same call.
19
20
21 If the {PRIV_PROC_SETID} privilege is asserted in the effective set of
22 the calling process, the real user ID and the effective user ID can be
23 set to any legal value.
24
25
26 If the {PRIV_PROC_SETID} privilege is not asserted in the effective set
27 of the calling process, either the real user ID can be set to the
28 effective user ID, or the effective user ID can either be set to the
29 saved set-user ID from execve() (seeexec(2)) or the real user ID.
30
31
32 In either case, if the real user ID is being changed (that is, if ruid
33 is not −1), or the effective user ID is being changed to a value not
34 equal to the real user ID, the saved set-user ID is set equal to the
35 new effective user ID.
36
37
38 All privileges are required to change to uid 0.
39
41 Upon successful completion, 0 is returned. Otherwise, −1 is returned,
42 errno is set to indicate the error, and neither of the user IDs will be
43 changed.
44
46 The setreuid() function will fail if:
47
48 EINVAL The value of ruid or euid is less than 0 or greater than
49 UID_MAX (defined in <limits.h>).
50
51
52 EPERM The {PRIV_PROC_SETID} privilege is not asserted in the effec‐
53 tive set of the calling processes and a change was specified
54 other than changing the real user ID to the effective user
55 ID, or changing the effective user ID to the real user ID or
56 the saved set-user ID. See privileges(5) for additional
57 restrictions which apply when changing to UID 0.
58
59
61 If a set-user-ID process sets its effective user ID to its real user
62 ID, it can still set its effective user ID back to the saved set-user
63 ID.
64
66 See attributes(5) for descriptions of the following attributes:
67
68
69
70
71 ┌─────────────────────────────┬─────────────────────────────┐
72 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
73 ├─────────────────────────────┼─────────────────────────────┤
74 │Interface Stability │Standard │
75 └─────────────────────────────┴─────────────────────────────┘
76
78 exec(2), getuid(2), setregid(2), setuid(2), attributes(5), privi‐
79 leges(5), standards(5)
80
81
82
83SunOS 5.11 22 Mar 2004 setreuid(2)