Dmitry V. Levin
530bed0ca8
Convert parsers of these syscalls to the same scheme as were applied to parsers of other uid/gid related syscalls. That is, define two sets of parsers on architectures that support (either directly or via multiarch) 16-bit and 32-bit gid getgroups and setgroups syscalls simultaneously, and reuse essentially the same code by parametrizing uid_t and names of parser functions. * groups.c: Remove. (sys_getgroups, sys_setgroups): Move ... * uid.c: ... here and parametrize their names. * Makefile.am (strace_SOURCES): Remove groups.c. * linux/syscall.h (sys_getgroups32, sys_setgroups32): Remove. [NEED_UID16_PARSERS] (sys_getgroups16, sys_setgroups16): New prototypes. * linux/arm/syscallent.h: Rename sys_[gs]etgroups to sys_[gs]etgroups16, rename sys_[gs]etgroups32 to sys_[gs]etgroups. * linux/bfin/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * tests/uid.c: Test for getgroups. * tests/uid16.c: Likewise. * tests/uid32.c: Test for getgroups32. * tests/uid.awk: Test for getgroups/getgroups32 decoding. * tests/uid.test: Trace getgroups/getgroups32 syscalls.
54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <sys/syscall.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
#if defined(__NR_getuid) \
|
|
&& defined(__NR_setuid) \
|
|
&& defined(__NR_getresuid) \
|
|
&& defined(__NR_setreuid) \
|
|
&& defined(__NR_setresuid) \
|
|
&& defined(__NR_chown) \
|
|
&& defined(__NR_getgroups) \
|
|
\
|
|
&& defined(__NR_getuid32) \
|
|
&& defined(__NR_setuid32) \
|
|
&& defined(__NR_getresuid32) \
|
|
&& defined(__NR_setreuid32) \
|
|
&& defined(__NR_setresuid32) \
|
|
&& defined(__NR_chown32) \
|
|
&& defined(__NR_getgroups32) \
|
|
\
|
|
&& __NR_getuid != __NR_getuid32 \
|
|
&& __NR_setuid != __NR_setuid32 \
|
|
&& __NR_getresuid != __NR_getresuid32 \
|
|
&& __NR_setreuid != __NR_setreuid32 \
|
|
&& __NR_setresuid != __NR_setresuid32 \
|
|
&& __NR_chown != __NR_chown32 \
|
|
&& __NR_getgroups != __NR_getgroups32 \
|
|
/**/
|
|
int r, e, s;
|
|
int size;
|
|
int *list = 0;
|
|
|
|
e = syscall(__NR_getuid);
|
|
assert(syscall(__NR_setuid, e) == 0);
|
|
assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
|
|
assert(syscall(__NR_setreuid, -1, 0xffff) == 0);
|
|
assert(syscall(__NR_setresuid, -1, e, 0xffff) == 0);
|
|
assert(syscall(__NR_chown, ".", -1, 0xffff) == 0);
|
|
assert((size = syscall(__NR_getgroups, 0, list)) >= 0);
|
|
assert(list = calloc(size + 1, sizeof(*list)));
|
|
assert(syscall(__NR_getgroups, size, list) == size);
|
|
return 0;
|
|
#else
|
|
return 77;
|
|
#endif
|
|
}
|