1setregid(2) System Calls setregid(2)
2
3
4
6 setregid - set real and effective group IDs
7
9 #include <unistd.h>
10
11 int setregid(gid_t rgid, gid_t egid);
12
13
15 The setregid() function is used to set the real and effective group IDs
16 of the calling process. If rgid is −1, the real group ID is not
17 changed; if egid is −1, the effective group ID is not changed. The
18 real and effective group IDs may be set to different values in the same
19 call.
20
21
22 If the {PRIV_PROC_SETID} privilege is asserted in the effective set of
23 the calling process, the real group ID and the effective group ID can
24 be set to any legal value.
25
26
27 If the {PRIV_PROC_SETID} privilege is not asserted in the effective set
28 of the calling process, either the real group ID can be set to the
29 saved set-group-ID from execve(2), or the effective group ID can either
30 be set to the saved set-group-ID or the real group ID.
31
32
33 In either case, if the real group ID is being changed (that is, if rgid
34 is not −1), or the effective group ID is being changed to a value not
35 equal to the real group ID, the saved set-group-ID is set equal to the
36 new effective group ID.
37
39 Upon successful completion, 0 is returned. Otherwise, −1 is returned,
40 errno is set to indicate the error, and neither of the group IDs will
41 be changed.
42
44 The setregid() function will fail if:
45
46 EINVAL The value of rgid or egid is less than 0 or greater than
47 UID_MAX (defined in <limits.h>).
48
49
50 EPERM The {PRIV_PROC_SETID} privilege is not asserted in the effec‐
51 tive set of the calling processes and a change was specified
52 other than changing the real group ID to the saved set-group-
53 ID or changing the effective group ID to the real group ID or
54 the saved group ID.
55
56
58 If a set-group-ID process sets its effective group ID to its real group
59 ID, it can still set its effective group ID back to the saved set-
60 group-ID.
61
63 See attributes(5) for descriptions of the following attributes:
64
65
66
67
68 ┌─────────────────────────────┬─────────────────────────────┐
69 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
70 ├─────────────────────────────┼─────────────────────────────┤
71 │Interface Stability │Standard │
72 └─────────────────────────────┴─────────────────────────────┘
73
75 execve(2), getgid(2), setreuid(2), setuid(2), attributes(5), privi‐
76 leges(5), standards(5)
77
78
79
80SunOS 5.11 22 Mar 2004 setregid(2)