Commit | Line | Data |
---|---|---|
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 |
19 | The real and effective group ID's of the current process |
20 | are set to the arguments. | |
21 | Unprivileged users may change the real group | |
22 | ID to the effective group ID and vice-versa; only the super-user may | |
23 | make other changes. | |
72216950 | 24 | .Pp |
2c4cf55f KM |
25 | Supplying a value of -1 for either the real or effective |
26 | group ID forces the system to substitute the current | |
27 | ID in place of the -1 parameter. | |
28 | .Pp | |
29 | The | |
30 | .Fn setregid function was intended to allow swapping | |
31 | the real and effective group IDs | |
32 | in set-group-ID programs to temporarily relinquish the set-group-ID value. | |
33 | This function did not work correctly, | |
34 | and its purpose is now better served by the use of the | |
35 | .Fn setegid | |
36 | function (see | |
37 | .Xr setuid 2 ) . | |
38 | .Pp | |
39 | When setting the real and effective group IDs to the same value, | |
40 | the standard | |
41 | .Fn setgid | |
42 | function is preferred. | |
72216950 KM |
43 | .Sh RETURN VALUES |
44 | Upon successful completion, a value of 0 is returned. Otherwise, | |
45 | a value of -1 is returned and | |
46 | .Va errno | |
47 | is set to indicate the error. | |
48 | .Sh ERRORS | |
49 | .Bl -tag -width [EPERM] | |
50 | .It Bq Er EPERM | |
51 | The current process is not the super-user and a change | |
52 | other than changing the effective group-id to the real group-id | |
2c4cf55f | 53 | was 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 |
61 | The | |
62 | .Nm | |
63 | function call appeared in | |
64 | .Bx 4.2 | |
65 | and was dropped in | |
66 | .Bx 4.4 . |