1*66822Sbostic.\" Copyright (c) 1980, 1991, 1993, 1994 260986Sbostic.\" The Regents of the University of California. All rights reserved. 358273Smckusick.\" 458273Smckusick.\" %sccs.include.redist.man% 558273Smckusick.\" 6*66822Sbostic.\" @(#)setregid.2 8.2 (Berkeley) 04/16/94 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 17*66822Sbostic.Fn setregid "gid_t rgid" "gid_t 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 30*66822Sbostic.Fn setregid 31*66822Sbosticfunction was intended to allow swapping 3258274Smckusickthe real and effective group IDs 3358274Smckusickin set-group-ID programs to temporarily relinquish the set-group-ID value. 3458274SmckusickThis function did not work correctly, 3558274Smckusickand its purpose is now better served by the use of the 3658274Smckusick.Fn setegid 3758274Smckusickfunction (see 3858274Smckusick.Xr setuid 2 ) . 3958274Smckusick.Pp 4058274SmckusickWhen setting the real and effective group IDs to the same value, 4158274Smckusickthe standard 4258274Smckusick.Fn setgid 4358274Smckusickfunction is preferred. 4458273Smckusick.Sh RETURN VALUES 4558273SmckusickUpon successful completion, a value of 0 is returned. Otherwise, 4658273Smckusicka value of -1 is returned and 4758273Smckusick.Va errno 4858273Smckusickis set to indicate the error. 4958273Smckusick.Sh ERRORS 5058273Smckusick.Bl -tag -width [EPERM] 5158273Smckusick.It Bq Er EPERM 5258273SmckusickThe current process is not the super-user and a change 5358273Smckusickother than changing the effective group-id to the real group-id 5458274Smckusickwas specified. 5558273Smckusick.El 5658273Smckusick.Sh SEE ALSO 5758273Smckusick.Xr getgid 2 , 5858273Smckusick.Xr setegid 2 , 5958476Smckusick.Xr setgid 2 , 6058476Smckusick.Xr setuid 2 6158273Smckusick.Sh HISTORY 6258273SmckusickThe 6358273Smckusick.Nm 6458273Smckusickfunction call appeared in 6558273Smckusick.Bx 4.2 6658273Smckusickand was dropped in 6758273Smckusick.Bx 4.4 . 68