]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: Migrate pdbedit to the new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 12:42:53 +0000 (13:42 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 May 2021 00:23:37 +0000 (00:23 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/utils/pdbedit.c
source3/utils/wscript_build

index 4c21b53062311353d647d71aba18b509c7109cb3..7d42b9def85c777e60a4dbccfabeec78ac742a8e 100644 (file)
@@ -21,7 +21,7 @@
 */
 
 #include "includes.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "../librpc/gen_ndr/samr.h"
 #include "../libcli/security/security.h"
 #include "passdb.h"
@@ -1069,6 +1069,7 @@ int main(int argc, const char **argv)
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
        poptContext pc;
+       bool ok;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
                {"list",        'L', POPT_ARG_NONE, &list_users, 0, "list all users", NULL},
@@ -1105,6 +1106,7 @@ int main(int argc, const char **argv)
                {"kickoff-time", 'K', POPT_ARG_STRING, &kickoff_time, 0, "set the kickoff time", NULL},
                {"set-nt-hash", 0, POPT_ARG_STRING, &str_hex_pwd, 0, "set password from nt-hash", NULL},
                POPT_COMMON_SAMBA
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
 
@@ -1112,10 +1114,25 @@ int main(int argc, const char **argv)
 
        smb_init_locale();
 
-       setup_logging("pdbedit", DEBUG_STDOUT);
+       ok = samba_cmdline_init(frame,
+                               SAMBA_CMDLINE_CONFIG_CLIENT,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
 
-       pc = poptGetContext(NULL, argc, argv, long_options,
-                           POPT_CONTEXT_KEEP_FIRST);
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   POPT_CONTEXT_KEEP_FIRST);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
 
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
@@ -1130,11 +1147,6 @@ int main(int argc, const char **argv)
        if (user_name == NULL)
                user_name = poptGetArg(pc);
 
-       if (!lp_load_global(get_dyn_CONFIGFILE())) {
-               fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
-               exit(1);
-       }
-
        setparms =      (backend ? BIT_BACKEND : 0) +
                        (verbose ? BIT_VERBOSE : 0) +
                        (spstyle ? BIT_SPSTYLE : 0) +
index b01d4d41b20c57b2050e68888a4525cb3bc11dd1..68563f90444d28eaf597aff3b6adcddd6bbc240a 100644 (file)
@@ -50,7 +50,7 @@ bld.SAMBA3_BINARY('pdbedit',
                  deps='''
                  talloc
                  smbconf
-                 popt_samba3
+                 CMDLINE_S3
                  cmdline_contexts
                  pdb
                  PASSWD_UTIL''')