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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

NOTES

54       Setting  the  effective user (group) ID to the saved set-user-ID (saved
55       set-group-ID) is possible since Linux 1.1.37 (1.1.38).
56

CONFORMING TO

58       POSIX.1-2001, 4.3BSD (the  setreuid()  and  setregid()  function  calls
59       first appeared in 4.2BSD).
60

SEE ALSO

62       getgid(2),  getuid(2),  seteuid(2), setgid(2), setresuid(2), setuid(2),
63       capabilities(7)
64
65
66
67Linux 2.6                         2004-07-04                       SETREUID(2)
Impressum