bozo: do not fail silently on unknown bosserver options 30/12630/3
authorMichael Meffie <mmeffie@sinenomine.net>
Fri, 2 Jun 2017 19:19:26 +0000 (15:19 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 4 Jun 2017 17:14:24 +0000 (13:14 -0400)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/bozo/bosserver.c

index ddaae5d..f97745c 100644 (file)
@@ -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) {