#include "includes.h"
#include "lib/util/debug.h"
-#include "popt_common.h"
-#include "popt_common_cmdline.h"
+#include "lib/cmdline/cmdline.h"
#include "lib/cmdline_contexts.h"
#include "param.h"
-#include "auth_info.h"
#include "client.h"
#include "libsmb/proto.h"
#include "librpc/rpc/rpc_common.h"
static char *opt_path;
static int opt_live;
-static struct poptOption long_options[] = {
- POPT_AUTOHELP
- {
- .longName = "path",
- .shortName = 'p',
- .argInfo = POPT_ARG_STRING,
- .arg = &opt_path,
- .descrip = "Server-relative search path",
- },
- {
- .longName = "live",
- .shortName = 'L',
- .argInfo = POPT_ARG_NONE,
- .arg = &opt_live,
- .descrip = "live query",
- },
- POPT_COMMON_SAMBA
- POPT_COMMON_CREDENTIALS
- POPT_TABLEEND
-};
-
int main(int argc, char **argv)
{
const char **const_argv = discard_const_p(const char *, argv);
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev = NULL;
- struct user_auth_info *auth = NULL;
struct cli_credentials *creds = NULL;
struct rpc_pipe_client *rpccli = NULL;
struct mdscli_ctx *mdscli_ctx = NULL;
struct cli_state *cli = NULL;
char *basepath = NULL;
uint32_t flags = CLI_FULL_CONNECTION_IPC;
- int signing_state = SMB_SIGNING_IPC_DEFAULT;
uint64_t *cnids = NULL;
size_t ncnids;
size_t i;
NTSTATUS status;
bool ok;
- setup_logging(argv[0], DEBUG_STDERR);
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {
+ .longName = "path",
+ .shortName = 'p',
+ .argInfo = POPT_ARG_STRING,
+ .arg = &opt_path,
+ .descrip = "Server-relative search path",
+ },
+ {
+ .longName = "live",
+ .shortName = 'L',
+ .argInfo = POPT_ARG_NONE,
+ .arg = &opt_live,
+ .descrip = "live query",
+ },
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CREDENTIALS
+ POPT_LEGACY_S3
+ POPT_COMMON_VERSION
+ POPT_TABLEEND
+ };
+
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);
+ }
lp_set_cmdline("log level", "1");
- pc = poptGetContext(argv[0],
- argc,
- const_argv,
- long_options,
- POPT_CONTEXT_KEEP_FIRST);
+ pc = samba_popt_get_context(getprogname(),
+ argc,
+ const_argv,
+ long_options,
+ POPT_CONTEXT_KEEP_FIRST);
poptSetOtherOptionHelp(pc, "mdsearch [OPTIONS] <server> <share> <query>\n");
goto fail;
}
- popt_burn_cmdline_password(argc, argv);
+ samba_cmdline_burn(argc, argv);
if ((server[0] == '/' && server[1] == '/') ||
(server[0] == '\\' && server[1] == '\\'))
server += 2;
}
- auth = popt_get_cmdline_auth_info();
- creds = get_cmdline_auth_info_creds(auth);
-
- signing_state = get_cmdline_auth_info_signing_state(auth);
- switch (signing_state) {
- case SMB_SIGNING_OFF:
- lp_set_cmdline("client ipc signing", "no");
- break;
- case SMB_SIGNING_REQUIRED:
- lp_set_cmdline("client ipc signing", "required");
- break;
- }
-
ev = samba_tevent_context_init(frame);
if (ev == NULL) {
goto fail;
cmdline_messaging_context(get_dyn_CONFIGFILE());
- ok = lp_load_client(get_dyn_CONFIGFILE());
- if (!ok) {
- fprintf(stderr, "ERROR: Can't load %s\n",
- get_dyn_CONFIGFILE());
- exit(1);
- }
+ creds = samba_cmdline_get_creds();
status = cli_full_connection_creds(&cli,
lp_netbios_name(),