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
|
/*
* $Id: getcap.c,v 1.1.2.2 2000/07/11 05:29:15 agmorgan Exp $
*
* Copyright (c) 1997 Andrew G. Morgan <morgan@linux.kernel.org>
*
* This displays the capabilities of a given file.
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/capability.h>
static void usage(void)
{
fprintf(stderr,
"usage: getcap <filename> [<filename> ...]\n"
"\n"
"\tdisplays the capabilities on the queried file(s).\n"
);
exit(1);
}
int main(int argc, char **argv)
{
char *result=NULL;
if (argc < 2) {
usage();
}
for ( ++argv; --argc > 0; ++argv ) {
ssize_t length;
cap_t cap_d;
cap_d = cap_get_file(argv[0]);
if (cap_d == NULL) {
fprintf(stderr,
"Failed to get capabilities for file `%s'\n"
" (%s)\n", argv[0], strerror(errno));
continue;
}
result = cap_to_text(cap_d, &length);
fprintf(stderr, "Capabilities for `%s': %s\n", *argv, result);
}
return 0;
}
|