1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "SETREUID" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
5 setreuid \- set real and effective user IDs
11 int setreuid(uid_t\fP \fIruid\fP\fB, uid_t\fP \fIeuid\fP\fB); \fP
17 The \fIsetreuid\fP() function shall set the real and effective user
18 IDs of the current process to the values specified by the
19 \fIruid\fP and \fIeuid\fP arguments. If \fIruid\fP or \fIeuid\fP is
20 -1, the corresponding effective or real user ID of the
21 current process shall be left unchanged.
23 A process with appropriate privileges can set either ID to any value.
24 An unprivileged process can only set the effective user ID
25 if the \fIeuid\fP argument is equal to either the real, effective,
26 or saved user ID of the process.
28 It is unspecified whether a process without appropriate privileges
29 is permitted to change the real user ID to match the current
30 real, effective, or saved set-user-ID of the process.
33 Upon successful completion, 0 shall be returned. Otherwise, -1 shall
34 be returned and \fIerrno\fP set to indicate the error.
37 The \fIsetreuid\fP() function shall fail if:
40 The value of the \fIruid\fP or \fIeuid\fP argument is invalid or out-of-range.
43 The current process does not have appropriate privileges, and either
44 an attempt was made to change the effective user ID to a
45 value other than the real user ID or the saved set-user-ID or an attempt
46 was made to change the real user ID to a value not
47 permitted by the implementation.
50 \fIThe following sections are informative.\fP
52 .SS Setting the Effective User ID to the Real User ID
54 The following example sets the effective user ID of the calling process
55 to the real user ID, so that files created later will be
56 owned by the current user.
61 \fB#include <unistd.h>
62 #include <sys/types.h>
64 setreuid(getuid(), getuid());
80 \fIgetegid\fP() , \fIgeteuid\fP() , \fIgetgid\fP() , \fIgetuid\fP()
81 , \fIsetegid\fP() , \fIseteuid\fP() , \fIsetgid\fP() , \fIsetregid\fP()
82 , \fIsetuid\fP() , the Base Definitions volume of
83 IEEE\ Std\ 1003.1-2001, \fI<unistd.h>\fP
85 Portions of this text are reprinted and reproduced in electronic form
86 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
87 -- Portable Operating System Interface (POSIX), The Open Group Base
88 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
89 Electrical and Electronics Engineers, Inc and The Open Group. In the
90 event of any discrepancy between this version and the original IEEE and
91 The Open Group Standard, the original IEEE and The Open Group Standard
92 is the referee document. The original Standard can be obtained online at
93 http://www.opengroup.org/unix/online.html .