1.\" Copyright (c) 1980, 1991, 1993, 1994 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)setregid.2 8.2 (Berkeley) 04/16/94 7.\" 8.Dd 9.Dt SETREGID 2 10.Os BSD 4.2 11.Sh NAME 12.Nm setregid 13.Nd set real and effective group ID 14.Sh SYNOPSIS 15.Fd #include <unistd.h> 16.Ft int 17.Fn setregid "gid_t rgid" "gid_t egid" 18.Sh DESCRIPTION 19The real and effective group ID's of the current process 20are set to the arguments. 21Unprivileged users may change the real group 22ID to the effective group ID and vice-versa; only the super-user may 23make other changes. 24.Pp 25Supplying a value of -1 for either the real or effective 26group ID forces the system to substitute the current 27ID in place of the -1 parameter. 28.Pp 29The 30.Fn setregid 31function was intended to allow swapping 32the real and effective group IDs 33in set-group-ID programs to temporarily relinquish the set-group-ID value. 34This function did not work correctly, 35and its purpose is now better served by the use of the 36.Fn setegid 37function (see 38.Xr setuid 2 ) . 39.Pp 40When setting the real and effective group IDs to the same value, 41the standard 42.Fn setgid 43function is preferred. 44.Sh RETURN VALUES 45Upon successful completion, a value of 0 is returned. Otherwise, 46a value of -1 is returned and 47.Va errno 48is set to indicate the error. 49.Sh ERRORS 50.Bl -tag -width [EPERM] 51.It Bq Er EPERM 52The current process is not the super-user and a change 53other than changing the effective group-id to the real group-id 54was specified. 55.El 56.Sh SEE ALSO 57.Xr getgid 2 , 58.Xr setegid 2 , 59.Xr setgid 2 , 60.Xr setuid 2 61.Sh HISTORY 62The 63.Nm 64function call appeared in 65.Bx 4.2 66and was dropped in 67.Bx 4.4 . 68