smbtree: don't ignore unknown options
authorRalph Boehme <slow@samba.org>
Fri, 10 Sep 2021 05:13:48 +0000 (07:13 +0200)
committerJule Anger <janger@samba.org>
Mon, 13 Sep 2021 07:48:08 +0000 (07:48 +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>
(cherry picked from commit 5562674a2188d4e11fbdfcbed7bf1fba02af9e90)

source3/utils/smbtree.c

index 87ced2425658b545b71db205c269ed1c14d944b2..dc5220e5f8b4c6ce6f70c79b2d4dc85ba8ec2c93 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;