smbtree: don't ignore unknown options
authorRalph Boehme <slow@samba.org>
Fri, 10 Sep 2021 05:13:48 +0000 (07:13 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 10 Sep 2021 15:10:30 +0000 (15:10 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14828

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/utils/smbtree.c

index 6e38b6eb5f2b6373ec6a15a40e2f1b5ace4ea0d0..4719640033a7e07ed3d4761f83f2b6cf45bdf4ce 100644 (file)
@@ -102,6 +102,7 @@ int main(int argc, char *argv[])
        struct smbc_dirent *dirent = NULL;
        bool ok;
        int ret, result = 1;
+       int opt;
        int debuglevel;
 
        /* Initialise samba stuff */
@@ -129,7 +130,16 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
-       while(poptGetNextOpt(pc) != -1);
+       while((opt = poptGetNextOpt(pc)) != -1) {
+               switch (opt) {
+               case POPT_ERROR_BADOPT:
+                       fprintf(stderr, "\nInvalid option %s: %s\n\n",
+                               poptBadOption(pc, 0), poptStrerror(opt));
+                       poptPrintUsage(pc, stderr, 0);
+                       exit(1);
+               }
+       }
+
        samba_cmdline_burn(argc, argv);
 
        debuglevel = DEBUGLEVEL;