1SETREUID(P)                POSIX Programmer's Manual               SETREUID(P)
2
3
4

NAME

6       setreuid - set real and effective user IDs
7

SYNOPSIS

9       #include <unistd.h>
10
11       int setreuid(uid_t ruid, uid_t euid);
12
13

DESCRIPTION

15       The  setreuid()  function  shall set the real and effective user IDs of
16       the current process to the values specified by the ruid and euid  argu‐
17       ments.  If ruid or euid is -1, the corresponding effective or real user
18       ID of the current process shall be left unchanged.
19
20       A process with appropriate privileges can set either ID to  any  value.
21       An  unprivileged process can only set the effective user ID if the euid
22       argument is equal to either the real, effective, or saved  user  ID  of
23       the process.
24
25       It  is  unspecified whether a process without appropriate privileges is
26       permitted to change the real user ID to match the current real,  effec‐
27       tive, or saved set-user-ID of the process.
28

RETURN VALUE

30       Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
31       returned and errno set to indicate the error.
32

ERRORS

34       The setreuid() function shall fail if:
35
36       EINVAL The value of the ruid or euid argument  is  invalid  or  out-of-
37              range.
38
39       EPERM  The  current  process  does not have appropriate privileges, and
40              either an attempt was made to change the effective user ID to  a
41              value other than the real user ID or the saved set-user-ID or an
42              attempt was made to change the real user ID to a value not  per‐
43              mitted by the implementation.
44
45
46       The following sections are informative.
47

EXAMPLES

49   Setting the Effective User ID to the Real User ID
50       The following example sets the effective user ID of the calling process
51       to the real user ID, so that files created later will be owned  by  the
52       current user.
53
54
55              #include <unistd.h>
56              #include <sys/types.h>
57              ...
58              setreuid(getuid(), getuid());
59              ...
60

APPLICATION USAGE

62       None.
63

RATIONALE

65       None.
66

FUTURE DIRECTIONS

68       None.
69

SEE ALSO

71       getegid()  ,  geteuid() , getgid() , getuid() , setegid() , seteuid() ,
72       setgid() , setregid() , setuid()  ,  the  Base  Definitions  volume  of
73       IEEE Std 1003.1-2001, <unistd.h>
74
76       Portions  of  this text are reprinted and reproduced in electronic form
77       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
78       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
79       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
80       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
81       event of any discrepancy between this version and the original IEEE and
82       The  Open Group Standard, the original IEEE and The Open Group Standard
83       is the referee document. The original Standard can be  obtained  online
84       at http://www.opengroup.org/unix/online.html .
85
86
87
88IEEE/The Open Group                  2003                          SETREUID(P)
Impressum