From e652f542e07f7562db9fa8620e39bcc9e2ebe777 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 13 Jan 2021 14:04:04 +0100 Subject: [PATCH] s3:utils: Migrate smbcacls to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- source3/utils/smbcacls.c | 43 +++++++++++++++++++++---------------- source3/utils/wscript_build | 2 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index e2dfcccddd7..a2d6b6c849d 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -23,7 +23,7 @@ */ #include "includes.h" -#include "popt_common_cmdline.h" +#include "lib/cmdline/cmdline.h" #include "rpc_client/cli_pipe.h" #include "../librpc/gen_ndr/ndr_lsa.h" #include "rpc_client/cli_lsarpc.h" @@ -1572,6 +1572,7 @@ int main(int argc, char *argv[]) struct cli_credentials *creds = NULL; char *targetfile = NULL; NTSTATUS status; + bool ok; struct poptOption long_options[] = { POPT_AUTOHELP @@ -1693,15 +1694,6 @@ int main(int argc, char *argv[]) .val = 0, .descrip = "Domain SID for sddl", .argDescrip = "SID"}, - { - .longName = "max-protocol", - .shortName = 'm', - .argInfo = POPT_ARG_STRING, - .arg = NULL, - .val = 'm', - .descrip = "Set the max protocol level", - .argDescrip = "LEVEL", - }, { .longName = "maximum-access", .shortName = 'x', @@ -1713,6 +1705,8 @@ int main(int argc, char *argv[]) POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS + POPT_LEGACY_S3 + POPT_COMMON_VERSION POPT_TABLEEND }; @@ -1723,15 +1717,29 @@ int main(int argc, char *argv[]) smb_init_locale(); + 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); + } /* set default debug level to 1 regardless of what smb.conf sets */ - setup_logging( "smbcacls", DEBUG_STDERR); lp_set_cmdline("log level", "1"); setlinebuf(stdout); - popt_common_credentials_set_ignore_missing_conf(); - - pc = poptGetContext("smbcacls", argc, argv_const, long_options, 0); + pc = samba_popt_get_context(getprogname(), + argc, + argv_const, + long_options, + 0); + if (pc == NULL) { + DBG_ERR("Failed to setup popt context!\n"); + TALLOC_FREE(frame); + exit(1); + } poptSetOtherOptionHelp(pc, "//server1/share1 filename\nACLs look like: " "'ACL:user:[ALLOWED|DENIED]/flags/permissions'"); @@ -1806,8 +1814,7 @@ int main(int argc, char *argv[]) } poptFreeContext(pc); - popt_burn_cmdline_password(argc, argv); - popt_common_credentials_post(); + samba_cmdline_burn(argc, argv); string_replace(path,'/','\\'); @@ -1824,7 +1831,7 @@ int main(int argc, char *argv[]) *share = 0; share++; - creds = get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); + creds = samba_cmdline_get_creds(); /* Make connection to server */ if (!test_args) { @@ -1833,7 +1840,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILED); } } else { - popt_free_cmdline_auth_info(); exit(0); } @@ -1886,7 +1892,6 @@ int main(int argc, char *argv[]) result = cacl_dump(targetcli, targetfile, numeric); } - popt_free_cmdline_auth_info(); TALLOC_FREE(frame); return result; diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index 68563f90444..8d4616e50f7 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -74,7 +74,7 @@ bld.SAMBA3_BINARY('smbcacls', source='smbcacls.c ../lib/util_sd.c', deps=''' talloc - popt_samba3_cmdline + CMDLINE_S3 msrpc3 libcli_lsa3 krb5samba''') -- 2.47.3