{get,set}hostid moves in from sys
[unix-history] / usr / src / lib / libc / compat-43 / setregid.2
CommitLineData
72216950
KM
1.\" Copyright (c) 1980, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
be5173a0 6.\" @(#)setregid.2 6.3 (Berkeley) %G%
72216950
KM
7.\"
8.Dd
9.Dt SETREGID 2
2c4cf55f 10.Os BSD 4.2
72216950
KM
11.Sh NAME
12.Nm setregid
2c4cf55f 13.Nd set real and effective group ID
72216950
KM
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn setregid "int rgid" "int egid"
18.Sh DESCRIPTION
2c4cf55f
KM
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.
72216950 24.Pp
2c4cf55f
KM
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 function was intended to allow swapping
31the real and effective group IDs
32in set-group-ID programs to temporarily relinquish the set-group-ID value.
33This function did not work correctly,
34and its purpose is now better served by the use of the
35.Fn setegid
36function (see
37.Xr setuid 2 ) .
38.Pp
39When setting the real and effective group IDs to the same value,
40the standard
41.Fn setgid
42function is preferred.
72216950
KM
43.Sh RETURN VALUES
44Upon successful completion, a value of 0 is returned. Otherwise,
45a value of -1 is returned and
46.Va errno
47is set to indicate the error.
48.Sh ERRORS
49.Bl -tag -width [EPERM]
50.It Bq Er EPERM
51The current process is not the super-user and a change
52other than changing the effective group-id to the real group-id
2c4cf55f 53was specified.
72216950
KM
54.El
55.Sh SEE ALSO
56.Xr getgid 2 ,
57.Xr setegid 2 ,
be5173a0
KM
58.Xr setgid 2 ,
59.Xr setuid 2
72216950
KM
60.Sh HISTORY
61The
62.Nm
63function call appeared in
64.Bx 4.2
65and was dropped in
66.Bx 4.4 .