1*60986Sbostic.\" Copyright (c) 1980, 1991, 1993 2*60986Sbostic.\" The Regents of the University of California. All rights reserved. 358273Smckusick.\" 458273Smckusick.\" %sccs.include.redist.man% 558273Smckusick.\" 6*60986Sbostic.\" @(#)setregid.2 8.1 (Berkeley) 06/02/93 758273Smckusick.\" 858273Smckusick.Dd 958273Smckusick.Dt SETREGID 2 1058274Smckusick.Os BSD 4.2 1158273Smckusick.Sh NAME 1258273Smckusick.Nm setregid 1358274Smckusick.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 1958274SmckusickThe real and effective group ID's of the current process 2058274Smckusickare set to the arguments. 2158274SmckusickUnprivileged users may change the real group 2258274SmckusickID to the effective group ID and vice-versa; only the super-user may 2358274Smckusickmake other changes. 2458273Smckusick.Pp 2558274SmckusickSupplying a value of -1 for either the real or effective 2658274Smckusickgroup ID forces the system to substitute the current 2758274SmckusickID in place of the -1 parameter. 2858274Smckusick.Pp 2958274SmckusickThe 3058274Smckusick.Fn setregid function was intended to allow swapping 3158274Smckusickthe real and effective group IDs 3258274Smckusickin set-group-ID programs to temporarily relinquish the set-group-ID value. 3358274SmckusickThis function did not work correctly, 3458274Smckusickand its purpose is now better served by the use of the 3558274Smckusick.Fn setegid 3658274Smckusickfunction (see 3758274Smckusick.Xr setuid 2 ) . 3858274Smckusick.Pp 3958274SmckusickWhen setting the real and effective group IDs to the same value, 4058274Smckusickthe standard 4158274Smckusick.Fn setgid 4258274Smckusickfunction 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 5358274Smckusickwas specified. 5458273Smckusick.El 5558273Smckusick.Sh SEE ALSO 5658273Smckusick.Xr getgid 2 , 5758273Smckusick.Xr setegid 2 , 5858476Smckusick.Xr setgid 2 , 5958476Smckusick.Xr setuid 2 6058273Smckusick.Sh HISTORY 6158273SmckusickThe 6258273Smckusick.Nm 6358273Smckusickfunction call appeared in 6458273Smckusick.Bx 4.2 6558273Smckusickand was dropped in 6658273Smckusick.Bx 4.4 . 67