.\" Copyright (c) 1983, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setregid.2 6.4 (Berkeley) 3/10/91 .\" .\" Modified Sat Jul 24 09:08:49 1993 by Rik Faith .\" Portions extracted from linux/kernel/sys.c: .\" Copyright (C) 1991, 1992 Linus Torvalds .\" May be distributed under the GNU General Public License .\" Changes: Fri Jul 29 10:56:01 BST 1994 by Wilf. .\" Tue Aug 2 14:56:48 BST 1994 by Wilf due to change in kernel. .\" .TH SETREUID 2 "2nd August 1994" "Linux 1.1.38" "Linux Programmer's Manual" .SH NAME setreuid, seteuid \- set real and / or effective user ID .SH SYNOPSIS .B #include .sp .BI "int setreuid(uid_t " ruid ", uid_t " euid ); .br .BI "int seteuid(uid_t " euid ); .SH DESCRIPTION .B setreuid sets real and effective user ID's of the current process. Un-privileged users may change the real user ID to the effective user ID and vice-versa. Prior to Linux 1.1.37, the saved ID paradigm, when used with .B setreuid or .B seteuid was broken. Starting at 1.1.37, it is also possible to set the effective user ID from the saved user ID. Only the super-user may make other changes. Supplying a value of \-1 for either the real or effective user ID forces the system to leave that ID unchanged. Currently .BI seteuid( euid ) is functionally equivalent to .BI setreuid( -1 , " euid" ) \fR. If the real user ID is changed or the effective user ID is set to a value not equal to the previous real user ID, the saved user ID will be set to the new effective user ID. .SH "RETURN VALUE" On success, zero is returned. On error, \-1 is returned, and .I errno is set appropriately. .SH ERRORS .TP .B EPERM The current process is not the super-user and changes other than (i) swapping the effective user ID with the real user ID or (ii) setting one to the value of the other or (iii) setting the effective user ID to the value of the saved user ID was specified. .SH "CONFORMING TO" BSD 4.3 (the .B setreuid function call first appeared in 4.2BSD.) .SH "SEE ALSO" .BR getuid "(2), " setuid (2)