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

NAME

6       setreuid, setregid - set real and/or effective user or group ID
7

SYNOPSIS

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

DESCRIPTION

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       Unprivileged users may only set the real user ID to the real user ID or
29       the effective user ID.
30
31       If the real user ID is set or the effective user ID is set to  a  value
32       not  equal  to the previous real user ID, the saved set-user-ID will be
33       set to the new effective user ID.
34
35       Completely analogously, setregid() sets real and effective  group  ID's
36       of the calling process, and all of the above holds with "group" instead
37       of "user".
38

RETURN VALUE

40       On success, zero is returned.  On error, -1 is returned, and  errno  is
41       set appropriately.
42

ERRORS

44       EPERM  The  calling process is not privileged (Linux: does not have the
45              CAP_SETUID capability in the case of setreuid(), or the CAP_SET‐
46              GID  capability  in  the  case of setregid()) and a change other
47              than (i) swapping the effective user (group) ID  with  the  real
48              user  (group)  ID, or (ii) setting one to the value of the other
49              or (iii) setting the effective user (group) ID to the  value  of
50              the saved set-user-ID (saved set-group-ID) was specified.
51

CONFORMING TO

53       POSIX.1-2001,  4.3BSD  (the  setreuid()  and  setregid() function calls
54       first appeared in 4.2BSD).
55

NOTES

57       Setting the effective user (group) ID to the saved  set-user-ID  (saved
58       set-group-ID) is possible since Linux 1.1.37 (1.1.38).
59
60       POSIX.1  does not specify all of possible ID changes that are permitted
61       on Linux for an unprivileged process.  For  setreuid(),  the  effective
62       user  ID can be made the same as the real user ID or the save set-user-
63       ID, and it is unspecified whether unprivileged processes  may  set  the
64       real  user  ID to the real user ID, the effective user ID, or the saved
65       set-user-ID.  For setregid(), the real group ID can be changed  to  the
66       value  of  the  saved  set-group-ID,  and the effective group ID can be
67       changed to the value of the real group ID or  the  saved  set-group-ID.
68       The precise details of what ID changes are permitted vary across imple‐
69       mentations.
70
71       POSIX.1 makes no specification about the effect of these calls  on  the
72       saved set-user-ID and saved set-group-ID.
73

SEE ALSO

75       getgid(2),  getuid(2),  seteuid(2), setgid(2), setresuid(2), setuid(2),
76       capabilities(7)
77

COLOPHON

79       This page is part of release 3.25 of the Linux  man-pages  project.   A
80       description  of  the project, and information about reporting bugs, can
81       be found at http://www.kernel.org/doc/man-pages/.
82
83
84
85Linux                             2009-10-17                       SETREUID(2)
Impressum