|
10 | 10 | #include <stdio.h> |
11 | 11 | #include <stdlib.h> |
12 | 12 | #include <sys/fsuid.h> |
| 13 | +#include <sys/syscall.h> |
13 | 14 |
|
14 | 15 | #include "tcb.h" |
15 | 16 | #include "attribute.h" |
@@ -160,6 +161,15 @@ static int ch_gid(gid_t gid, gid_t *save) |
160 | 161 | return (gid_t) setfsgid(gid) == gid; |
161 | 162 | } |
162 | 163 |
|
| 164 | +static int sys_setgroups(size_t size, const gid_t *list) |
| 165 | +{ |
| 166 | +#ifdef SYS_setgroups32 |
| 167 | + if (sizeof(*list) == 4) |
| 168 | + return syscall(SYS_setgroups32, size, list); |
| 169 | +#endif |
| 170 | + return syscall(SYS_setgroups, size, list); |
| 171 | +} |
| 172 | + |
163 | 173 | #define PRIV_MAGIC 0x1004000a |
164 | 174 | #define PRIV_MAGIC_NONROOT 0xdead000a |
165 | 175 |
|
@@ -200,7 +210,7 @@ int tcb_drop_priv_r(const char *name, struct tcb_privs *p) |
200 | 210 |
|
201 | 211 | p->number_of_groups = res; |
202 | 212 |
|
203 | | - if (setgroups(0, NULL) == -1) |
| 213 | + if (sys_setgroups(0, NULL) == -1) |
204 | 214 | return -1; |
205 | 215 | if (!ch_gid(shadow_gid, &p->old_gid)) |
206 | 216 | return -1; |
@@ -230,7 +240,7 @@ int tcb_gain_priv_r(struct tcb_privs *p) |
230 | 240 | return -1; |
231 | 241 | if (!ch_gid(p->old_gid, NULL)) |
232 | 242 | return -1; |
233 | | - if (setgroups(p->number_of_groups, p->grplist) == -1) |
| 243 | + if (sys_setgroups(p->number_of_groups, p->grplist) == -1) |
234 | 244 | return -1; |
235 | 245 |
|
236 | 246 | p->is_dropped = 0; |
|
0 commit comments