Fix clvmd return code for bad options.
PATCH 1/1 Fix clvmd return code for bad options.
We should return exit code 2 for unknown options.
Patch also adds standart --help oprion instead
of nonstandard (and getopt incomatible -?).
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=666991
Signed-off-by Milan Broz <[email protected]>
--- daemons/clvmd/clvmd.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-)
daemons/clvmd/clvmd.c +12 -6
@@ -20,6 +20,7 @@#include "clvmd-common.h" #include <pthread.h> +#include <getopt.h> #include "clvmd-comms.h" #include "clvm.h"
@@ -335,7 +336,7 @@ int main(int argc, char *argv[])struct local_client *newfd;struct utsname nodeinfo;struct lvm_startup_params lvm_params; -signed char opt; +int opt;int cmd_timeout =DEFAULT_CMD_TIMEOUT ;int start_timeout =0 ;if_type_t cluster_iface =IF_AUTO ;
@@ -346,19 +347,21 @@ int main(int argc, char *argv[])int clusterwide_opt =0 ;mode_t old_mask; +struct option longopts[] = { + {"help" ,0 ,0 ,'h' }, + {NULL ,0 ,0 ,0 } + }; +/* Deal with command-line arguments */ opterr =0 ; optind =0 ; -while ((opt =getopt (argc, argv,"?vVhfd::t:RST:CI:E:" )) !=EOF ) { +while ((opt =getopt_long (argc, argv,"vVhfd::t:RST:CI:E:" , + longopts,NULL )) !=-1 ) {switch (opt) {case 'h' :usage (argv[0 ], stdout);exit (0 ); -case '?' : -usage (argv[0 ], stderr); -exit (0 ); -case 'R' :check_permissions ();return refresh_clvmd (1 )==1 ?0 :1 ;
@@ -409,6 +412,9 @@ int main(int argc, char *argv[])exit (0 );break ; +default : +usage (argv[0 ], stderr); +exit (2 ); } }
Signature · 1 line
1.7.2.3
PATCH 1/1 Fix clvmd return code for bad options.
Quoted 3 lines · Milan Broz
We should return exit code 2 for unknown options.
Patch also adds standart --help oprion instead
of nonstandard (and getopt incomatible -?).
Ack.
Alasdair