r24621: - deferr calling build_options();exit(0);
authorStefan Metzmacher <metze@samba.org>
Wed, 22 Aug 2007 12:06:27 +0000 (12:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:30:11 +0000 (12:30 -0500)
- use poptPrintUsage() to give the user more info

metze
(This used to be commit a95d9d1ef99d6a2f77a289f8d2011cae482821b1)

source3/nmbd/nmbd.c
source3/nsswitch/winbindd.c
source3/smbd/server.c

index 4f1dd93cae9c8f72ee13a5075873d50aeb67c32e..9c8c764763c601aab601f057b2f6f8eb8d7d64b0 100644 (file)
@@ -678,8 +678,9 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
                default:
-                       d_fprintf(stderr, "\nInvalid option %s: %s\n",
+                       d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
                                  poptBadOption(pc, 0), poptStrerror(opt));
+                       poptPrintUsage(pc, stderr, 0);
                        exit(1);
                }
        };
index f1283c5a838e81565961c015e0dcdb5a2c004567..56e20b78c72ea7936f8d44314b76e80050ce6432 100644 (file)
@@ -1017,8 +1017,9 @@ int main(int argc, char **argv, char **envp)
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
                default:
-                       d_fprintf(stderr, "\nInvalid option %s: %s\n",
+                       d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
                                  poptBadOption(pc, 0), poptStrerror(opt));
+                       poptPrintUsage(pc, stderr, 0);
                        exit(1);
                }
        }
@@ -1036,6 +1037,8 @@ int main(int argc, char **argv, char **envp)
                exit(1);
        }
 
+       poptFreeContext(pc);
+
        if (!override_logfile) {
                pstr_sprintf(logfile, "%s/log.winbindd", dyn_LOGFILEBASE);
                lp_set_logfile(logfile);
@@ -1167,8 +1170,6 @@ int main(int argc, char **argv, char **envp)
        messaging_register(winbind_messaging_context(), NULL,
                           MSG_DUMP_EVENT_LIST, winbind_msg_dump_event_list);
 
-       poptFreeContext(pc);
-
        netsamlogon_cache_init(); /* Non-critical */
        
        /* clear the cached list of trusted domains */
index 3bb60058acbc5434eaf07d96b8bf96591cf02f9c..8f6d9a38ac4d6631097fe51366c8a9e9d2901ac2 100644 (file)
@@ -818,6 +818,7 @@ extern void build_options(BOOL screen);
        const char *profile_level = NULL;
        int opt;
        poptContext pc;
+       BOOL print_build_options = False;
 
        enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
 
@@ -849,21 +850,25 @@ extern void build_options(BOOL screen);
 #endif
 
        pc = poptGetContext("smbd", argc, argv, long_options, 0);
-       
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt)  {
                case 'b':
-                       build_options(True); /* Display output to screen as well as debug */ 
-                       exit(0);
+                       print_build_options = True;
+                       break;
                default:
-                       d_fprintf(stderr, "\nInvalid option %s: %s\n",
+                       d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
                                  poptBadOption(pc, 0), poptStrerror(opt));
+                       poptPrintUsage(pc, stderr, 0);
                        exit(1);
                }
        }
-
        poptFreeContext(pc);
 
+       if (print_build_options) {
+               build_options(True); /* Display output to screen as well as debug */
+               exit(0);
+       }
+
 #ifdef HAVE_SETLUID
        /* needed for SecureWare on SCO */
        setluid(0);