.\" 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 (faith@cs.unc.edu) .\" 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. (G.Wilford@ee.surrey.ac.uk) .\" Tue Aug 2 14:56:48 BST 1994 by Wilf due to changes in kernel. .\" .TH SETREGID 2 "2nd August 1994" "Linux 1.1.38" "Linux Programmer's Manual" .SH NAME setregid, setegid \- set real and / or effective group ID .SH SYNOPSIS .B #include .sp .BI "int setregid(gid_t " rgid ", gid_t " egid ); .br .BI "int setegid(gid_t " egid ); .SH DESCRIPTION .B setregid sets real and effective group ID's of the current process. Un-privileged users may change the real group ID to the effective group ID and vice-versa. Prior to Linux 1.1.38, the saved ID paradigm, when used with .B setregid or .B setegid was broken. Starting at 1.1.38, it is also possible to set the effective group 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 group ID forces the system to leave that ID unchanged. Currently (libc-4.x.x), .BI setegid( egid ) is functionally equivalent to .BI setregid( -1 , " egid" ). If the real group ID is changed or the effective group ID is set to a value not equal to the previous real group ID, the saved group ID will be set to the new effective group ID. .SH "RETURN VALUE" On success, zero is returned. On error, \-1 is returned, and .I errno is set appropriately. .SH ERRORS .TP 0.8i .TP .B EPERM The current process is not the super-user and changes other than (i) swapping the effective group ID with the real group ID or (ii) setting one to the value of the other or (iii) setting the effective group ID to the value of the saved group ID was specified. .SH HISTORY The .B setregid function call appeared in BSD 4.2. .SH "CONFORMING TO" BSD 4.3 .SH "SEE ALSO" .BR getgid "(2), " setgid (2)