1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

s3:utils: Migrate pdbedit to the new cmdline option parser

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2021-01-13 13:42:53 +01:00 committed by Andrew Bartlett
parent 95e82b5b5f
commit aff65c0754
2 changed files with 22 additions and 10 deletions

View 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) +

View File

@ -50,7 +50,7 @@ bld.SAMBA3_BINARY('pdbedit',
deps='''
talloc
smbconf
popt_samba3
CMDLINE_S3
cmdline_contexts
pdb
PASSWD_UTIL''')