summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2020-12-15 22:09:39 -0800
committerAndrew G. Morgan <morgan@kernel.org>2020-12-23 16:38:38 -0800
commit0799b36a415c081c35a6e8e0f2a6b739d574fbd5 (patch)
tree6acf5f2f70f6d53fb55787df33ce3a3f7f8c9d21 /progs
parent676ced165d907d58af903fba0a434ff69087bba6 (diff)
downloadlibcap2-0799b36a415c081c35a6e8e0f2a6b739d574fbd5.tar.gz
checkpoint
Diffstat (limited to 'progs')
-rw-r--r--progs/capsh.c8
-rw-r--r--progs/getcap.c10
-rw-r--r--progs/getpcaps.c7
3 files changed, 15 insertions, 10 deletions
diff --git a/progs/capsh.c b/progs/capsh.c
index 899f79c..5ea340b 100644
--- a/progs/capsh.c
+++ b/progs/capsh.c
@@ -912,7 +912,7 @@ int main(int argc, char *argv[], char *envp[])
} else {
usage:
printf("usage: %s [args ...]\n"
- " --help this message (or try 'man capsh')\n"
+ " --help, -h this message (or try 'man capsh')\n"
" --print display capability relevant state\n"
" --decode=xxx decode a hex string to a list of caps\n"
" --supports=xxx exit 1 if capability xxx unsupported\n"
@@ -948,8 +948,10 @@ int main(int argc, char *argv[], char *envp[])
" -- remaining arguments are for " SHELL "\n"
" (without -- [%s] will simply exit(0))\n",
argv[0], argv[0]);
-
- exit(strcmp("--help", argv[i]) != 0);
+ if (strcmp("--help", argv[1]) && strcmp("-h", argv[1])) {
+ exit(1);
+ }
+ exit(0);
}
}
diff --git a/progs/getcap.c b/progs/getcap.c
index 225207f..b4a9a60 100644
--- a/progs/getcap.c
+++ b/progs/getcap.c
@@ -23,14 +23,14 @@ static int verbose = 0;
static int recursive = 0;
static int namespace = 0;
-static void usage(void)
+static void usage(int ok)
{
fprintf(stderr,
"usage: getcap [-v] [-r] [-h] [-n] <filename> [<filename> ...]\n"
"\n"
"\tdisplays the capabilities on the queried file(s).\n"
);
- exit(1);
+ exit(!ok);
}
static int do_getcap(const char *fname, const struct stat *stbuf,
@@ -93,13 +93,15 @@ int main(int argc, char **argv)
case 'n':
namespace = 1;
break;
+ case 'h':
+ usage(1);
default:
- usage();
+ usage(0);
}
}
if (!argv[optind])
- usage();
+ usage(0);
for (i=optind; argv[i] != NULL; i++) {
struct stat stbuf;
diff --git a/progs/getpcaps.c b/progs/getpcaps.c
index 497abcd..5cd81af 100644
--- a/progs/getpcaps.c
+++ b/progs/getpcaps.c
@@ -18,10 +18,10 @@ static void usage(int exiter)
" This program displays the capabilities on the queried process(es).\n"
" The capabilities are displayed in the cap_from_text(3) format.\n\n"
" Optional arguments:\n"
-" --help or --usage display this message.\n"
+" --help, -h or --usage display this message.\n"
" --verbose use a more verbose output format.\n"
" --ugly or --legacy use the archaic legacy output format.\n\n"
-"[Copyright (c) 1997-8,2007,2019 Andrew G. Morgan <morgan@kernel.org>]\n"
+"[Copyright (c) 1997-8,2007,2019 Andrew G. Morgan <morgan@kernel.org>]\n"
);
exit(exiter);
}
@@ -40,7 +40,8 @@ int main(int argc, char **argv)
int pid;
cap_t cap_d;
- if (!strcmp(argv[0], "--help") || !strcmp(argv[0], "--usage")) {
+ if (!strcmp(argv[0], "--help") || !strcmp(argv[0], "--usage") ||
+ !strcmp(argv[0], "-h")) {
usage(0);
} else if (!strcmp(argv[0], "--verbose")) {
verbose = 1;