From f5491119ff7d422b1c0c311a50e30bec1c15296c Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Fri, 2 Jun 2017 15:19:26 -0400 Subject: [PATCH] bozo: do not fail silently on unknown bosserver options Instead of failing silently when the bosserver is started with an unknown option, print an error message and exit with a non-zero value. Continue to exit with 0 when the -help option is given to request the usage message. This change should help make bosserver startup failures more obvious when an unsupported option is specified. Example systemd status message: systemd[1]: Starting OpenAFS Server Service... bosserver[32308]: Unrecognized option: -bogus bosserver[32308]: Usage: bosserver [-noauth] .... systemd[1]: openafs-server.service: main process exited, code=exited, status=1/FAILURE Change-Id: I8717fb4a788fbcc3d1e2d271dd03511c5b504f10 Reviewed-on: https://gerrit.openafs.org/12630 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/bozo/bosserver.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index ddaae5d..f97745c 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -1002,6 +1002,13 @@ main(int argc, char **argv, char **envp) else { /* hack to support help flag */ + int ec; + if (strcmp(argv[code], "-help") == 0 || strcmp(argv[code], "-h") == 0) + ec = 0; /* It is not an error to ask for usage. */ + else { + printf("Unrecognized option: %s\n", argv[code]); + ec = 1; + } #ifndef AFS_NT40_ENV printf("Usage: bosserver [-noauth] [-log] " @@ -1028,7 +1035,7 @@ main(int argc, char **argv, char **envp) #endif fflush(stdout); - exit(0); + exit(ec); } } if (auditFileName) { -- 1.7.1