]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3p/setreuid.3p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3p / setreuid.3p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "SETREUID" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" setreuid
4 .SH NAME
5 setreuid \- set real and effective user IDs
6 .SH SYNOPSIS
7 .LP
8 \fB#include <unistd.h>
9 .br
10 .sp
11 int setreuid(uid_t\fP \fIruid\fP\fB, uid_t\fP \fIeuid\fP\fB); \fP
12 \fB
13 .br
14 \fP
15 .SH DESCRIPTION
16 .LP
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.
22 .LP
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.
27 .LP
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.
31 .SH RETURN VALUE
32 .LP
33 Upon successful completion, 0 shall be returned. Otherwise, -1 shall
34 be returned and \fIerrno\fP set to indicate the error.
35 .SH ERRORS
36 .LP
37 The \fIsetreuid\fP() function shall fail if:
38 .TP 7
39 .B EINVAL
40 The value of the \fIruid\fP or \fIeuid\fP argument is invalid or out-of-range.
41 .TP 7
42 .B EPERM
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.
48 .sp
49 .LP
50 \fIThe following sections are informative.\fP
51 .SH EXAMPLES
52 .SS Setting the Effective User ID to the Real User ID
53 .LP
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.
57 .sp
58 .RS
59 .nf
60
61 \fB#include <unistd.h>
62 #include <sys/types.h>
63 \&...
64 setreuid(getuid(), getuid());
65 \&...
66 \fP
67 .fi
68 .RE
69 .SH APPLICATION USAGE
70 .LP
71 None.
72 .SH RATIONALE
73 .LP
74 None.
75 .SH FUTURE DIRECTIONS
76 .LP
77 None.
78 .SH SEE ALSO
79 .LP
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
84 .SH COPYRIGHT
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 .