Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 1 | #ifdef HAVE_CONFIG_H |
| 2 | # include "config.h" |
| 3 | #endif |
| 4 | #include <assert.h> |
Dmitry V. Levin | 530bed0 | 2014-12-14 13:30:54 +0000 | [diff] [blame^] | 5 | #include <stdlib.h> |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 6 | #include <unistd.h> |
| 7 | #include <sys/syscall.h> |
| 8 | |
| 9 | int |
| 10 | main(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. Levin | 530bed0 | 2014-12-14 13:30:54 +0000 | [diff] [blame^] | 17 | && defined(__NR_chown) \ |
| 18 | && defined(__NR_getgroups) |
| 19 | int r, e, s; |
| 20 | int size; |
| 21 | int *list = 0; |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 22 | |
| 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. Levin | 530bed0 | 2014-12-14 13:30:54 +0000 | [diff] [blame^] | 29 | 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. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 32 | return 0; |
| 33 | #else |
| 34 | return 77; |
| 35 | #endif |
| 36 | } |