From f52b42c75fda1069664fdbedf392e4fca87d7fc0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 07:43:52 +0000 Subject: r7710: new command line handling code for ldb (This used to be commit 5e8db1c9b3bb6c5196652a7af877b4204148c305) --- source4/lib/ldb/tools/cmdline.c | 142 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 source4/lib/ldb/tools/cmdline.c (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c new file mode 100644 index 0000000000..a7bfac8bb4 --- /dev/null +++ b/source4/lib/ldb/tools/cmdline.c @@ -0,0 +1,142 @@ +/* + ldb database library - command line handling for ldb tools + + Copyright (C) Andrew Tridgell 2005 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" +#include "ldb/tools/cmdline.h" + +/* + process command line options +*/ +struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv, + void (*usage)(void)) +{ + struct ldb_cmdline options, *ret; + poptContext pc; + int num_options = 0; + char opt; + struct poptOption popt_options[] = { + POPT_AUTOHELP + { "url", 'H', POPT_ARG_STRING, &options.url, 0, "database URL", "URL" }, + { "basedn", 'b', POPT_ARG_STRING, &options.basedn, 0, "base DN", "DN" }, + { "editor", 'e', POPT_ARG_STRING, &options.editor, 0, "external editor", "PROGRAM" }, + { "scope", 's', POPT_ARG_STRING, NULL, 's', "search scope", "SCOPE" }, + { "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "increase verbosity", NULL }, + { "interactive", 'i', POPT_ARG_NONE, &options.interactive, 0, "input from stdin", NULL }, + { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL }, + { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, + { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, + { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, + { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, + { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, + POPT_TABLEEND + }; + + ret = talloc_zero(ldb, struct ldb_cmdline); + if (ret == NULL) { + ldb_oom(ldb); + goto failed; + } + + options = *ret; + + /* pull in URL */ + options.url = getenv("LDB_URL"); + + /* and editor (used by ldbedit) */ + options.editor = getenv("VISUAL"); + if (!options.editor) { + options.editor = getenv("EDITOR"); + } + if (!options.editor) { + options.editor = "vi"; + } + + pc = poptGetContext(argv[0], argc, argv, popt_options, + POPT_CONTEXT_KEEP_FIRST); + + while((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case 's': { + const char *arg = poptGetOptArg(pc); + if (strcmp(arg, "base") == 0) { + options.scope = LDB_SCOPE_BASE; + } else if (strcmp(arg, "sub") == 0) { + options.scope = LDB_SCOPE_SUBTREE; + } else if (strcmp(arg, "one") == 0) { + options.scope = LDB_SCOPE_ONELEVEL; + } else { + fprintf(stderr, "Invalid scope '%s'\n", arg); + goto failed; + } + break; + } + + case 'v': + options.verbose++; + break; + + case 'o': + options.options = talloc_realloc(ret, options.options, + const char *, num_options+2); + if (options.options == NULL) { + ldb_oom(ldb); + goto failed; + } + options.options[num_options++] = poptGetOptArg(pc); + options.options[num_options+1] = NULL; + break; + + default: + fprintf(stderr, "Invalid option %s: %s\n", + poptBadOption(pc, 0), poptStrerror(opt)); + if (usage) usage(); + goto failed; + } + } + + /* setup the remaining options for the main program to use */ + options.argv = poptGetArgs(pc); + if (options.argv) { + options.argv++; + while (options.argv[options.argc]) options.argc++; + } + + *ret = options; + + /* all utils need some option */ + if (ret->url == NULL) { + fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n"); + if (usage) usage(); + goto failed; + } + + return ret; + +failed: + talloc_free(ret); + exit(1); + return NULL; +} -- cgit From f40e69da2633771a42ec2b74fca63bd0b0a37e4a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 09:01:09 +0000 Subject: r7714: enable samba credentials handling in ldb tools. So you can now do a encrypted ldbedit against w2k3 (This used to be commit 6277c3923e7d9c26753424b1e77ac62f8e0729a4) --- source4/lib/ldb/tools/cmdline.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index a7bfac8bb4..1f4a7544a5 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -26,6 +26,9 @@ #include "ldb/include/ldb.h" #include "ldb/include/ldb_private.h" #include "ldb/tools/cmdline.h" +#ifdef _SAMBA_BUILD_ +#include "lib/cmdline/popt_common.h" +#endif /* process command line options @@ -50,10 +53,20 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, + { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, +#ifdef _SAMBA_BUILD_ + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION +#endif POPT_TABLEEND }; +#ifdef _SAMBA_BUILD_ + ldbsearch_init_subsystems; +#endif + ret = talloc_zero(ldb, struct ldb_cmdline); if (ret == NULL) { ldb_oom(ldb); @@ -74,6 +87,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const options.editor = "vi"; } + options.scope = LDB_SCOPE_DEFAULT; + pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); @@ -133,6 +148,12 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const goto failed; } + if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { + fprintf(stderr, "Failed to connect to %s - %s\n", + ret->url, ldb_errstring(ldb)); + goto failed; + } + return ret; failed: -- cgit From 5be159f304411b58c417a979c819f9ab211a0337 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Jun 2005 07:52:00 +0000 Subject: r7804: added the samba specific ldif handlers into the tree, but don't enable them just yet. I have tested them, and they work fine, but enabling them will break code in rpc_server/ and samdb, so we need to fix that first (This used to be commit 07d459406b4c63e49141e0e533e1274b4052abf9) --- source4/lib/ldb/tools/cmdline.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 1f4a7544a5..31d3f2662a 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -36,9 +36,9 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv, void (*usage)(void)) { - struct ldb_cmdline options, *ret; + struct ldb_cmdline options, *ret=NULL; poptContext pc; - int num_options = 0; + int r, num_options = 0; char opt; struct poptOption popt_options[] = { POPT_AUTOHELP @@ -65,6 +65,10 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const #ifdef _SAMBA_BUILD_ ldbsearch_init_subsystems; + r = ldb_register_samba_handlers(ldb); + if (r != 0) { + goto failed; + } #endif ret = talloc_zero(ldb, struct ldb_cmdline); -- cgit From 1603fd94666d3175e9df12652f9ff4e1d14de064 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 25 Jun 2005 03:43:33 +0000 Subject: r7897: work in progress (This used to be commit 8e1431efcf0df797bc50ef584c38fce6a03429b3) --- source4/lib/ldb/tools/cmdline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 31d3f2662a..606c511600 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -38,7 +38,10 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { struct ldb_cmdline options, *ret=NULL; poptContext pc; - int r, num_options = 0; +#ifdef _SAMBA_BUILD_ + int r; +#endif + int num_options = 0; char opt; struct poptOption popt_options[] = { POPT_AUTOHELP -- cgit From 6a7119fc83326b8243a1ce4598fe6b6c4b013e45 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Jun 2005 06:09:03 +0000 Subject: r7926: poptGetNextOpt() returns int, not char this was breaking ldbadd on some platforms (This used to be commit dd0ac3f68d709c0364d992673e76db73398c0369) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 606c511600..48dc8ddd47 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -42,7 +42,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const int r; #endif int num_options = 0; - char opt; + int opt; struct poptOption popt_options[] = { POPT_AUTOHELP { "url", 'H', POPT_ARG_STRING, &options.url, 0, "database URL", "URL" }, -- cgit From 3e4c4cff2177af33efdb15f03a1bbcb639505cee Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 15:02:01 +0000 Subject: r9391: Convert all the code to use struct ldb_dn to ohandle ldap like distinguished names Provide more functions to handle DNs in this form (This used to be commit 692e35b7797e39533dd2a1c4b63d9da30f1eb5ba) --- source4/lib/ldb/tools/cmdline.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 48dc8ddd47..7657301f35 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -57,6 +57,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, + { "input", 'I', POPT_ARG_STRING, &options.input, 0, "Input File", "Input" }, + { "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" }, { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, #ifdef _SAMBA_BUILD_ POPT_COMMON_SAMBA @@ -149,16 +151,18 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const *ret = options; /* all utils need some option */ - if (ret->url == NULL) { - fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n"); - if (usage) usage(); - goto failed; - } + if (ldb) { + if (ret->url == NULL) { + fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n"); + if (usage) usage(); + goto failed; + } - if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { - fprintf(stderr, "Failed to connect to %s - %s\n", - ret->url, ldb_errstring(ldb)); - goto failed; + if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { + fprintf(stderr, "Failed to connect to %s - %s\n", + ret->url, ldb_errstring(ldb)); + goto failed; + } } return ret; -- cgit From 5c16371daa9d496fe109ea30bd6cfa3fd863a219 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 21 Aug 2005 14:26:03 +0000 Subject: r9447: Add a new tool to convert openLdap schema files into an ldif My first test with nis.schema seem to confirm it works properly Use a command line like: oLschema2ldif -I tests/schema/nis.schema -O nis_schema.ldif -b "dc=sambadom,dc=samba,dc=org" to see how it works. SSS (This used to be commit fc373fd4631420c9d8d4087a2c698b08e18372d7) --- source4/lib/ldb/tools/cmdline.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 7657301f35..cde357a088 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -151,13 +151,13 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const *ret = options; /* all utils need some option */ - if (ldb) { - if (ret->url == NULL) { - fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n"); - if (usage) usage(); - goto failed; - } + if (ret->url == NULL) { + fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n"); + if (usage) usage(); + goto failed; + } + if (strcmp(ret->url, "NONE") != 0) { if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", ret->url, ldb_errstring(ldb)); -- cgit From 7e3838dd2d8647e9c621a08c61a2a22ef1d94bb2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 27 Aug 2005 15:13:15 +0000 Subject: r9685: Add tests for samba3sam mapping module Fix a couple of bugs Move samba3sam backend to lib/ldb/ Remove some more unused parameters (This used to be commit 7f864d446d6af7cfd9fb8dbc496a29b36ec57ce9) --- source4/lib/ldb/tools/cmdline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index cde357a088..fb0292b7d9 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -124,13 +124,14 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const case 'o': options.options = talloc_realloc(ret, options.options, - const char *, num_options+2); + const char *, num_options+3); if (options.options == NULL) { ldb_oom(ldb); goto failed; } - options.options[num_options++] = poptGetOptArg(pc); + options.options[num_options] = poptGetOptArg(pc); options.options[num_options+1] = NULL; + num_options++; break; default: -- cgit From d78ea3e34abd30fb388c4cc39e12611e211416a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Sep 2005 04:16:46 +0000 Subject: r10406: added --nosync option to all ldb tools, so that you can control if transactions are synchronous or not on the command line. add LDB_FLG_NOSYNC flag to ldb_connect() so we can make our temporary ldb databases non-synchronous (This used to be commit dba41164e0c52f1e4351bd9057b16661cee3a822) --- source4/lib/ldb/tools/cmdline.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index fb0292b7d9..7cdecc334f 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -55,6 +55,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, + { "nosync", 0, POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, { "input", 'I', POPT_ARG_STRING, &options.input, 0, "Input File", "Input" }, @@ -159,7 +160,11 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const } if (strcmp(ret->url, "NONE") != 0) { - if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { + int flags = 0; + if (options.nosync) { + flags |= LDB_FLG_NOSYNC; + } + 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; -- cgit From 1377cca5f4beb43cf67fcc65eed79f14178d6349 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Oct 2005 11:31:45 +0000 Subject: r10810: This adds the hooks required to communicate the current user from the authenticated session down into LDB. This associates a session info structure with the open LDB, allowing a future ldb_ntacl module to allow/deny operations on that basis. Along the way, I cleaned up a few things, and added new helper functions to assist. In particular the LSA pipe uses simpler queries for some of the setup. In ldap_server, I have removed the 'ldasrv:hacked' module, which hasn't been worked on (other than making it continue to compile) since January, and I think the features of this module are being put into ldb anyway. I have also changed the partitions in ldap_server to be initialised after the connection, with the private pointer used to associate the ldb with the incoming session. Andrew Bartlett (This used to be commit fd7203789a2c0929eecea8125b57b833a67fed71) --- source4/lib/ldb/tools/cmdline.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 7cdecc334f..642ad127d8 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -75,6 +75,11 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const if (r != 0) { goto failed; } + + if (ldb_set_opaque(ldb, "securityToken", system_session(ldb))) { + goto failed; + } + #endif ret = talloc_zero(ldb, struct ldb_cmdline); -- cgit From 0b1b8704bdb7c8a37738db722d3b2ac2d2a3e298 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 8 Oct 2005 07:41:57 +0000 Subject: r10830: we should use the same name in all places:-) metze (This used to be commit fbe8fd06b700b78f02b7f01fc2ad45eee419d216) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 642ad127d8..2428306f39 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -76,7 +76,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const goto failed; } - if (ldb_set_opaque(ldb, "securityToken", system_session(ldb))) { + if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { goto failed; } -- cgit From 36d73b0e71eb3fbbe8d660b7609806b0355bd09c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Oct 2005 11:00:16 +0000 Subject: r10894: make the handling of dn/distinguishedName much closer to real ldap. Also ensure we put a objectclass on our private ldb's, so they have some chance of being stored in ldap if you want to (This used to be commit 1af2cc067f70f6654d08387fc28def67229bb06a) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 2428306f39..ca9d3847e8 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -54,7 +54,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL }, { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, - { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, + { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "objectClass=*", NULL }, { "nosync", 0, POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, -- cgit From 0a1b8f58a212ed2ed2814b2e8a4845790f5f23e4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 1 Dec 2005 04:52:54 +0000 Subject: r11988: Setup the sessionInfo just before the connect, rather than earlier when we havn't finished popt. Andrew Bartlett (This used to be commit e5c5eb97a0ab841442b2c3fb5ea67f0d21b42932) --- source4/lib/ldb/tools/cmdline.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index ca9d3847e8..0be8951b9f 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -76,10 +76,6 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const goto failed; } - if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { - goto failed; - } - #endif ret = talloc_zero(ldb, struct ldb_cmdline); @@ -169,6 +165,12 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const if (options.nosync) { flags |= LDB_FLG_NOSYNC; } + +#ifdef _SAMBA_BUILD_ + if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { + goto failed; + } +#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)); -- cgit From da574945caea27fea468ed41eb42311480253a58 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 5 Dec 2005 00:43:50 +0000 Subject: r12057: fixed authentication in ldb client tools (This used to be commit 020de11a61a1aa2c77c0a308186c85960c10fe32) --- source4/lib/ldb/tools/cmdline.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 0be8951b9f..78dc84d01c 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -170,6 +170,9 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { goto failed; } + if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { + goto failed; + } #endif if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", -- cgit From 6aafed9600a3fa05932668c70fc0e20f3724dab6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 18:48:23 +0000 Subject: r12499: Move smb_build.h out of includes.h (This used to be commit c92ace494f92084ddf178626cdf392d151043bc7) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 78dc84d01c..3bbc87d05f 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -28,6 +28,7 @@ #include "ldb/tools/cmdline.h" #ifdef _SAMBA_BUILD_ #include "lib/cmdline/popt_common.h" +#include "smb_build.h" #endif /* -- cgit From 2cd5ca7d25f12aa9198bf8c2deb6aea282f573ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Dec 2005 15:38:36 +0000 Subject: r12542: Move some more prototypes out to seperate headers (This used to be commit 0aca5fd5130d980d07398f3291d294202aefe3c2) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 3bbc87d05f..a14434622f 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -29,6 +29,7 @@ #ifdef _SAMBA_BUILD_ #include "lib/cmdline/popt_common.h" #include "smb_build.h" +#include "auth/auth.h" #endif /* -- cgit From aa9f67163cd2df2a815ef585edad1951343b82c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 22:46:16 +0000 Subject: r12620: Get rid of automatically generated lists of init functions of subsystems. This allows Samba libraries to be used by other projects (and parts of Samba to be built as shared libraries). (This used to be commit 44f0aba715bfedc7e1ee3d07e9a101a91dbd84b3) --- source4/lib/ldb/tools/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index a14434622f..c134c3befd 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -28,7 +28,6 @@ #include "ldb/tools/cmdline.h" #ifdef _SAMBA_BUILD_ #include "lib/cmdline/popt_common.h" -#include "smb_build.h" #include "auth/auth.h" #endif @@ -72,7 +71,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const }; #ifdef _SAMBA_BUILD_ - ldbsearch_init_subsystems; + gensec_init(); + r = ldb_register_samba_handlers(ldb); if (r != 0) { goto failed; -- cgit From b51fe793c7cefb693d6d3633272b82238e712abe Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 19:42:08 +0000 Subject: r12745: Initial work to support a syntax to pass over controls via command line to ldbsearch. Very rough work, no checks are done on the input yet (will segfault if you make it wrong). Controls are passed via the --controls switch an are comma separated (no escaping yet). General syntax is : is a string is 1 or 0 Current semi-parsed controls are: server_sort syntax: server_sort:1:0:attributename 1st parm: criticality 2nd parm: reversed 3rd parm: attribute name to be used for sorting todo: still missing suport for multiple sorting attributes and ordering rule no check on result code paged_results syntax: paged_results:1:100 1st parm: criticality 2nd parm: number of results to be returned todo: ldbsearch will return only the first batch (missing code to cycle over conditionally) no check on result code extended_dn syntax: extended_dn:1:0 1st parm: criticality 2nd parm: type, see MS docs on meaning Simo. (This used to be commit 4c685ac0d1638a1d5392dfe733baf0db77e84858) --- source4/lib/ldb/tools/cmdline.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index c134c3befd..bac444fe75 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -62,6 +62,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "input", 'I', POPT_ARG_STRING, &options.input, 0, "Input File", "Input" }, { "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" }, { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, + { "controls", 0, POPT_ARG_STRING, NULL, 'c', "controls", NULL }, #ifdef _SAMBA_BUILD_ POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS @@ -137,7 +138,35 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const options.options[num_options+1] = NULL; num_options++; break; - + + case 'c': { + const char *cs = poptGetOptArg(pc); + const char *p; + int cc; + + for (p = cs, cc = 1; p = strchr(p, ','); cc++) ; + + options.controls = talloc_array(ret, char *, cc + 1); + if (options.controls == NULL) { + ldb_oom(ldb); + goto failed; + } + for (p = cs, cc = 0; p != NULL; cc++) { + const char *t; + + t = strchr(p, ','); + if (t == NULL) { + options.controls[cc] = talloc_strdup(options.controls, p); + p = NULL; + } else { + options.controls[cc] = talloc_strndup(options.controls, p, t-p); + p = t + 1; + } + } + options.controls[cc + 1] = NULL; + + break; + } default: fprintf(stderr, "Invalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); -- cgit From 39212a4960059905c7b976793f2e306163bf9918 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Jan 2006 14:19:24 +0000 Subject: r12790: fix compiler warning metze (This used to be commit c65ebc8b5574f9bd05270964dee9d4882e2d1828) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index bac444fe75..d1ad79b7f6 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -144,7 +144,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const const char *p; int cc; - for (p = cs, cc = 1; p = strchr(p, ','); cc++) ; + for (p = cs, cc = 1; (p = strchr(p, ',')); cc++) ; options.controls = talloc_array(ret, char *, cc + 1); if (options.controls == NULL) { -- cgit From 4d1c5a023cf6680474bd8d8be73f576d155cfe81 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Jan 2006 16:48:32 +0000 Subject: r12829: fix ldb headers, to not include '<...>' files in .c files this helps in getting symbol -fvisibility=hidden (GCC 4 feature) working later. metze (This used to be commit 380938e97f31c7860aed1e73cc0110c6e17b472e) --- source4/lib/ldb/tools/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index d1ad79b7f6..9b24b83239 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -23,9 +23,9 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" +#include "ldb/include/includes.h" #include "ldb/tools/cmdline.h" + #ifdef _SAMBA_BUILD_ #include "lib/cmdline/popt_common.h" #include "auth/auth.h" -- cgit From 5ecc64dcab1089cf134a264de28aca0b21100cca Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 10 Jan 2006 17:19:32 +0000 Subject: r12833: complete ldbsearch support for controls now the three supported controls (paged_results, server_sort, extended_dn) are fully functional and the infrastructure to add more is in place. valgrind is happy too :) Simo. (This used to be commit bd8e2629378700198e16287823970f52d1150a86) --- source4/lib/ldb/tools/cmdline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 9b24b83239..ee9e5f5e47 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -141,10 +141,10 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const case 'c': { const char *cs = poptGetOptArg(pc); - const char *p; + const char *p, *q; int cc; - for (p = cs, cc = 1; (p = strchr(p, ',')); cc++) ; + for (p = cs, cc = 1; (q = strchr(p, ',')); cc++, p = q + 1) ; options.controls = talloc_array(ret, char *, cc + 1); if (options.controls == NULL) { @@ -163,7 +163,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const p = t + 1; } } - options.controls[cc + 1] = NULL; + options.controls[cc] = NULL; break; } -- cgit From 2e8937c334b20b07d28f1a6647f97c1df5da44e7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 15:03:20 +0000 Subject: r12843: get special objects with ldbsearch -a too, to match ldbedit -a metze (This used to be commit bb68f2e602dbcc94c05b2dd764c163be1e5a583d) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index ee9e5f5e47..7f715a46b1 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -55,7 +55,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL }, { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, - { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "objectClass=*", NULL }, + { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "(|(objectClass=*)(distinguishedName=*))", NULL }, { "nosync", 0, POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, -- cgit From f81d80a4afd77cd100832b80bc2383d7c19a71a8 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 18 Jan 2006 04:36:30 +0000 Subject: r12989: move the control parsing and handleng functions to cmdline.c so that they can be used by the other ldb tools as well (This used to be commit c12b3c5cb46d428f815c623efacff8edebb6f6e3) --- source4/lib/ldb/tools/cmdline.c | 317 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 7f715a46b1..df8d94d1f0 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -219,3 +219,320 @@ failed: exit(1); return NULL; } + +struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) +{ + int i; + struct ldb_control **ctrl; + + if (control_strings == NULL || control_strings[0] == NULL) + return NULL; + + for (i = 0; control_strings[i]; i++); + + ctrl = talloc_array(mem_ctx, struct ldb_control *, i + 1); + + for (i = 0; control_strings[i]; i++) { + if (strncmp(control_strings[i], "dirsync:", 8) == 0) { + struct ldb_dirsync_control *control; + const char *p; + char cookie[1024]; + int crit, flags, max_attrs, ret; + + cookie[0] = '\0'; + p = &(control_strings[i][8]); + ret = sscanf(p, "%d:%d:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie); + + if ((ret < 3) || (crit < 0) || (crit > 1) || (flags < 0) || (max_attrs < 0)) { + fprintf(stderr, "invalid dirsync control syntax\n"); + return NULL; + } + + /* w2k3 seems to ignore the parameter, + * but w2k sends a wrong cookie when this value is to small + * this would cause looping forever, while getting + * the same data and same cookie forever + */ + if (max_attrs == 0) max_attrs = 0x0FFFFFFF; + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_DIRSYNC_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_dirsync_control); + control->flags = flags; + control->max_attributes = max_attrs; + if (*cookie) { + control->cookie_len = ldb_base64_decode(cookie); + control->cookie = talloc_memdup(control, cookie, control->cookie_len); + } else { + control->cookie = NULL; + control->cookie_len = 0; + } + ctrl[i]->data = control; + + continue; + } + + if (strncmp(control_strings[i], "asq:", 4) == 0) { + struct ldb_asq_control *control; + const char *p; + char attr[256]; + int crit, ret; + + attr[0] = '\0'; + p = &(control_strings[i][4]); + ret = sscanf(p, "%d:%255[^$]", &crit, attr); + if ((ret != 2) || (crit < 0) || (crit > 1) || (attr[0] == '\0')) { + fprintf(stderr, "invalid asq control syntax\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_ASQ_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_asq_control); + control->request = 1; + control->source_attribute = talloc_strdup(control, attr); + control->src_attr_len = strlen(attr); + ctrl[i]->data = control; + + continue; + } + + if (strncmp(control_strings[i], "extended_dn:", 12) == 0) { + struct ldb_extended_dn_control *control; + const char *p; + int crit, type, ret; + + p = &(control_strings[i][12]); + ret = sscanf(p, "%d:%d", &crit, &type); + if ((ret != 2) || (crit < 0) || (crit > 1) || (type < 0) || (type > 1)) { + fprintf(stderr, "invalid extended_dn control syntax\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_EXTENDED_DN_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_extended_dn_control); + control->type = type; + ctrl[i]->data = control; + + continue; + } + + if (strncmp(control_strings[i], "paged_results:", 14) == 0) { + struct ldb_paged_control *control; + const char *p; + int crit, size, ret; + + p = &(control_strings[i][14]); + ret = sscanf(p, "%d:%d", &crit, &size); + + if ((ret != 2) || (crit < 0) || (crit > 1) || (size < 0)) { + fprintf(stderr, "invalid paged_results control syntax\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_PAGED_RESULTS_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_paged_control); + control->size = size; + control->cookie = NULL; + control->cookie_len = 0; + ctrl[i]->data = control; + + continue; + } + + if (strncmp(control_strings[i], "server_sort:", 12) == 0) { + struct ldb_server_sort_control **control; + const char *p; + char attr[256]; + char rule[128]; + int crit, rev, ret; + + attr[0] = '\0'; + rule[0] = '\0'; + p = &(control_strings[i][12]); + ret = sscanf(p, "%d:%d:%255[^:]:%127[^:]", &crit, &rev, attr, rule); + if ((ret < 3) || (crit < 0) || (crit > 1) || (rev < 0 ) || (rev > 1) ||attr[0] == '\0') { + fprintf(stderr, "invalid server_sort control syntax\n"); + return NULL; + } + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_SERVER_SORT_OID; + ctrl[i]->critical = crit; + control = talloc_array(ctrl[i], struct ldb_server_sort_control *, 2); + control[0] = talloc(control, struct ldb_server_sort_control); + control[0]->attributeName = talloc_strdup(control, attr); + if (rule[0]) + control[0]->orderingRule = talloc_strdup(control, rule); + else + control[0]->orderingRule = NULL; + control[0]->reverse = rev; + control[1] = NULL; + ctrl[i]->data = control; + + continue; + } + + if (strncmp(control_strings[i], "notification:", 13) == 0) { + const char *p; + int crit, ret; + + p = &(control_strings[i][13]); + ret = sscanf(p, "%d", &crit); + if ((ret != 1) || (crit < 0) || (crit > 1)) { + fprintf(stderr, "invalid notification control syntax\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_NOTIFICATION_OID; + ctrl[i]->critical = crit; + ctrl[i]->data = NULL; + + continue; + } + + /* no controls matched, throw an error */ + fprintf(stderr, "Invalid control name\n"); + return NULL; + } + + ctrl[i] = NULL; + + return ctrl; +} + + +/* this function check controls reply and determines if more + * processing is needed setting up the request controls correctly + * + * returns: + * -1 error + * 0 all ok + * 1 all ok, more processing required + */ +int handle_controls_reply(struct ldb_control **reply, struct ldb_control **request) +{ + int i, j; + int ret = 0; + + if (reply == NULL || request == NULL) return -1; + + for (i = 0; reply[i]; i++) { + if (strcmp(LDB_CONTROL_ASQ_OID, reply[i]->oid) == 0) { + struct ldb_asq_control *rep_control; + + rep_control = talloc_get_type(reply[i]->data, struct ldb_asq_control); + + /* check the result */ + if (rep_control->result != 0) { + fprintf(stderr, "Warning: ASQ not performed with error: %d\n", rep_control->result); + } + + continue; + } + if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, reply[i]->oid) == 0) { + struct ldb_paged_control *rep_control, *req_control; + + rep_control = talloc_get_type(reply[i]->data, struct ldb_paged_control); + if (rep_control->cookie_len == 0) /* we are done */ + break; + + /* more processing required */ + /* let's fill in the request control with the new cookie */ + + for (j = 0; request[j]; j++) { + if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, request[j]->oid) == 0) + break; + } + /* if there's a reply control we must find a request + * control matching it */ + if (! request[j]) return -1; + + req_control = talloc_get_type(request[j]->data, struct ldb_paged_control); + + if (req_control->cookie) + talloc_free(req_control->cookie); + req_control->cookie = talloc_memdup(req_control, + rep_control->cookie, + rep_control->cookie_len); + req_control->cookie_len = rep_control->cookie_len; + + ret = 1; + + continue; + } + + if (strcmp(LDB_CONTROL_SORT_RESP_OID, reply[i]->oid) == 0) { + struct ldb_sort_resp_control *rep_control; + + rep_control = talloc_get_type(reply[i]->data, struct ldb_sort_resp_control); + + /* check we have a matching control in the request */ + for (j = 0; request[j]; j++) { + if (strcmp(LDB_CONTROL_SERVER_SORT_OID, request[j]->oid) == 0) + break; + } + if (! request[j]) { + fprintf(stderr, "Warning Server Sort reply received but no request found\n"); + continue; + } + + /* check the result */ + if (rep_control->result != 0) { + fprintf(stderr, "Warning: Sorting not performed with error: %d\n", rep_control->result); + } + + continue; + } + + if (strcmp(LDB_CONTROL_DIRSYNC_OID, reply[i]->oid) == 0) { + struct ldb_dirsync_control *rep_control, *req_control; + char *cookie; + + rep_control = talloc_get_type(reply[i]->data, struct ldb_dirsync_control); + if (rep_control->cookie_len == 0) /* we are done */ + break; + + /* more processing required */ + /* let's fill in the request control with the new cookie */ + + for (j = 0; request[j]; j++) { + if (strcmp(LDB_CONTROL_DIRSYNC_OID, request[j]->oid) == 0) + break; + } + /* if there's a reply control we must find a request + * control matching it */ + if (! request[j]) return -1; + + req_control = talloc_get_type(request[j]->data, struct ldb_dirsync_control); + + if (req_control->cookie) + talloc_free(req_control->cookie); + req_control->cookie = talloc_memdup(req_control, + rep_control->cookie, + rep_control->cookie_len); + req_control->cookie_len = rep_control->cookie_len; + + cookie = ldb_base64_encode(req_control, rep_control->cookie, rep_control->cookie_len); + printf("# DIRSYNC cookie returned was:\n# %s\n", cookie); + + sleep(120); + + ret = 1; + + continue; + } + + /* no controls matched, throw a warning */ + fprintf(stderr, "Unknown reply control oid: %s\n", reply[i]->oid); + } + + return ret; +} + -- cgit From 88279373abc07fa50a969135eb5ecf58d6c40cc7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 05:59:48 +0000 Subject: r13328: After the attribute name check cleanup it turned up ldb_caseless_cmp() was used just in one places and by mistake, as there we should have been using ldb_attr_cmp() Remove ldb_caseless_cmp() ... going on with the cleanup and utf8 compliance effort. Simo. (This used to be commit afda68d7bf655a9145648856d29e6e64b9f21aa3) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index df8d94d1f0..232cfcbb16 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -204,6 +204,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const 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", -- cgit From 04396c36d3ee8300b2b73ea8b43a45ea1b250828 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 06:57:28 +0000 Subject: r13333: revert previous commit I will use ldb_caseless_cmp in attrib_handlers to correctly support utf8 comparisons add an ldb_attr_Casefold function for attribute names and use it instead of casefold in the right places (This used to be commit 3b4eb2413bbce059dde69f35c03cdc3cc2ba85c5) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 232cfcbb16..446923f282 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -204,7 +204,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { goto failed; } - ldb_set_utf8_fns(ldb, NULL, wrap_casefold); + ldb_set_utf8_fns(ldb, NULL, wrap_caseless_cmp, wrap_casefold); #endif if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", -- cgit From f1b2c6d686763078fbc7ce97bc63b68844d457da Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Feb 2006 09:49:33 +0000 Subject: r13340: The gensec_init() needs to be after the popt processing, as it disables modules based on parametric options. Andrew Bartlett (This used to be commit db32a81f3ea661e2308cccca8d6a251a3d57337e) --- source4/lib/ldb/tools/cmdline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 446923f282..1926df4c86 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -72,8 +72,6 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const }; #ifdef _SAMBA_BUILD_ - gensec_init(); - r = ldb_register_samba_handlers(ldb); if (r != 0) { goto failed; @@ -198,6 +196,9 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const } #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; } -- cgit From 76036d37b42d0c77e57b288af410b931c51fea81 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 18:30:30 +0000 Subject: r13349: In the end I could not use ldb_caseless_cmp in attrib_handler.c functions remove it again Simo (This used to be commit 513ff499071e6cb5e608a82430718021f72997bd) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 1926df4c86..8937f9d4f6 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -205,7 +205,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { goto failed; } - ldb_set_utf8_fns(ldb, NULL, wrap_caseless_cmp, wrap_casefold); + 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", -- cgit From 338c410fec8dbd902485e56567f6aecf256cdba2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 6 Feb 2006 01:21:17 +0000 Subject: r13361: initial implementation of the vlv control seem still buggy, can't make w2k3 to like it yet (This used to be commit e1318383e91f6f6db39e3e3c9946fbb089753947) --- source4/lib/ldb/tools/cmdline.c | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 8937f9d4f6..24005c450c 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -235,6 +235,52 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) ctrl = talloc_array(mem_ctx, struct ldb_control *, i + 1); for (i = 0; control_strings[i]; i++) { + if (strncmp(control_strings[i], "vlv:", 4) == 0) { + struct ldb_vlv_req_control *control; + const char *p; + char attr[1024]; + char ctxid[1024]; + int crit, bc, ac, os, cc, ret; + + attr[0] = '\0'; + ctxid[0] = '\0'; + p = &(control_strings[i][4]); + ret = sscanf(p, "%d:%d:%d:%d:%d:%1023[^$]", &crit, &bc, &ac, &os, &cc, ctxid); + if (ret < 5) { + ret = sscanf(p, "%d:%d:%d:%1023[^:]:%1023[^$]", &crit, &bc, &ac, attr, ctxid); + } + + if ((ret < 4) || (crit < 0) || (crit > 1)) { + fprintf(stderr, "invalid server_sort control syntax\n"); + return NULL; + } + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_VLV_REQ_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_vlv_req_control); + control->beforeCount = bc; + control->afterCount = ac; + if (attr[0]) { + control->type = 1; + control->match.gtOrEq.value = talloc_strdup(control, attr); + control->match.gtOrEq.value_len = strlen(attr); + } else { + control->type = 0; + control->match.byOffset.offset = os; + control->match.byOffset.contentCount = cc; + } + if (ctxid[0]) { + control->ctxid_len = ldb_base64_decode(ctxid); + control->contextId = talloc_memdup(control, ctxid, control->ctxid_len); + } else { + control->ctxid_len = 0; + control->contextId = NULL; + } + ctrl[i]->data = control; + + continue; + } + if (strncmp(control_strings[i], "dirsync:", 8) == 0) { struct ldb_dirsync_control *control; const char *p; @@ -426,6 +472,31 @@ int handle_controls_reply(struct ldb_control **reply, struct ldb_control **reque if (reply == NULL || request == NULL) return -1; for (i = 0; reply[i]; i++) { + if (strcmp(LDB_CONTROL_VLV_RESP_OID, reply[i]->oid) == 0) { + struct ldb_vlv_resp_control *rep_control; + + rep_control = talloc_get_type(reply[i]->data, struct ldb_vlv_resp_control); + + /* check we have a matching control in the request */ + for (j = 0; request[j]; j++) { + if (strcmp(LDB_CONTROL_VLV_REQ_OID, request[j]->oid) == 0) + break; + } + if (! request[j]) { + fprintf(stderr, "Warning VLV reply received but no request have been made\n"); + continue; + } + + /* check the result */ + if (rep_control->vlv_result != 0) { + fprintf(stderr, "Warning: VLV not performed with error: %d\n", rep_control->vlv_result); + } else { + fprintf(stderr, "VLV Info: target position = %d, content count = %d\n", rep_control->targetPosition, rep_control->contentCount); + } + + continue; + } + if (strcmp(LDB_CONTROL_ASQ_OID, reply[i]->oid) == 0) { struct ldb_asq_control *rep_control; @@ -438,6 +509,7 @@ int handle_controls_reply(struct ldb_control **reply, struct ldb_control **reque continue; } + if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, reply[i]->oid) == 0) { struct ldb_paged_control *rep_control, *req_control; -- cgit From 00fe70e5b917769418f68eaa255d3a06a9a08ce7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Feb 2006 01:31:35 +0000 Subject: r13609: Get in the initial work on making ldb async Currently only ldb_ildap is async, the plan is to first make all backend support the async calls, and then remove the sync functions from backends and keep the only in the API. Modules will need to be transformed along the way. Simo (This used to be commit 1e2c13b2d52de7c534493dd79a2c0596a3e8c1f5) --- source4/lib/ldb/tools/cmdline.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 24005c450c..a67c41e67f 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -596,10 +596,6 @@ int handle_controls_reply(struct ldb_control **reply, struct ldb_control **reque cookie = ldb_base64_encode(req_control, rep_control->cookie, rep_control->cookie_len); printf("# DIRSYNC cookie returned was:\n# %s\n", cookie); - sleep(120); - - ret = 1; - continue; } -- cgit From 26af14c39b88b0e7eb53657b89be65d865804688 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 2 Mar 2006 16:32:53 +0000 Subject: r13786: [merge] Add registration functions for LDB modules Applications that use LDB modules will now have to run ldb_global_init() before they can use LDB. The next step will be adding support for loading LDB modules from .so files. This will also allow us to use one LDB without difference between the standalone and the Samba-specific build (This used to be commit 52a235650514039bf8ffee99a784bbc1b6ae6b92) --- source4/lib/ldb/tools/cmdline.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index a67c41e67f..8f803c5118 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -71,6 +71,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const POPT_TABLEEND }; + ldb_global_init(); + #ifdef _SAMBA_BUILD_ r = ldb_register_samba_handlers(ldb); if (r != 0) { -- cgit From 4ac2be99588b48b0652a524bf12fb1aa9c3f5fbb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 7 Mar 2006 11:07:23 +0000 Subject: r13924: Split more prototypes out of include/proto.h + initial work on header file dependencies (This used to be commit 122835876748a3eaf5e8d31ad1abddab9acb8781) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 8f803c5118..2874818160 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -29,6 +29,7 @@ #ifdef _SAMBA_BUILD_ #include "lib/cmdline/popt_common.h" #include "auth/auth.h" +#include "db_wrap.h" #endif /* -- cgit From b1bf44a4e1190fe41440e731adaab9db14881508 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 13 Mar 2006 21:05:55 +0000 Subject: r14344: More helpful messages on error for command line specified controls fixes in paged_results asq -> async (This used to be commit fbd347544001da9e46246eb0b4a8d165ccab15c9) --- source4/lib/ldb/tools/cmdline.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 2874818160..31cfcc1d08 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -255,6 +255,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) if ((ret < 4) || (crit < 0) || (crit > 1)) { fprintf(stderr, "invalid server_sort control syntax\n"); + fprintf(stderr, " syntax: crit(b):bc(n):ac(n):[:ctxid(o)]\n"); + fprintf(stderr, " note: b = boolean, n = number, s = string, o = b64 binary blob\n"); return NULL; } ctrl[i] = talloc(ctrl, struct ldb_control); @@ -296,6 +298,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) if ((ret < 3) || (crit < 0) || (crit > 1) || (flags < 0) || (max_attrs < 0)) { fprintf(stderr, "invalid dirsync control syntax\n"); + fprintf(stderr, " syntax: crit(b):flags(n):max_attrs(n)[:cookie(o)]\n"); + fprintf(stderr, " note: b = boolean, n = number, o = b64 binary blob\n"); return NULL; } @@ -335,6 +339,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) ret = sscanf(p, "%d:%255[^$]", &crit, attr); if ((ret != 2) || (crit < 0) || (crit > 1) || (attr[0] == '\0')) { fprintf(stderr, "invalid asq control syntax\n"); + fprintf(stderr, " syntax: crit(b):attr(s)\n"); + fprintf(stderr, " note: b = boolean, s = string\n"); return NULL; } @@ -359,6 +365,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) ret = sscanf(p, "%d:%d", &crit, &type); if ((ret != 2) || (crit < 0) || (crit > 1) || (type < 0) || (type > 1)) { fprintf(stderr, "invalid extended_dn control syntax\n"); + fprintf(stderr, " syntax: crit(b):type(b)\n"); + fprintf(stderr, " note: b = boolean\n"); return NULL; } @@ -382,6 +390,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) if ((ret != 2) || (crit < 0) || (crit > 1) || (size < 0)) { fprintf(stderr, "invalid paged_results control syntax\n"); + fprintf(stderr, " syntax: crit(b):size(n)\n"); + fprintf(stderr, " note: b = boolean, n = number\n"); return NULL; } @@ -410,6 +420,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) ret = sscanf(p, "%d:%d:%255[^:]:%127[^:]", &crit, &rev, attr, rule); if ((ret < 3) || (crit < 0) || (crit > 1) || (rev < 0 ) || (rev > 1) ||attr[0] == '\0') { fprintf(stderr, "invalid server_sort control syntax\n"); + fprintf(stderr, " syntax: crit(b):rev(b):attr(s)[:rule(s)]\n"); + fprintf(stderr, " note: b = boolean, s = string\n"); return NULL; } ctrl[i] = talloc(ctrl, struct ldb_control); @@ -437,6 +449,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) ret = sscanf(p, "%d", &crit); if ((ret != 1) || (crit < 0) || (crit > 1)) { fprintf(stderr, "invalid notification control syntax\n"); + fprintf(stderr, " syntax: crit(b)\n"); + fprintf(stderr, " note: b = boolean\n"); return NULL; } -- cgit From 7a121583b496a8fc0c1fcf44504d814700273e40 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Mar 2006 22:36:07 +0000 Subject: r14349: Kill proto.h! Prototypes are now spread over multiple headers, usually one per subsystem. This change is required to allow proper header dependencies later on, without recompiling Samba each time the mtime of any source file changes. (This used to be commit 3da79bf909f801386a52e6013db399c384d0401c) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 31cfcc1d08..fa01f5c3fb 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -28,6 +28,7 @@ #ifdef _SAMBA_BUILD_ #include "lib/cmdline/popt_common.h" +#include "lib/ldb/samba/ldif_handlers.h" #include "auth/auth.h" #include "db_wrap.h" #endif -- cgit From 47bf79eac5c5c23394778b7e20a5263be71a9c66 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 01:34:04 +0000 Subject: r15370: Fix more dependencies for shared libs (This used to be commit 9a518661fbb76bf1c153afc6f581e888186dc165) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index fa01f5c3fb..453fc14663 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -44,7 +44,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const #ifdef _SAMBA_BUILD_ int r; #endif - int num_options = 0; + int num_options = 0; int opt; struct poptOption popt_options[] = { POPT_AUTOHELP -- cgit From 8d0d05ddfdb227969777cc7ca6446c13c856fac5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 30 May 2006 17:02:21 +0000 Subject: r15955: fix whitespaces metze (This used to be commit a3d1ce6d3b8e771d28ab4418679b89a388579360) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 453fc14663..e7e5186b55 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -44,7 +44,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const #ifdef _SAMBA_BUILD_ int r; #endif - int num_options = 0; + int num_options = 0; int opt; struct poptOption popt_options[] = { POPT_AUTOHELP -- cgit From b4028ca1041fc8e0266de2f5c858dd40e660aafb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 10:26:23 +0000 Subject: r17418: add client support for the LDAP_SERVER_SD_FLAGS control metze (This used to be commit 23759a1e9b05c4fde475a9016cb0b7447656d7e7) --- source4/lib/ldb/tools/cmdline.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index e7e5186b55..d5a52cf370 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -381,6 +381,31 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) continue; } + if (strncmp(control_strings[i], "sd_flags:", 9) == 0) { + struct ldb_sd_flags_control *control; + const char *p; + int crit, ret; + unsigned secinfo_flags; + + p = &(control_strings[i][9]); + ret = sscanf(p, "%d:%u", &crit, &secinfo_flags); + if ((ret != 2) || (crit < 0) || (crit > 1) || (secinfo_flags < 0) || (secinfo_flags > 0xF)) { + fprintf(stderr, "invalid sd_flags control syntax\n"); + fprintf(stderr, " syntax: crit(b):secinfo_flags(n)\n"); + fprintf(stderr, " note: b = boolean, n = number\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_SD_FLAGS_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_sd_flags_control); + control->secinfo_flags = secinfo_flags; + ctrl[i]->data = control; + + continue; + } + if (strncmp(control_strings[i], "paged_results:", 14) == 0) { struct ldb_paged_control *control; const char *p; @@ -464,7 +489,7 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) } /* no controls matched, throw an error */ - fprintf(stderr, "Invalid control name\n"); + fprintf(stderr, "Invalid control name: '%s'\n", control_strings[i]); return NULL; } -- cgit From 817610f38540fb99595f6e3b77b9f6696f9e3b3f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 11:18:14 +0000 Subject: r17419: add client support for the LDAP_SERVER_SEARCH_OPTIONS support. with this you can limit a search to a specific partitions or a search over all partitions without getting referrals. (Witch is the default behavior on the Global Catalog Port) metze (This used to be commit 4ccd0f8171f3748ee6efe1abd3f894d2cdf46bf4) --- source4/lib/ldb/tools/cmdline.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index d5a52cf370..0901c7bbf2 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -406,6 +406,31 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) continue; } + if (strncmp(control_strings[i], "search_options:", 15) == 0) { + struct ldb_search_options_control *control; + const char *p; + int crit, ret; + unsigned search_options; + + p = &(control_strings[i][15]); + ret = sscanf(p, "%d:%u", &crit, &search_options); + if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options < 0) || (search_options > 0x0FFFFFFFF)) { + fprintf(stderr, "invalid sd_flags control syntax\n"); + fprintf(stderr, " syntax: crit(b):search_options(n)\n"); + fprintf(stderr, " note: b = boolean, n = number\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_SEARCH_OPTIONS_OID; + ctrl[i]->critical = crit; + control = talloc(ctrl[i], struct ldb_search_options_control); + control->search_options = search_options; + ctrl[i]->data = control; + + continue; + } + if (strncmp(control_strings[i], "paged_results:", 14) == 0) { struct ldb_paged_control *control; const char *p; -- cgit From 8ac0237eba1831c8ba6d01c2b9d8402636a21bb2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 11:38:50 +0000 Subject: r17420: add client support for the LDAP_SERVER_DOMAIN_SCOPE control metze (This used to be commit 84e74a759cfa49ebc8b4ba1b8e729d6d920fc55a) --- source4/lib/ldb/tools/cmdline.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 0901c7bbf2..c470c64703 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -414,8 +414,8 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) p = &(control_strings[i][15]); ret = sscanf(p, "%d:%u", &crit, &search_options); - if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options < 0) || (search_options > 0x0FFFFFFFF)) { - fprintf(stderr, "invalid sd_flags control syntax\n"); + if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options < 0) || (search_options > 0xF)) { + fprintf(stderr, "invalid search_options control syntax\n"); fprintf(stderr, " syntax: crit(b):search_options(n)\n"); fprintf(stderr, " note: b = boolean, n = number\n"); return NULL; @@ -431,6 +431,27 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) continue; } + if (strncmp(control_strings[i], "domain_scope:", 13) == 0) { + const char *p; + int crit, ret; + + p = &(control_strings[i][13]); + ret = sscanf(p, "%d", &crit); + if ((ret != 1) || (crit < 0) || (crit > 1)) { + fprintf(stderr, "invalid domain_scope control syntax\n"); + fprintf(stderr, " syntax: crit(b)\n"); + fprintf(stderr, " note: b = boolean\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_DOMAIN_SCOPE_OID; + ctrl[i]->critical = crit; + ctrl[i]->data = NULL; + + continue; + } + if (strncmp(control_strings[i], "paged_results:", 14) == 0) { struct ldb_paged_control *control; const char *p; -- cgit From 12050962f6dd37819e58e1e0b572c159f0406f7a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 19:35:00 +0000 Subject: r17429: implement the LDAP_SERVER_SHOW_DELETED control in the client metze (This used to be commit 40dc7c1787c16bfc15ac87fee81d2d2d1f3d2fde) --- source4/lib/ldb/tools/cmdline.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index c470c64703..5359cb1fff 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -534,6 +534,27 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) continue; } + if (strncmp(control_strings[i], "show_deleted:", 13) == 0) { + const char *p; + int crit, ret; + + p = &(control_strings[i][13]); + ret = sscanf(p, "%d", &crit); + if ((ret != 1) || (crit < 0) || (crit > 1)) { + fprintf(stderr, "invalid show_deleted control syntax\n"); + fprintf(stderr, " syntax: crit(b)\n"); + fprintf(stderr, " note: b = boolean\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_SHOW_DELETED_OID; + ctrl[i]->critical = crit; + ctrl[i]->data = NULL; + + continue; + } + /* no controls matched, throw an error */ fprintf(stderr, "Invalid control name: '%s'\n", control_strings[i]); return NULL; -- cgit From 3a083f8f53b998b6aabf69e845fd0fbdf86b6499 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 19:50:58 +0000 Subject: r17430: implement the LDAP_SERVER_PERMISSIVE_MODIFY control in the client metze (This used to be commit 96259f0f24b114e505241c9d2deb702a8b40f1b6) --- source4/lib/ldb/tools/cmdline.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 5359cb1fff..f71b6eea69 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -555,6 +555,27 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) continue; } + if (strncmp(control_strings[i], "permissive_modify:", 18) == 0) { + const char *p; + int crit, ret; + + p = &(control_strings[i][18]); + ret = sscanf(p, "%d", &crit); + if ((ret != 1) || (crit < 0) || (crit > 1)) { + fprintf(stderr, "invalid permissive_modify control syntax\n"); + fprintf(stderr, " syntax: crit(b)\n"); + fprintf(stderr, " note: b = boolean\n"); + return NULL; + } + + ctrl[i] = talloc(ctrl, struct ldb_control); + ctrl[i]->oid = LDB_CONTROL_PERMISSIVE_MODIFY_OID; + ctrl[i]->critical = crit; + ctrl[i]->data = NULL; + + continue; + } + /* no controls matched, throw an error */ fprintf(stderr, "Invalid control name: '%s'\n", control_strings[i]); return NULL; -- cgit From e7f56e45b2c5e952208c0a0755ed04185dc7c8f2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 22 Aug 2006 20:39:01 +0000 Subject: r17719: ldb_cmdline needs to be static for cc on solaris (This used to be commit db4d99f35b6874da01d0a1c68d64bd73635a7ec9) --- source4/lib/ldb/tools/cmdline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index f71b6eea69..1fd14d1739 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -39,7 +39,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv, void (*usage)(void)) { - struct ldb_cmdline options, *ret=NULL; + static struct ldb_cmdline options; /* needs to be static for older compilers */ + struct ldb_cmdline *ret=NULL; poptContext pc; #ifdef _SAMBA_BUILD_ int r; -- cgit From 6a4794452fdfffac4d9b1c6fc95bcb475f62b68c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Aug 2006 06:38:29 +0000 Subject: r17820: simplify the code flow a little (This used to be commit 221272e3930e1fbf30df1ad19713935d38cde46c) --- source4/lib/ldb/tools/cmdline.c | 47 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') 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; -- cgit From 873749f2189ecf1fbfdc681df4dd304a17716279 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 12:28:01 +0000 Subject: r18168: Use {NULL} rather than POPT_TABLEEND, which is not always available. (This used to be commit 8b622c5ded0732df0eaf9f6226f52a27b6eacd73) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index de24475f6e..77cdcf4db8 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -75,7 +75,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION #endif - POPT_TABLEEND + { NULL } }; ldb_global_init(); -- cgit From 088c24e4e6e72568d4362ac39dc5ff7734782197 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 23 Sep 2006 04:36:30 +0000 Subject: r18840: make these compatible with g++ warnings (This used to be commit bcfa93954fdb00f500f174cd227e3d9b2ef94fdc) --- source4/lib/ldb/tools/cmdline.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 77cdcf4db8..cb811452b8 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -26,7 +26,7 @@ #include "ldb/include/includes.h" #include "ldb/tools/cmdline.h" -#ifdef _SAMBA_BUILD_ +#if (_SAMBA_BUILD_ >= 4) #include "lib/cmdline/popt_common.h" #include "lib/ldb/samba/ldif_handlers.h" #include "auth/auth.h" @@ -44,7 +44,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const static struct ldb_cmdline options; /* needs to be static for older compilers */ struct ldb_cmdline *ret=NULL; poptContext pc; -#ifdef _SAMBA_BUILD_ +#if (_SAMBA_BUILD_ >= 4) int r; #endif int num_options = 0; @@ -70,7 +70,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" }, { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, { "controls", 0, POPT_ARG_STRING, NULL, 'c', "controls", NULL }, -#ifdef _SAMBA_BUILD_ +#if (_SAMBA_BUILD_ >= 4) POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION @@ -80,7 +80,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const ldb_global_init(); -#ifdef _SAMBA_BUILD_ +#if (_SAMBA_BUILD_ >= 4) r = ldb_register_samba_handlers(ldb); if (r != 0) { goto failed; @@ -206,7 +206,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const flags |= LDB_FLG_NOSYNC; } -#ifdef _SAMBA_BUILD_ +#if (_SAMBA_BUILD_ >= 4) /* Must be after we have processed command line options */ gensec_init(); -- cgit From 51f27dc3f19e9916155ecad64662b874d1fea229 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Sep 2006 20:29:54 +0000 Subject: r18851: Some C++ warnings (This used to be commit 69f05f288ce7a8508760db861d0910495bd1d578) --- source4/lib/ldb/tools/cmdline.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index cb811452b8..09bb99c096 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -285,7 +285,7 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) } if (ctxid[0]) { control->ctxid_len = ldb_base64_decode(ctxid); - control->contextId = talloc_memdup(control, ctxid, control->ctxid_len); + control->contextId = (char *)talloc_memdup(control, ctxid, control->ctxid_len); } else { control->ctxid_len = 0; control->contextId = NULL; @@ -327,7 +327,7 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) control->max_attributes = max_attrs; if (*cookie) { control->cookie_len = ldb_base64_decode(cookie); - control->cookie = talloc_memdup(control, cookie, control->cookie_len); + control->cookie = (char *)talloc_memdup(control, cookie, control->cookie_len); } else { control->cookie = NULL; control->cookie_len = 0; @@ -671,9 +671,9 @@ int handle_controls_reply(struct ldb_control **reply, struct ldb_control **reque if (req_control->cookie) talloc_free(req_control->cookie); - req_control->cookie = talloc_memdup(req_control, - rep_control->cookie, - rep_control->cookie_len); + req_control->cookie = (char *)talloc_memdup( + req_control, rep_control->cookie, + rep_control->cookie_len); req_control->cookie_len = rep_control->cookie_len; ret = 1; @@ -727,9 +727,9 @@ int handle_controls_reply(struct ldb_control **reply, struct ldb_control **reque if (req_control->cookie) talloc_free(req_control->cookie); - req_control->cookie = talloc_memdup(req_control, - rep_control->cookie, - rep_control->cookie_len); + req_control->cookie = (char *)talloc_memdup( + req_control, rep_control->cookie, + rep_control->cookie_len); req_control->cookie_len = rep_control->cookie_len; cookie = ldb_base64_encode(req_control, rep_control->cookie, rep_control->cookie_len); -- cgit From 13dbee3ffea6065a826f010e50c9b4eb2c6ad109 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Nov 2006 00:48:36 +0000 Subject: r19598: Ahead of a merge to current lorikeet-heimdal: Break up auth/auth.h not to include the world. Add credentials_krb5.h with the kerberos dependent prototypes. Andrew Bartlett (This used to be commit 2b569c42e0fbb596ea82484d0e1cb22e193037b9) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 09bb99c096..928519f3bb 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -29,6 +29,7 @@ #if (_SAMBA_BUILD_ >= 4) #include "lib/cmdline/popt_common.h" #include "lib/ldb/samba/ldif_handlers.h" +#include "auth/gensec/gensec.h" #include "auth/auth.h" #include "db_wrap.h" #endif -- cgit From a98d02c2f4f649a2c437bb3821b32fb83deea7c0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 25 Nov 2006 17:00:55 +0000 Subject: r19897: Fix klokwork ids 2278 and 2279 (This used to be commit 44e6d39e0ef17ed5a801f95edaa6fbf5efa21a26) --- source4/lib/ldb/tools/cmdline.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 928519f3bb..8eb7a7e952 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -269,10 +269,17 @@ struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) fprintf(stderr, " note: b = boolean, n = number, s = string, o = b64 binary blob\n"); return NULL; } - ctrl[i] = talloc(ctrl, struct ldb_control); + if (!(ctrl[i] = talloc(ctrl, struct ldb_control))) { + fprintf(stderr, "talloc failed\n"); + return NULL; + } ctrl[i]->oid = LDB_CONTROL_VLV_REQ_OID; ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_vlv_req_control); + if (!(control = talloc(ctrl[i], + struct ldb_vlv_req_control))) { + fprintf(stderr, "talloc failed\n"); + return NULL; + } control->beforeCount = bc; control->afterCount = ac; if (attr[0]) { -- cgit From 7dc7156bd76425df129102a42dd29a85fd8c7ebc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Feb 2007 01:54:40 +0000 Subject: r21496: A number of ldb control and LDAP changes, surrounding the 'phantom_root' flag in the search_options control - Add in support for LDB controls to the js layer - Test the behaviour - Implement support for the 'phantom_root' flag in the partitions module - Make the LDAP server set the 'phantom_root' flag in the search_options control - This replaces the global_catalog flag passed down as an opaque pointer - Rework the string-format control parsing function into ldb_parse_control_strings(), returning errors by ldb_errorstring() method, rather than with printf to stderr - Rework some of the ldb_control handling logic Andrew Bartlett (This used to be commit 2b3df7f38d7790358dbb4de1b8609bf794a351fb) --- source4/lib/ldb/tools/cmdline.c | 368 ---------------------------------------- 1 file changed, 368 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 8eb7a7e952..c0de314ef1 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -235,374 +235,6 @@ failed: return NULL; } -struct ldb_control **parse_controls(void *mem_ctx, char **control_strings) -{ - int i; - struct ldb_control **ctrl; - - if (control_strings == NULL || control_strings[0] == NULL) - return NULL; - - for (i = 0; control_strings[i]; i++); - - ctrl = talloc_array(mem_ctx, struct ldb_control *, i + 1); - - for (i = 0; control_strings[i]; i++) { - if (strncmp(control_strings[i], "vlv:", 4) == 0) { - struct ldb_vlv_req_control *control; - const char *p; - char attr[1024]; - char ctxid[1024]; - int crit, bc, ac, os, cc, ret; - - attr[0] = '\0'; - ctxid[0] = '\0'; - p = &(control_strings[i][4]); - ret = sscanf(p, "%d:%d:%d:%d:%d:%1023[^$]", &crit, &bc, &ac, &os, &cc, ctxid); - if (ret < 5) { - ret = sscanf(p, "%d:%d:%d:%1023[^:]:%1023[^$]", &crit, &bc, &ac, attr, ctxid); - } - - if ((ret < 4) || (crit < 0) || (crit > 1)) { - fprintf(stderr, "invalid server_sort control syntax\n"); - fprintf(stderr, " syntax: crit(b):bc(n):ac(n):[:ctxid(o)]\n"); - fprintf(stderr, " note: b = boolean, n = number, s = string, o = b64 binary blob\n"); - return NULL; - } - if (!(ctrl[i] = talloc(ctrl, struct ldb_control))) { - fprintf(stderr, "talloc failed\n"); - return NULL; - } - ctrl[i]->oid = LDB_CONTROL_VLV_REQ_OID; - ctrl[i]->critical = crit; - if (!(control = talloc(ctrl[i], - struct ldb_vlv_req_control))) { - fprintf(stderr, "talloc failed\n"); - return NULL; - } - control->beforeCount = bc; - control->afterCount = ac; - if (attr[0]) { - control->type = 1; - control->match.gtOrEq.value = talloc_strdup(control, attr); - control->match.gtOrEq.value_len = strlen(attr); - } else { - control->type = 0; - control->match.byOffset.offset = os; - control->match.byOffset.contentCount = cc; - } - if (ctxid[0]) { - control->ctxid_len = ldb_base64_decode(ctxid); - control->contextId = (char *)talloc_memdup(control, ctxid, control->ctxid_len); - } else { - control->ctxid_len = 0; - control->contextId = NULL; - } - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "dirsync:", 8) == 0) { - struct ldb_dirsync_control *control; - const char *p; - char cookie[1024]; - int crit, flags, max_attrs, ret; - - cookie[0] = '\0'; - p = &(control_strings[i][8]); - ret = sscanf(p, "%d:%d:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie); - - if ((ret < 3) || (crit < 0) || (crit > 1) || (flags < 0) || (max_attrs < 0)) { - fprintf(stderr, "invalid dirsync control syntax\n"); - fprintf(stderr, " syntax: crit(b):flags(n):max_attrs(n)[:cookie(o)]\n"); - fprintf(stderr, " note: b = boolean, n = number, o = b64 binary blob\n"); - return NULL; - } - - /* w2k3 seems to ignore the parameter, - * but w2k sends a wrong cookie when this value is to small - * this would cause looping forever, while getting - * the same data and same cookie forever - */ - if (max_attrs == 0) max_attrs = 0x0FFFFFFF; - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_DIRSYNC_OID; - ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_dirsync_control); - control->flags = flags; - control->max_attributes = max_attrs; - if (*cookie) { - control->cookie_len = ldb_base64_decode(cookie); - control->cookie = (char *)talloc_memdup(control, cookie, control->cookie_len); - } else { - control->cookie = NULL; - control->cookie_len = 0; - } - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "asq:", 4) == 0) { - struct ldb_asq_control *control; - const char *p; - char attr[256]; - int crit, ret; - - attr[0] = '\0'; - p = &(control_strings[i][4]); - ret = sscanf(p, "%d:%255[^$]", &crit, attr); - if ((ret != 2) || (crit < 0) || (crit > 1) || (attr[0] == '\0')) { - fprintf(stderr, "invalid asq control syntax\n"); - fprintf(stderr, " syntax: crit(b):attr(s)\n"); - fprintf(stderr, " note: b = boolean, s = string\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_ASQ_OID; - ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_asq_control); - control->request = 1; - control->source_attribute = talloc_strdup(control, attr); - control->src_attr_len = strlen(attr); - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "extended_dn:", 12) == 0) { - struct ldb_extended_dn_control *control; - const char *p; - int crit, type, ret; - - p = &(control_strings[i][12]); - ret = sscanf(p, "%d:%d", &crit, &type); - if ((ret != 2) || (crit < 0) || (crit > 1) || (type < 0) || (type > 1)) { - fprintf(stderr, "invalid extended_dn control syntax\n"); - fprintf(stderr, " syntax: crit(b):type(b)\n"); - fprintf(stderr, " note: b = boolean\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_EXTENDED_DN_OID; - ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_extended_dn_control); - control->type = type; - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "sd_flags:", 9) == 0) { - struct ldb_sd_flags_control *control; - const char *p; - int crit, ret; - unsigned secinfo_flags; - - p = &(control_strings[i][9]); - ret = sscanf(p, "%d:%u", &crit, &secinfo_flags); - if ((ret != 2) || (crit < 0) || (crit > 1) || (secinfo_flags < 0) || (secinfo_flags > 0xF)) { - fprintf(stderr, "invalid sd_flags control syntax\n"); - fprintf(stderr, " syntax: crit(b):secinfo_flags(n)\n"); - fprintf(stderr, " note: b = boolean, n = number\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_SD_FLAGS_OID; - ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_sd_flags_control); - control->secinfo_flags = secinfo_flags; - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "search_options:", 15) == 0) { - struct ldb_search_options_control *control; - const char *p; - int crit, ret; - unsigned search_options; - - p = &(control_strings[i][15]); - ret = sscanf(p, "%d:%u", &crit, &search_options); - if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options < 0) || (search_options > 0xF)) { - fprintf(stderr, "invalid search_options control syntax\n"); - fprintf(stderr, " syntax: crit(b):search_options(n)\n"); - fprintf(stderr, " note: b = boolean, n = number\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_SEARCH_OPTIONS_OID; - ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_search_options_control); - control->search_options = search_options; - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "domain_scope:", 13) == 0) { - const char *p; - int crit, ret; - - p = &(control_strings[i][13]); - ret = sscanf(p, "%d", &crit); - if ((ret != 1) || (crit < 0) || (crit > 1)) { - fprintf(stderr, "invalid domain_scope control syntax\n"); - fprintf(stderr, " syntax: crit(b)\n"); - fprintf(stderr, " note: b = boolean\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_DOMAIN_SCOPE_OID; - ctrl[i]->critical = crit; - ctrl[i]->data = NULL; - - continue; - } - - if (strncmp(control_strings[i], "paged_results:", 14) == 0) { - struct ldb_paged_control *control; - const char *p; - int crit, size, ret; - - p = &(control_strings[i][14]); - ret = sscanf(p, "%d:%d", &crit, &size); - - if ((ret != 2) || (crit < 0) || (crit > 1) || (size < 0)) { - fprintf(stderr, "invalid paged_results control syntax\n"); - fprintf(stderr, " syntax: crit(b):size(n)\n"); - fprintf(stderr, " note: b = boolean, n = number\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_PAGED_RESULTS_OID; - ctrl[i]->critical = crit; - control = talloc(ctrl[i], struct ldb_paged_control); - control->size = size; - control->cookie = NULL; - control->cookie_len = 0; - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "server_sort:", 12) == 0) { - struct ldb_server_sort_control **control; - const char *p; - char attr[256]; - char rule[128]; - int crit, rev, ret; - - attr[0] = '\0'; - rule[0] = '\0'; - p = &(control_strings[i][12]); - ret = sscanf(p, "%d:%d:%255[^:]:%127[^:]", &crit, &rev, attr, rule); - if ((ret < 3) || (crit < 0) || (crit > 1) || (rev < 0 ) || (rev > 1) ||attr[0] == '\0') { - fprintf(stderr, "invalid server_sort control syntax\n"); - fprintf(stderr, " syntax: crit(b):rev(b):attr(s)[:rule(s)]\n"); - fprintf(stderr, " note: b = boolean, s = string\n"); - return NULL; - } - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_SERVER_SORT_OID; - ctrl[i]->critical = crit; - control = talloc_array(ctrl[i], struct ldb_server_sort_control *, 2); - control[0] = talloc(control, struct ldb_server_sort_control); - control[0]->attributeName = talloc_strdup(control, attr); - if (rule[0]) - control[0]->orderingRule = talloc_strdup(control, rule); - else - control[0]->orderingRule = NULL; - control[0]->reverse = rev; - control[1] = NULL; - ctrl[i]->data = control; - - continue; - } - - if (strncmp(control_strings[i], "notification:", 13) == 0) { - const char *p; - int crit, ret; - - p = &(control_strings[i][13]); - ret = sscanf(p, "%d", &crit); - if ((ret != 1) || (crit < 0) || (crit > 1)) { - fprintf(stderr, "invalid notification control syntax\n"); - fprintf(stderr, " syntax: crit(b)\n"); - fprintf(stderr, " note: b = boolean\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_NOTIFICATION_OID; - ctrl[i]->critical = crit; - ctrl[i]->data = NULL; - - continue; - } - - if (strncmp(control_strings[i], "show_deleted:", 13) == 0) { - const char *p; - int crit, ret; - - p = &(control_strings[i][13]); - ret = sscanf(p, "%d", &crit); - if ((ret != 1) || (crit < 0) || (crit > 1)) { - fprintf(stderr, "invalid show_deleted control syntax\n"); - fprintf(stderr, " syntax: crit(b)\n"); - fprintf(stderr, " note: b = boolean\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_SHOW_DELETED_OID; - ctrl[i]->critical = crit; - ctrl[i]->data = NULL; - - continue; - } - - if (strncmp(control_strings[i], "permissive_modify:", 18) == 0) { - const char *p; - int crit, ret; - - p = &(control_strings[i][18]); - ret = sscanf(p, "%d", &crit); - if ((ret != 1) || (crit < 0) || (crit > 1)) { - fprintf(stderr, "invalid permissive_modify control syntax\n"); - fprintf(stderr, " syntax: crit(b)\n"); - fprintf(stderr, " note: b = boolean\n"); - return NULL; - } - - ctrl[i] = talloc(ctrl, struct ldb_control); - ctrl[i]->oid = LDB_CONTROL_PERMISSIVE_MODIFY_OID; - ctrl[i]->critical = crit; - ctrl[i]->data = NULL; - - continue; - } - - /* no controls matched, throw an error */ - fprintf(stderr, "Invalid control name: '%s'\n", control_strings[i]); - return NULL; - } - - ctrl[i] = NULL; - - return ctrl; -} - - /* this function check controls reply and determines if more * processing is needed setting up the request controls correctly * -- cgit From e0e8fc3db45691160b629b0a43753c162be03490 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 May 2007 18:59:52 +0000 Subject: r22682: Fix standalone ldb build when parent directory name != ldb. (This used to be commit 532f28724dcc9e0fe7051e27d145469398041101) --- source4/lib/ldb/tools/cmdline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index c0de314ef1..7589c159d8 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -22,11 +22,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "includes.h" -#include "ldb/include/includes.h" -#include "ldb/tools/cmdline.h" +#include "ldb_includes.h" +#include "tools/cmdline.h" #if (_SAMBA_BUILD_ >= 4) +#include "includes.h" #include "lib/cmdline/popt_common.h" #include "lib/ldb/samba/ldif_handlers.h" #include "auth/gensec/gensec.h" -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 7589c159d8..0f44ddf777 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/ldb/tools/cmdline.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 0f44ddf777..2d65a4d3ad 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #include "ldb_includes.h" -- cgit From 69c0923c5ea02cd89c5465023692927d30043676 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 10 Jul 2007 10:50:44 +0000 Subject: r23809: Don't give users the fantasy that we can control choice of GENSEC security mechanisms at the moment. I'll put this back when I implement the functionality. Andrew Bartlett (This used to be commit 9a38ddc86fe8c68520622678eae81e4e90f427cf) --- source4/lib/ldb/tools/cmdline.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 2d65a4d3ad..08f5dc721f 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -65,7 +65,6 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "(|(objectClass=*)(distinguishedName=*))", NULL }, { "nosync", 0, POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, - { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, { "input", 'I', POPT_ARG_STRING, &options.input, 0, "Input File", "Input" }, { "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" }, { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, -- cgit From 4a4cdc990cdc9e29b63fd28c5aa58ae1b47ed174 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 11 Sep 2007 16:06:32 +0000 Subject: r25084: Move samba-specific code out of lib/ldb directory. (This used to be commit 917bd737cb07817664d9088860588d47525f5ff8) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 08f5dc721f..2cf8212154 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -27,7 +27,7 @@ #if (_SAMBA_BUILD_ >= 4) #include "includes.h" #include "lib/cmdline/popt_common.h" -#include "lib/ldb/samba/ldif_handlers.h" +#include "lib/ldb-samba/ldif_handlers.h" #include "auth/gensec/gensec.h" #include "auth/auth.h" #include "db_wrap.h" -- cgit From f017f871078fd2219766ea061468268acb92140c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Nov 2007 21:57:33 +0100 Subject: r25842: Start working on test for loading dso's in ldb. (This used to be commit d41ed7ca8d3954bf586126edd7aba17acc6af8a1) --- source4/lib/ldb/tools/cmdline.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 2cf8212154..a713f54e68 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -60,6 +60,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "increase verbosity", NULL }, { "interactive", 'i', POPT_ARG_NONE, &options.interactive, 0, "input from stdin", NULL }, { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL }, + { "modules-path", 0, POPT_ARG_STRING, &options.modules_path, 0, "modules path", "PATH" }, { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "(|(objectClass=*)(distinguishedName=*))", NULL }, @@ -218,6 +219,12 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const ldb_set_utf8_fns(ldb, NULL, wrap_casefold); #endif + if (options.modules_path != NULL) { + ldb_set_modules_dir(ldb, options.modules_path); + } else if (getenv("LDB_MODULES_PATH") != NULL) { + ldb_set_modules_dir(ldb, getenv("LDB_MODULES_PATH")); + } + /* now connect to the ldb */ if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", -- cgit From ca0b72a1fdb7bd965065e833df34662afef0423e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Nov 2007 20:12:00 +0100 Subject: r26003: Split up DB_WRAP, as first step in an attempt to sanitize dependencies. (This used to be commit 56dfcb4f2f8e74c9d8b2fe3a0df043781188a555) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index a713f54e68..01ef04f5d2 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -30,7 +30,7 @@ #include "lib/ldb-samba/ldif_handlers.h" #include "auth/gensec/gensec.h" #include "auth/auth.h" -#include "db_wrap.h" +#include "ldb_wrap.h" #endif -- cgit From 2fa338cdc99276a5f85ad54cb88b372ffe8ab063 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 17:09:43 +0100 Subject: r26226: Avoid more uses of global_loadparm. (This used to be commit 6cbce47a3eaef76a89db7cd0ab0d4f6441fc720d) --- source4/lib/ldb/tools/cmdline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 01ef04f5d2..5e3013600a 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -31,11 +31,12 @@ #include "auth/gensec/gensec.h" #include "auth/auth.h" #include "ldb_wrap.h" +#include "param/param.h" #endif -/* +/** process command line options */ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv, @@ -208,7 +209,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const #if (_SAMBA_BUILD_ >= 4) /* Must be after we have processed command line options */ - gensec_init(); + gensec_init(global_loadparm); if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { goto failed; -- cgit From 51db4c3f3d81d1ed03beae6426786c843ac59807 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 17:56:09 +0100 Subject: r26228: Store loadparm context in auth context, move more loadparm_contexts up the call stack. (This used to be commit ba75f1613a9aac69dd5df94dd8a2b37820acd166) --- source4/lib/ldb/tools/cmdline.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 5e3013600a..1f8c7ce684 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -217,6 +217,10 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { goto failed; } + if (ldb_set_opaque(ldb, "loadparm", global_loadparm)) { + goto failed; + } + ldb_set_utf8_fns(ldb, NULL, wrap_casefold); #endif -- cgit From 43696d2752e2faad34fb3ed2a7dbf01d40ffdc46 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 15:53:28 +0100 Subject: r26252: Specify loadparm_context explicitly when creating sessions. (This used to be commit 7280c1e9415daabb2712db1372e23f9846272ede) --- source4/lib/ldb/tools/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 1f8c7ce684..e2df0a1b66 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -211,7 +211,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const /* Must be after we have processed command line options */ gensec_init(global_loadparm); - if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) { + if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb, global_loadparm))) { goto failed; } if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { -- cgit From 9ebcd7a0df117158f1817b7d3a9a21ad4e1fa97a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 01:51:36 +0100 Subject: r26277: Move loadparm context higher up the stack. (This used to be commit 38fa08310ce573e9b46e76c840ddda6f18863573) --- source4/lib/ldb/tools/cmdline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index e2df0a1b66..aff730c178 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -39,7 +39,8 @@ /** process command line options */ -struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv, +struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, + int argc, const char **argv, void (*usage)(void)) { static struct ldb_cmdline options; /* needs to be static for older compilers */ -- cgit From b65dba2245bf382c47d65c95ac9b1efa43918fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:16 +0100 Subject: r26355: Eliminate global_loadparm in more places. (This used to be commit 5d589a0d94bd76a9b4c9fc748854e8098ea43c4d) --- source4/lib/ldb/tools/cmdline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index aff730c178..8ee1994615 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -210,15 +210,15 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, #if (_SAMBA_BUILD_ >= 4) /* Must be after we have processed command line options */ - gensec_init(global_loadparm); + gensec_init(cmdline_lp_ctx); - if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb, global_loadparm))) { + if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb, cmdline_lp_ctx))) { goto failed; } if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) { goto failed; } - if (ldb_set_opaque(ldb, "loadparm", global_loadparm)) { + if (ldb_set_opaque(ldb, "loadparm", cmdline_lp_ctx)) { goto failed; } -- cgit From 0020793515ade04f3ef5754717490e2eb2ca6bb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 03:40:44 +0100 Subject: Fix static module list generation for ldb. (This used to be commit 92c1c0e9137f0845cac6cc96bf78711b6aaffe21) --- source4/lib/ldb/tools/cmdline.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 8ee1994615..c9c77c4e47 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -80,8 +80,6 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, { NULL } }; - ldb_global_init(); - #if (_SAMBA_BUILD_ >= 4) r = ldb_register_samba_handlers(ldb); if (r != 0) { -- cgit From 9437adf68b565b7a8ac40fdad3fe821c66818274 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 25 Jul 2008 16:02:29 +0200 Subject: lib/ldb/tools: allow -W and --realm when build from samba4 metze (This used to be commit 0aa6d63ec571b0ca05fbfe14d2b4e9ba3e1082e9) --- source4/lib/ldb/tools/cmdline.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index c9c77c4e47..765d8b9edf 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -75,6 +75,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, #if (_SAMBA_BUILD_ >= 4) POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS + POPT_COMMON_CONNECTION POPT_COMMON_VERSION #endif { NULL } -- cgit