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():
18           _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
19           _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
20

DESCRIPTION

22       setreuid() sets real and effective user IDs of the calling process.
23
24       Supplying a value of -1 for either the real or effective user ID forces
25       the system to leave that ID unchanged.
26
27       Unprivileged  processes  may only set the effective user ID to the real
28       user ID, the effective user ID, or the saved set-user-ID.
29
30       Unprivileged users may only set the real user ID to the real user ID or
31       the effective user ID.
32
33       If  the  real user ID is set or the effective user ID is set to a value
34       not equal to the previous real user ID, the saved set-user-ID  will  be
35       set to the new effective user ID.
36
37       Completely  analogously,  setregid() sets real and effective group ID's
38       of the calling process, and all of the above holds with "group" instead
39       of "user".
40

RETURN VALUE

42       On  success,  zero is returned.  On error, -1 is returned, and errno is
43       set appropriately.
44

ERRORS

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

CONFORMING TO

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

NOTES

59       Setting  the  effective user (group) ID to the saved set-user-ID (saved
60       set-group-ID) is possible since Linux 1.1.37 (1.1.38).
61
62       POSIX.1 does not specify all of possible ID changes that are  permitted
63       on  Linux  for  an unprivileged process.  For setreuid(), the effective
64       user ID can be made the same as the real user ID or the save  set-user-
65       ID,  and  it  is unspecified whether unprivileged processes may set the
66       real user ID to the real user ID, the effective user ID, or  the  saved
67       set-user-ID.   For  setregid(), the real group ID can be changed to the
68       value of the saved set-group-ID, and the  effective  group  ID  can  be
69       changed  to  the  value of the real group ID or the saved set-group-ID.
70       The precise details of what ID changes are permitted vary across imple‐
71       mentations.
72
73       POSIX.1  makes  no specification about the effect of these calls on the
74       saved set-user-ID and saved set-group-ID.
75
76       The original Linux setreuid() and  setregid()  system  calls  supported
77       only  16-bit  user  and  group  IDs.   Subsequently,  Linux  2.4  added
78       setreuid32()  and  setregid32(),  supporting  32-bit  IDs.   The  glibc
79       setreuid() and setregid() wrapper functions transparently deal with the
80       variations across kernel versions.
81

SEE ALSO

83       getgid(2), getuid(2), seteuid(2), setgid(2),  setresuid(2),  setuid(2),
84       capabilities(7)
85

COLOPHON

87       This  page  is  part of release 3.53 of the Linux man-pages project.  A
88       description of the project, and information about reporting  bugs,  can
89       be found at http://www.kernel.org/doc/man-pages/.
90
91
92
93Linux                             2010-11-22                       SETREUID(2)
Impressum