| 12 | #include <sys/prctl.h> |
| 13 | |
| 14 | static unsigned long long status_capability(const char *field) { |
| 15 | FILE *status = fopen("/proc/self/status", "r"); |
| 16 | if (status == NULL) { |
| 17 | perror("fopen(/proc/self/status)"); |
| 18 | exit(EXIT_FAILURE); |
| 19 | } |
| 20 | |
| 21 | char line[256]; |
| 22 | unsigned long long value = 0; |
| 23 | int found = 0; |
| 24 | while (fgets(line, sizeof(line), status) != NULL) { |
| 25 | char name[32]; |
| 26 | unsigned long long candidate; |
| 27 | if (sscanf(line, "%31[^:]:%llx", name, &candidate) == 2 && |
| 28 | strcmp(name, field) == 0) { |
| 29 | value = candidate; |
| 30 | found = 1; |
| 31 | break; |
| 32 | } |
| 33 | } |
| 34 | fclose(status); |
| 35 | |
| 36 | if (!found) { |
| 37 | fprintf(stderr, "missing %s in /proc/self/status\n", field); |
| 38 | exit(EXIT_FAILURE); |
| 39 | } |
| 40 | return value; |
| 41 | } |
| 42 | |
| 43 | static void print_apparmor_profile(void) { |
| 44 | FILE *profile = fopen("/proc/self/attr/current", "r"); |