'\" te .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. .\" 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. .\" 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. .\" 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] .TH SETREUID 2 "Mar 22, 2004" .SH NAME setreuid \- set real and effective user IDs .SH SYNOPSIS .LP .nf #include \fBint\fR \fBsetreuid\fR(\fBuid_t\fR \fIruid\fR, \fBuid_t\fR \fIeuid\fR); .fi .SH DESCRIPTION .sp .LP The \fBsetreuid()\fR function is used to set the real and effective user IDs of the calling process. If \fIruid\fR is \(mi1, the real user ID is not changed; if \fIeuid\fR is \(mi1, the effective user ID is not changed. The real and effective user IDs may be set to different values in the same call. .sp .LP If the {\fBPRIV_PROC_SETID\fR} privilege is asserted in the effective set of the calling process, the real user ID and the effective user \fBID\fR can be set to any legal value. .sp .LP If the {\fBPRIV_PROC_SETID\fR} privilege is not asserted in the effective set of the calling process, either the real user ID can be set to the effective user ID, or the effective user ID can either be set to the saved set-user ID from \fBexecve()\fR (see\fBexec\fR(2)) or the real user ID. .sp .LP In either case, if the real user ID is being changed (that is, if \fIruid\fR is not \fB\(mi1\fR), or the effective user ID is being changed to a value not equal to the real user ID, the saved set-user ID is set equal to the new effective user ID. .sp .LP All privileges are required to change to uid 0. .SH RETURN VALUES .sp .LP Upon successful completion, 0 is returned. Otherwise, \(mi1 is returned, \fBerrno\fR is set to indicate the error, and neither of the user IDs will be changed. .SH ERRORS .sp .LP The \fBsetreuid()\fR function will fail if: .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n The value of \fIruid\fR or \fIeuid\fR is less than \fB0\fR or greater than \fBUID_MAX\fR (defined in <\fBlimits.h\fR>). .RE .sp .ne 2 .na \fB\fBEPERM\fR\fR .ad .RS 10n The {PRIV_PROC_SETID} privilege is not asserted in the effective set of the calling processes and a change was specified other than changing the real user \fBID\fR to the effective user \fBID\fR, or changing the effective user \fBID\fR to the real user \fBID\fR or the saved set-user \fBID\fR. See \fBprivileges\fR(5) for additional restrictions which apply when changing to UID 0. .RE .SH USAGE .sp .LP If a set-user-\fBID\fR process sets its effective user \fBID\fR to its real user \fBID\fR, it can still set its effective user \fBID\fR back to the saved set-user \fBID\fR. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Standard .TE .SH SEE ALSO .sp .LP \fBexec\fR(2), \fBgetuid\fR(2), \fBsetregid\fR(2), \fBsetuid\fR(2), \fBattributes\fR(5), \fBprivileges\fR(5), \fBstandards\fR(5)