strace/tests/caps.c
Dmitry V. Levin 4b9c68b9a3 Implement full decoding of 64-bit capabilities
Unlike v1 capabilities which are 32-bit, v2 and v3 are 64-bit, but
before this change only lower 32 capability bits were decoded for
v2 and v3.

* xlat/capabilities1.in: New file.
* capability.c: Define v2/v3 CAP_* constants.
Include xlat/capabilities1.h.
(get_cap_header): New function.
(print_cap_header): Update to use get_cap_header result.
(print_cap_data): Decoder higher capability bits for v2 and v3.
(sys_capget, sys_capset): Use get_cap_header, update print_cap_header
and print_cap_data calls.
* tests/caps.c: New file.
* tests/caps.awk: New file.
* tests/caps.test: New test.
* tests/Makefile.am (CHECK_PROGRAMS): Add caps.
(TESTS): Add caps.test.
(EXTRA_DIST): Add caps.awk.
2014-12-06 03:53:12 +00:00

20 lines
344 B
C

#include <errno.h>
extern int capget(int *, int *);
extern int capset(int *, const int *);
int
main(void)
{
int unused[6];
const int data[] = { 2, 4, 0, 8, 16, 0 };
const int v3 = 0x20080522;
int head[] = { v3, 0 };
if (capget(head, unused) || head[0] != v3 ||
capset(head, data) == 0 || errno != EPERM)
return 77;
return 0;
}