diff options
Diffstat (limited to 'source4/lib/ldb/tools')
-rw-r--r-- | source4/lib/ldb/tools/cmdline.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 1fd14d1739..de24475f6e 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -33,6 +33,8 @@ #include "db_wrap.h" #endif + + /* process command line options */ @@ -47,6 +49,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const #endif int num_options = 0; int opt; + int flags = 0; + struct poptOption popt_options[] = { POPT_AUTOHELP { "url", 'H', POPT_ARG_STRING, &options.url, 0, "database URL", "URL" }, @@ -194,29 +198,32 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const goto failed; } - if (strcmp(ret->url, "NONE") != 0) { - int flags = 0; - if (options.nosync) { - flags |= LDB_FLG_NOSYNC; - } + if (strcmp(ret->url, "NONE") == 0) { + return ret; + } -#ifdef _SAMBA_BUILD_ - /* Must be after we have processed command line options */ - gensec_init(); + if (options.nosync) { + flags |= LDB_FLG_NOSYNC; + } - if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { - goto failed; - } - if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { - goto failed; - } - ldb_set_utf8_fns(ldb, NULL, wrap_casefold); +#ifdef _SAMBA_BUILD_ + /* Must be after we have processed command line options */ + gensec_init(); + + if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { + goto failed; + } + if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { + goto failed; + } + ldb_set_utf8_fns(ldb, NULL, wrap_casefold); #endif - if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { - fprintf(stderr, "Failed to connect to %s - %s\n", - ret->url, ldb_errstring(ldb)); - goto failed; - } + + /* now connect to the ldb */ + if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { + fprintf(stderr, "Failed to connect to %s - %s\n", + ret->url, ldb_errstring(ldb)); + goto failed; } return ret; |