Merge commit 'b31ca922c7346747131aed07c0c171ec2f573aac' into merges
[unleashed.git] / share / man / man2 / setreuid.2
blobb35f01701f03e884c51880d79fb7825aa58ae258
1 '\" te
2 .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SETREUID 2 "Mar 22, 2004"
7 .SH NAME
8 setreuid \- set real and effective user IDs
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <unistd.h>
14 \fBint\fR \fBsetreuid\fR(\fBuid_t\fR \fIruid\fR, \fBuid_t\fR \fIeuid\fR);
15 .fi
17 .SH DESCRIPTION
18 .sp
19 .LP
20 The \fBsetreuid()\fR function is used to set the real and effective user IDs of
21 the calling process. If \fIruid\fR is \(mi1, the real user ID is not changed;
22 if \fIeuid\fR is \(mi1, the effective user ID is not changed. The real and
23 effective user IDs may be set to different values in the same call.
24 .sp
25 .LP
26 If the {\fBPRIV_PROC_SETID\fR} privilege is asserted in the effective set of
27 the calling process, the real user ID and the effective user \fBID\fR can be
28 set to any legal value.
29 .sp
30 .LP
31 If the {\fBPRIV_PROC_SETID\fR} privilege is not asserted in the effective set
32 of the calling process, either the real user ID can be set to the effective
33 user ID, or the effective user ID can either be set to the saved set-user ID
34 from \fBexecve()\fR (see \fBexec\fR(2)) or the real user ID.
35 .sp
36 .LP
37 In either case, if the real user ID is being changed (that is, if \fIruid\fR is
38 not  \fB\(mi1\fR), or the effective user ID is being changed to a value not
39 equal to the real user ID, the saved set-user ID is set equal to the new
40 effective user ID.
41 .sp
42 .LP
43 All privileges are required to change to uid 0.
44 .SH RETURN VALUES
45 .sp
46 .LP
47 Upon successful completion, 0 is returned. Otherwise, \(mi1 is returned,
48 \fBerrno\fR is set to indicate the error, and neither of the user IDs will be
49 changed.
50 .SH ERRORS
51 .sp
52 .LP
53 The \fBsetreuid()\fR function will fail if:
54 .sp
55 .ne 2
56 .na
57 \fB\fBEINVAL\fR\fR
58 .ad
59 .RS 10n
60 The value of \fIruid\fR or \fIeuid\fR is less than  \fB0\fR or greater than
61 \fBUID_MAX\fR (defined in <\fBlimits.h\fR>).
62 .RE
64 .sp
65 .ne 2
66 .na
67 \fB\fBEPERM\fR\fR
68 .ad
69 .RS 10n
70 The {PRIV_PROC_SETID} privilege is not asserted in the effective set of the
71 calling processes and a change was specified other than changing the real user
72 \fBID\fR to the effective user \fBID\fR, or changing the effective user
73 \fBID\fR to the real user \fBID\fR or the saved set-user \fBID\fR. See
74 \fBprivileges\fR(5) for additional restrictions which apply when changing to
75 UID 0.
76 .RE
78 .SH USAGE
79 .sp
80 .LP
81 If a set-user-\fBID\fR process sets its effective user \fBID\fR to its real
82 user \fBID\fR, it can still set its effective user \fBID\fR back to the saved
83 set-user \fBID\fR.
84 .SH ATTRIBUTES
85 .sp
86 .LP
87 See \fBattributes\fR(5) for descriptions of the following attributes:
88 .sp
90 .sp
91 .TS
92 box;
93 c | c
94 l | l .
95 ATTRIBUTE TYPE  ATTRIBUTE VALUE
97 Interface Stability     Standard
98 .TE
100 .SH SEE ALSO
103 \fBexec\fR(2), \fBgetuid\fR(2), \fBsetregid\fR(2), \fBsetuid\fR(2),
104 \fBattributes\fR(5), \fBprivileges\fR(5), \fBstandards\fR(5)