158273Smckusick.\" Copyright (c) 1980, 1991 The Regents of the University of California. 258273Smckusick.\" All rights reserved. 358273Smckusick.\" 458273Smckusick.\" %sccs.include.redist.man% 558273Smckusick.\" 6*58274Smckusick.\" @(#)setregid.2 6.2 (Berkeley) 02/26/93 758273Smckusick.\" 858273Smckusick.Dd 958273Smckusick.Dt SETREGID 2 10*58274Smckusick.Os BSD 4.2 1158273Smckusick.Sh NAME 1258273Smckusick.Nm setregid 13*58274Smckusick.Nd set real and effective group ID 1458273Smckusick.Sh SYNOPSIS 1558273Smckusick.Fd #include <unistd.h> 1658273Smckusick.Ft int 1758273Smckusick.Fn setregid "int rgid" "int egid" 1858273Smckusick.Sh DESCRIPTION 19*58274SmckusickThe real and effective group ID's of the current process 20*58274Smckusickare set to the arguments. 21*58274SmckusickUnprivileged users may change the real group 22*58274SmckusickID to the effective group ID and vice-versa; only the super-user may 23*58274Smckusickmake other changes. 2458273Smckusick.Pp 25*58274SmckusickSupplying a value of -1 for either the real or effective 26*58274Smckusickgroup ID forces the system to substitute the current 27*58274SmckusickID in place of the -1 parameter. 28*58274Smckusick.Pp 29*58274SmckusickThe 30*58274Smckusick.Fn setregid function was intended to allow swapping 31*58274Smckusickthe real and effective group IDs 32*58274Smckusickin set-group-ID programs to temporarily relinquish the set-group-ID value. 33*58274SmckusickThis function did not work correctly, 34*58274Smckusickand its purpose is now better served by the use of the 35*58274Smckusick.Fn setegid 36*58274Smckusickfunction (see 37*58274Smckusick.Xr setuid 2 ) . 38*58274Smckusick.Pp 39*58274SmckusickWhen setting the real and effective group IDs to the same value, 40*58274Smckusickthe standard 41*58274Smckusick.Fn setgid 42*58274Smckusickfunction is preferred. 4358273Smckusick.Sh RETURN VALUES 4458273SmckusickUpon successful completion, a value of 0 is returned. Otherwise, 4558273Smckusicka value of -1 is returned and 4658273Smckusick.Va errno 4758273Smckusickis set to indicate the error. 4858273Smckusick.Sh ERRORS 4958273Smckusick.Bl -tag -width [EPERM] 5058273Smckusick.It Bq Er EPERM 5158273SmckusickThe current process is not the super-user and a change 5258273Smckusickother than changing the effective group-id to the real group-id 53*58274Smckusickwas specified. 5458273Smckusick.El 5558273Smckusick.Sh SEE ALSO 5658273Smckusick.Xr getgid 2 , 5758273Smckusick.Xr setegid 2 , 5858273Smckusick.Xr setgid 2 5958273Smckusick.Sh HISTORY 6058273SmckusickThe 6158273Smckusick.Nm 6258273Smckusickfunction call appeared in 6358273Smckusick.Bx 4.2 6458273Smckusickand was dropped in 6558273Smckusick.Bx 4.4 . 66