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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       setreuid - set real and effective user IDs
13

SYNOPSIS

15       #include <unistd.h>
16
17       int setreuid(uid_t ruid, uid_t euid);
18
19

DESCRIPTION

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

RETURN VALUE

36       Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
37       returned and errno set to indicate the error.
38

ERRORS

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

EXAMPLES

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

APPLICATION USAGE

68       None.
69

RATIONALE

71       None.
72

FUTURE DIRECTIONS

74       None.
75

SEE ALSO

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