-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/I9rAACgkQrlYvE4MpobN+zwCdGxDegmmjmKVrFTnwofWgfYfq 9pYAoKlFL5uSJWFkFYg3yal+YgxYmhf4 =+SYb -----END PGP SIGNATURE-----
>From e7d1eacb93b76ad34320d14c4bfe7f8235d370e0 Mon Sep 17 00:00:00 2001 From: Dan Walsh <dwalsh@xxxxxxxxxx> Date: Tue, 24 Jan 2012 11:22:43 -0500 Subject: [PATCH 12/90] policycoreutils: restorecond: wrong options should exit with a non zero exit code. FIXME Add -h option to get usage command [SPLIT THIS INTO TWO PATCHES] NOT-Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> Acked-by: Dan Walsh <dwalsh@xxxxxxxxxx> --- policycoreutils/restorecond/restorecond.8 | 5 ++++- policycoreutils/restorecond/restorecond.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/policycoreutils/restorecond/restorecond.8 b/policycoreutils/restorecond/restorecond.8 index 4622d2b..bf8ec87 100644 --- a/policycoreutils/restorecond/restorecond.8 +++ b/policycoreutils/restorecond/restorecond.8 @@ -3,7 +3,7 @@ restorecond \- daemon that watches for file creation and then sets the default SELinux file context .SH "SYNOPSIS" -.B restorecond [\-d] [\-f restorecond_file ] [\-u] [\-v] +.B restorecond [\-d] [-h] [\-f restorecond_file ] [\-u] [\-v] .P .SH "DESCRIPTION" @@ -20,6 +20,9 @@ the correct file context associated with the policy. Turns on debugging mode. Application will stay in the foreground and lots of debugs messages start printing. .TP +. B \-h +Print usage statement. +.TP .B \-f restorecond_file Use alternative restorecond.conf file. .TP diff --git a/policycoreutils/restorecond/restorecond.c b/policycoreutils/restorecond/restorecond.c index dfd9629..1762850 100644 --- a/policycoreutils/restorecond/restorecond.c +++ b/policycoreutils/restorecond/restorecond.c @@ -121,7 +121,6 @@ static void term_handler() static void usage(char *program) { printf("%s [-d] [-f restorecond_file ] [-u] [-v] \n", program); - exit(0); } void exitApp(const char *msg) @@ -178,7 +177,7 @@ int main(int argc, char **argv) exclude_non_seclabel_mounts(); atexit( done ); - while ((opt = getopt(argc, argv, "df:uv")) > 0) { + while ((opt = getopt(argc, argv, "hdf:uv")) > 0) { switch (opt) { case 'd': debug_mode = 1; @@ -189,11 +188,16 @@ int main(int argc, char **argv) case 'u': run_as_user = 1; break; + case 'h': + usage(argv[0]); + exit(0); + break; case 'v': r_opts.verbose++; break; case '?': usage(argv[0]); + exit(-1); } } -- 1.7.10.2