blob: 9f7062eb45d6a12d4458d06d667f99d689e663e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <stdio.h>
#include <stdlib.h>
#include <sys/capability.h>
#include "execable.h"
static void usage(int status)
{
printf("\nusage: libcap.so [--help|--usage|--summary]\n");
exit(status);
}
static void summary(void)
{
cap_value_t bits = cap_max_bits(), c;
cap_mode_t mode = cap_get_mode();
printf("\nCurrent mode: %s\n", cap_mode_name(mode));
printf("Number of cap values known to: this libcap=%d, running kernel=%d\n",
CAP_LAST_CAP+1, bits);
if (bits > CAP_LAST_CAP+1) {
printf("=> Consider upgrading libcap to name:");
for (c = CAP_LAST_CAP+1; c < bits; c++) {
printf(" %d", c);
}
} else if (bits < CAP_LAST_CAP+1) {
printf("=> Newer kernels also provide support for:");
for (c = bits; c <= CAP_LAST_CAP; c++) {
char *name = cap_to_name(c);
printf(" %s", name);
cap_free(name);
}
} else {
return;
}
printf("\n");
}
SO_MAIN(int argc, char **argv)
{
int i;
const char *cmd = "This library";
if (argv != NULL && argv[0] != NULL) {
cmd = argv[0];
}
printf("%s is the shared library version: " LIBRARY_VERSION ".\n"
"See the License file for distribution information.\n"
"More information on this library is available from:\n"
"\n"
" https://sites.google.com/site/fullycapable/\n", cmd);
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--usage") || !strcmp(argv[i], "--help")) {
usage(0);
}
if (!strcmp(argv[i], "--summary")) {
summary();
continue;
}
usage(1);
}
}
|