/* * Test file to exercise the setcap/getcap system calls */ #include // includes /usr/include/linux/capability.h // which defines the cap_user_header_t and cap_user_data_t // typedefs and related data structures // sys/capability defines the lipcap data structures and // methods, but I did not try to decipher those API's #include #include #include main() { struct __user_cap_header_struct cap_header_data; cap_user_header_t cap_header = &cap_header_data; struct __user_cap_data_struct cap_data_data; cap_user_data_t cap_data = &cap_data_data; cap_header->pid = getpid(); cap_header->version = _LINUX_CAPABILITY_VERSION; if (capget(cap_header, cap_data) < 0) { perror("Failed capget"); exit(1); } printf("Cap data 0x%x, 0x%x, 0x%x\n", cap_data->effective, cap_data->permitted, cap_data->inheritable); }