blob: 5687dabde3a0cd5e4289ff42cb2578c82405b9b2 [file] [log] [blame]
Dmitry V. Levin1da7c952014-12-13 18:24:13 +00001#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4#include <assert.h>
Dmitry V. Levin530bed02014-12-14 13:30:54 +00005#include <stdlib.h>
Dmitry V. Levin1da7c952014-12-13 18:24:13 +00006#include <unistd.h>
7#include <sys/syscall.h>
8
9int
10main(void)
11{
12#if defined(__NR_getuid) \
13 && defined(__NR_setuid) \
14 && defined(__NR_getresuid) \
15 && defined(__NR_setreuid) \
16 && defined(__NR_setresuid) \
Dmitry V. Levin530bed02014-12-14 13:30:54 +000017 && defined(__NR_chown) \
18 && defined(__NR_getgroups)
19 int r, e, s;
20 int size;
21 int *list = 0;
Dmitry V. Levin1da7c952014-12-13 18:24:13 +000022
23 e = syscall(__NR_getuid);
24 assert(syscall(__NR_setuid, e) == 0);
25 assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
26 assert(syscall(__NR_setreuid, -1, -1L) == 0);
27 assert(syscall(__NR_setresuid, -1, e, -1L) == 0);
28 assert(syscall(__NR_chown, ".", -1, -1L) == 0);
Dmitry V. Levin530bed02014-12-14 13:30:54 +000029 assert((size = syscall(__NR_getgroups, 0, list)) >= 0);
30 assert(list = calloc(size + 1, sizeof(*list)));
31 assert(syscall(__NR_getgroups, size, list) == size);
Dmitry V. Levin1da7c952014-12-13 18:24:13 +000032 return 0;
33#else
34 return 77;
35#endif
36}