From 58d50a614f1b4a3fc6b60ad5f777d987263fe54f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Mar 2004 06:45:39 +0000 Subject: make a more recent snapshot of ldb available to interested people. Note that I decided to make it LGPL. ldb is not finished yet, but enough of it is there for people to get an idea of what it does, and quite a few simple tests work (This used to be commit dc6f41f9e777d37f883303ddef0d96840d80f78e) --- source4/lib/ldb/tools/ldbdel.c | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 source4/lib/ldb/tools/ldbdel.c (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c new file mode 100644 index 0000000000..177279d47a --- /dev/null +++ b/source4/lib/ldb/tools/ldbdel.c @@ -0,0 +1,69 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + + ** 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 +*/ + +/* + * Name: ldb + * + * Component: ldbdel + * + * Description: utility to delete records - modelled on ldapdelete + * + * Author: Andrew Tridgell + */ + +#include "includes.h" + + int main(int argc, const char *argv[]) +{ + static struct ldb_context *ldb; + int ret, i; + const char *ldb_url; + + ldb_url = getenv("LDB_URL"); + if (!ldb_url) { + ldb_url = "tdb://test.ldb"; + } + + + if (argc < 2) { + printf("Usage: ldbdel \n"); + exit(1); + } + + ldb = ldb_connect(ldb_url, 0, NULL); + if (!ldb) { + perror("ldb_connect"); + exit(1); + } + + for (i=1;i Date: Sat, 10 Apr 2004 20:18:22 +0000 Subject: r152: a quick airport commit .... added ldbedit, a _really_ useful command added ldbadd, ldbdel, ldbsearch and ldbmodify to build solved lots of timezone issues, we now pass the torture tests with client and server in different zones fixed several build issues I know this breaks the no-LDAP build. Wait till I arrive in San Jose for that fix. (This used to be commit af34710d4da1841653624fe304b1c8d812c0fdd9) --- source4/lib/ldb/tools/ldbdel.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 177279d47a..0e50a68532 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -34,20 +34,48 @@ #include "includes.h" - int main(int argc, const char *argv[]) +static void usage(void) { - static struct ldb_context *ldb; + printf("Usage: ldbdel \n"); + printf("Options:\n"); + printf(" -H ldb_url choose the database (or $LDB_URL)\n"); + printf("\n"); + printf("Deletes records from a ldb\n\n"); + exit(1); +} + + int main(int argc, char * const argv[]) +{ + struct ldb_context *ldb; int ret, i; const char *ldb_url; + int opt; ldb_url = getenv("LDB_URL"); + + while ((opt = getopt(argc, argv, "hH:")) != EOF) { + switch (opt) { + case 'H': + ldb_url = optarg; + break; + + case 'h': + default: + usage(); + break; + } + } + if (!ldb_url) { - ldb_url = "tdb://test.ldb"; + fprintf(stderr, "You must specify a ldb URL\n"); + exit(1); } + argc -= optind; + argv += optind; - if (argc < 2) { - printf("Usage: ldbdel \n"); + if (argc < 1) { + usage(); exit(1); } @@ -57,7 +85,7 @@ exit(1); } - for (i=1;i Date: Sun, 11 Apr 2004 01:27:33 +0000 Subject: r159: nicer usage messages when no URL is given (This used to be commit 8655f0b435e06af21d5d9fa210441fbf318673f0) --- source4/lib/ldb/tools/ldbdel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 0e50a68532..48ee07ad25 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -67,8 +67,8 @@ static void usage(void) } if (!ldb_url) { - fprintf(stderr, "You must specify a ldb URL\n"); - exit(1); + fprintf(stderr, "You must specify a ldb URL\n\n"); + usage(); } argc -= optind; -- cgit From 68293565de0b799dcc51e001dabf53adf88ee7ad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 09:55:05 +0000 Subject: r513: added a generic ldb debug system to allow the Samba debug functions to be cleanly interfaced to ldb (This used to be commit 74b89d5f960d6b936751e3f057b4540eb80b79cd) --- source4/lib/ldb/tools/ldbdel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 48ee07ad25..880713b25a 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -85,6 +85,8 @@ static void usage(void) exit(1); } + ldb_set_debug_stderr(ldb); + for (i=0;i Date: Thu, 20 May 2004 13:25:06 +0000 Subject: r792: - changed the ldb ldif_* functions to be in the ldb_ namespace - added better error reporting in ldbdel - fixed a bug in handling packing of records which contain elements with no values (it caused db corruption) - allow search with "dn" as target attribute (This used to be commit 36575396234e3d35dbd442c8f1ff54a17ae64e64) --- source4/lib/ldb/tools/ldbdel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 880713b25a..2977357ced 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -90,7 +90,8 @@ static void usage(void) for (i=0;i Date: Tue, 28 Sep 2004 12:39:41 +0000 Subject: r2726: added a -r option to ldbdel to allow easy delete of a whole subtree. Useful when cleaning up a mess after testing. (This used to be commit 476674af5519960300c0a07349c7cdf307af3822) --- source4/lib/ldb/tools/ldbdel.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 2977357ced..d36db5429a 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -34,10 +34,35 @@ #include "includes.h" +static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) +{ + int ret, i, total=0; + const char *attrs[] = { "dn", NULL }; + struct ldb_message **res; + + ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "dn=*", attrs, &res); + if (ret <= 0) return -1; + + for (i=0;idn) == 0) { + total++; + } + } + + ldb_search_free(ldb, res); + + if (total == 0) { + return -1; + } + printf("Deleted %d records\n", total); + return 0; +} + static void usage(void) { printf("Usage: ldbdel \n"); printf("Options:\n"); + printf(" -r recursively delete the given subtree\n"); printf(" -H ldb_url choose the database (or $LDB_URL)\n"); printf("\n"); printf("Deletes records from a ldb\n\n"); @@ -49,16 +74,20 @@ static void usage(void) struct ldb_context *ldb; int ret, i; const char *ldb_url; - int opt; + int opt, recursive=0; ldb_url = getenv("LDB_URL"); - while ((opt = getopt(argc, argv, "hH:")) != EOF) { + while ((opt = getopt(argc, argv, "hH:r")) != EOF) { switch (opt) { case 'H': ldb_url = optarg; break; + case 'r': + recursive=1; + break; + case 'h': default: usage(); @@ -88,7 +117,14 @@ static void usage(void) ldb_set_debug_stderr(ldb); for (i=0;i Date: Mon, 15 Nov 2004 11:40:27 +0000 Subject: r3754: merge in ldb modules support from the tmp branch ldbPlugins (This used to be commit 71323f424b4561af1fdddd2358629049be3dad8c) --- source4/lib/ldb/tools/ldbdel.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index d36db5429a..42dc9c19d8 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -72,13 +72,16 @@ static void usage(void) int main(int argc, char * const argv[]) { struct ldb_context *ldb; + const char **options = NULL; + int ldbopts; int ret, i; const char *ldb_url; int opt, recursive=0; ldb_url = getenv("LDB_URL"); - while ((opt = getopt(argc, argv, "hH:r")) != EOF) { + ldbopts = 0; + while ((opt = getopt(argc, argv, "hH:ro:")) != EOF) { switch (opt) { case 'H': ldb_url = optarg; @@ -88,6 +91,21 @@ static void usage(void) recursive=1; break; + case 'o': + ldbopts++; + if (options == NULL) { + options = (const char **)malloc(sizeof(char *) * (ldbopts + 1)); + } else { + options = (const char **)realloc(options, sizeof(char *) * (ldbopts + 1)); + if (options == NULL) { + fprintf(stderr, "Out of memory!\n"); + exit(-1); + } + } + options[ldbopts - 1] = optarg; + options[ldbopts] = NULL; + break; + case 'h': default: usage(); @@ -108,7 +126,7 @@ static void usage(void) exit(1); } - ldb = ldb_connect(ldb_url, 0, NULL); + ldb = ldb_connect(ldb_url, 0, options); if (!ldb) { perror("ldb_connect"); exit(1); -- cgit From 57d2043479d290bbfa8d2752da454efea330606e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 15 Nov 2004 14:16:10 +0000 Subject: r3760: mention -o switch in help message (This used to be commit 0e7d8753101f22aa192ac5628675a0374484d0e9) --- source4/lib/ldb/tools/ldbdel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 42dc9c19d8..839cb4cbe2 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -64,6 +64,8 @@ static void usage(void) printf("Options:\n"); printf(" -r recursively delete the given subtree\n"); printf(" -H ldb_url choose the database (or $LDB_URL)\n"); + printf(" -o options pass options like modules to activate\n"); + printf(" e.g: -o modules:timestamps\n"); printf("\n"); printf("Deletes records from a ldb\n\n"); exit(1); -- cgit From 8a18778286a16423d7d6e483fdb308a91e294efe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 09:00:52 +0000 Subject: r3783: - don't use make proto for ldb anymore - split ldh.h out of samba's includes.h - make ldb_context and ldb_module private to the subsystem - use ltdb_ prefix for all ldb_tdb functions metze (This used to be commit f5ee40d6ce8224e280070975efc9911558fe675c) --- source4/lib/ldb/tools/ldbdel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 839cb4cbe2..dc1c734284 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) { -- cgit From 9012a501533126c4c0ac25a16fd6439a45df3d9a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 4 Dec 2004 10:14:03 +0000 Subject: r4059: moved the ldb -o option parsing to a common routine (This used to be commit ee52c1e38c9bac852458196ffbd677cca62a3965) --- source4/lib/ldb/tools/ldbdel.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index dc1c734284..29d3b39730 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -34,6 +34,7 @@ #include "includes.h" #include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) { @@ -95,18 +96,7 @@ static void usage(void) break; case 'o': - ldbopts++; - if (options == NULL) { - options = (const char **)malloc(sizeof(char *) * (ldbopts + 1)); - } else { - options = (const char **)realloc(options, sizeof(char *) * (ldbopts + 1)); - if (options == NULL) { - fprintf(stderr, "Out of memory!\n"); - exit(-1); - } - } - options[ldbopts - 1] = optarg; - options[ldbopts] = NULL; + options = ldb_options_parse(options, &ldbopts, optarg); break; case 'h': -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/lib/ldb/tools/ldbdel.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 29d3b39730..2241a0b823 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -36,6 +36,10 @@ #include "ldb/include/ldb.h" #include "ldb/include/ldb_private.h" +#ifdef _SAMBA_BUILD_ +#include "system/filesys.h" +#endif + static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) { int ret, i, total=0; -- cgit From b1b14817eaa6e6579596d54166e17bc8d5605c01 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 27 Feb 2005 11:35:47 +0000 Subject: r5585: LDB interfaces change: changes: - ldb_wrap disappears from code and become a private structure of db_wrap.c thanks to our move to talloc in ldb code, we do not need to expose it anymore - removal of ldb_close() function form the code thanks to our move to talloc in ldb code, we do not need it anymore use talloc_free() to close and free an ldb database - some minor updates to ldb modules code to cope with the change and fix some bugs I found out during the process (This used to be commit d58be9e74b786a11a57e89df36081d55730dfe0a) --- source4/lib/ldb/tools/ldbdel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 2241a0b823..72540db07a 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -146,7 +146,7 @@ static void usage(void) } } - ldb_close(ldb); + talloc_free(ldb); return 0; } -- cgit From fe4d985b6f3d318d9b58a16677be3b4ae34fba15 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 25 Apr 2005 12:46:18 +0000 Subject: r6470: Remove ldb_search_free() it is not needed anymore. Just use talloc_free() to release the memory after an ldb_search(). (This used to be commit 4f0948dab0aa5e8b6a4ce486f3668ca8dfae23db) --- source4/lib/ldb/tools/ldbdel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 72540db07a..ec2e302b20 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -55,7 +55,7 @@ static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) } } - ldb_search_free(ldb, res); + talloc_free(res); if (total == 0) { return -1; -- cgit From ed3d8091ce2b2014350a2f7f22202dde6846a130 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 07:42:21 +0000 Subject: r7709: - convert ldb to use popt, so that it can interact with the samba cmdline credentials code (which will be done soon) - added a ldb_init() call, and changed ldb_connect() to take a ldb context. This allows for much better error handling in ldb_connect(), and also made the popt conversion easier - fixed up all the existing backends with the new syntax - improved error handling in *_connect() - fixed a crash bug in the new case_fold_required() code - ensured that ltdb_rename() and all ltdb_search() paths get the read lock - added a ldb_oom() macro to make it easier to report out of memory situations in ldb code (This used to be commit f648fdf187669d6d87d01dd4e786b03cd420f220) --- source4/lib/ldb/tools/ldbdel.c | 64 +++++++++++------------------------------- 1 file changed, 17 insertions(+), 47 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index ec2e302b20..fcf1d26d53 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -35,6 +35,7 @@ #include "includes.h" #include "ldb/include/ldb.h" #include "ldb/include/ldb_private.h" +#include "ldb/tools/cmdline.h" #ifdef _SAMBA_BUILD_ #include "system/filesys.h" @@ -77,72 +78,41 @@ static void usage(void) exit(1); } - int main(int argc, char * const argv[]) + int main(int argc, const char **argv) { struct ldb_context *ldb; - const char **options = NULL; - int ldbopts; int ret, i; - const char *ldb_url; - int opt, recursive=0; - - ldb_url = getenv("LDB_URL"); - - ldbopts = 0; - while ((opt = getopt(argc, argv, "hH:ro:")) != EOF) { - switch (opt) { - case 'H': - ldb_url = optarg; - break; - - case 'r': - recursive=1; - break; - - case 'o': - options = ldb_options_parse(options, &ldbopts, optarg); - break; - - case 'h': - default: - usage(); - break; - } - } + struct ldb_cmdline *options; - if (!ldb_url) { - fprintf(stderr, "You must specify a ldb URL\n\n"); - usage(); - } + ldb = ldb_init(NULL); - argc -= optind; - argv += optind; + options = ldb_cmdline_process(ldb, argc, argv, usage); - if (argc < 1) { + if (options->argc < 1) { usage(); exit(1); } - ldb = ldb_connect(ldb_url, 0, options); - if (!ldb) { - perror("ldb_connect"); + ret = ldb_connect(ldb, options->url, 0, options->options); + if (ret != 0) { + fprintf(stderr, "Failed to connect to %s - %s\n", + options->url, ldb_errstring(ldb)); + talloc_free(ldb); exit(1); } - ldb_set_debug_stderr(ldb); - - for (i=0;iargc;i++) { + const char *dn = options->argv[i]; + if (options->recursive) { + ret = ldb_delete_recursive(ldb, dn); } else { - ret = ldb_delete(ldb, argv[i]); + ret = ldb_delete(ldb, dn); if (ret == 0) { printf("Deleted 1 record\n"); } } if (ret != 0) { - printf("delete of '%s' failed - %s\n", - argv[i], ldb_errstring(ldb)); + printf("delete of '%s' failed - %s\n", dn, ldb_errstring(ldb)); } } -- 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/ldbdel.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index fcf1d26d53..fdb1f7ef3b 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -93,14 +93,6 @@ static void usage(void) exit(1); } - ret = ldb_connect(ldb, options->url, 0, options->options); - if (ret != 0) { - fprintf(stderr, "Failed to connect to %s - %s\n", - options->url, ldb_errstring(ldb)); - talloc_free(ldb); - exit(1); - } - for (i=0;iargc;i++) { const char *dn = options->argv[i]; if (options->recursive) { -- 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/ldbdel.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index fdb1f7ef3b..6082931e22 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -41,7 +41,7 @@ #include "system/filesys.h" #endif -static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) +static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn) { int ret, i, total=0; const char *attrs[] = { "dn", NULL }; @@ -94,7 +94,13 @@ static void usage(void) } for (i=0;iargc;i++) { - const char *dn = options->argv[i]; + const struct ldb_dn *dn; + + dn = ldb_dn_explode(ldb, options->argv[i]); + if (dn == NULL) { + printf("Invalid DN format\n"); + exit(1); + } if (options->recursive) { ret = ldb_delete_recursive(ldb, dn); } else { @@ -104,7 +110,9 @@ static void usage(void) } } if (ret != 0) { - printf("delete of '%s' failed - %s\n", dn, ldb_errstring(ldb)); + printf("delete of '%s' failed - %s\n", + ldb_dn_linearize(ldb, dn), + ldb_errstring(ldb)); } } -- 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/ldbdel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 6082931e22..bd40fccbdb 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -44,10 +44,10 @@ static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn) { int ret, i, total=0; - const char *attrs[] = { "dn", NULL }; + const char *attrs[] = { NULL }; struct ldb_message **res; - ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "dn=*", attrs, &res); + ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "distinguishedName=*", attrs, &res); if (ret <= 0) return -1; for (i=0;i Date: Tue, 8 Nov 2005 00:11:45 +0000 Subject: r11567: Ldb API change patch. This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780) --- source4/lib/ldb/tools/ldbdel.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index bd40fccbdb..6da8d0269f 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -34,6 +34,7 @@ #include "includes.h" #include "ldb/include/ldb.h" +#include "ldb/include/ldb_errors.h" #include "ldb/include/ldb_private.h" #include "ldb/tools/cmdline.h" @@ -45,13 +46,13 @@ static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn { int ret, i, total=0; const char *attrs[] = { NULL }; - struct ldb_message **res; + struct ldb_result *res; ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "distinguishedName=*", attrs, &res); - if (ret <= 0) return -1; + if (ret != LDB_SUCCESS) return -1; - for (i=0;idn) == 0) { + for (i = 0; i < res->count; i++) { + if (ldb_delete(ldb, res->msgs[i]->dn) == 0) { total++; } } -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/lib/ldb/tools/ldbdel.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 6da8d0269f..a6574a5088 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -35,7 +35,6 @@ #include "includes.h" #include "ldb/include/ldb.h" #include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" #include "ldb/tools/cmdline.h" #ifdef _SAMBA_BUILD_ -- cgit From c908d0b2aa111659e57a73efb8c33c413965c846 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 04:01:23 +0000 Subject: r12733: Merge ldap/ldb controls into main tree There's still lot of work to do but the patch is stable enough to be pushed into the main samba4 tree. Simo. (This used to be commit 77125feaff252cab44d26593093a9c211c846ce8) --- source4/lib/ldb/tools/ldbdel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index a6574a5088..6da8d0269f 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -35,6 +35,7 @@ #include "includes.h" #include "ldb/include/ldb.h" #include "ldb/include/ldb_errors.h" +#include "ldb/include/ldb_private.h" #include "ldb/tools/cmdline.h" #ifdef _SAMBA_BUILD_ -- 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/ldbdel.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 6da8d0269f..26544d8a9e 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -33,15 +33,9 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb/include/includes.h" #include "ldb/tools/cmdline.h" -#ifdef _SAMBA_BUILD_ -#include "system/filesys.h" -#endif - static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn) { int ret, i, total=0; -- 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/ldbdel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 26544d8a9e..749ce3f91c 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -79,6 +79,8 @@ static void usage(void) int ret, i; struct ldb_cmdline *options; + ldb_global_init(); + ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); -- 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/ldbdel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 749ce3f91c..aee911efaf 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -73,7 +73,7 @@ static void usage(void) exit(1); } - int main(int argc, const char **argv) +int main(int argc, const char **argv) { struct ldb_context *ldb; int ret, i; -- cgit From 04140ac3c75e3bdb2fad4b534d86c5fafabe58c5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 14 Oct 2006 08:26:10 +0000 Subject: r19274: fix ldbdel and ldbmodify to return an error if the underlying ldb call fails (This used to be commit 330a722f1330059cbba19f99210a1a5a7c773a36) --- source4/lib/ldb/tools/ldbdel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index aee911efaf..94f1da9903 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -76,7 +76,7 @@ static void usage(void) int main(int argc, const char **argv) { struct ldb_context *ldb; - int ret, i; + int ret = 0, i; struct ldb_cmdline *options; ldb_global_init(); @@ -115,5 +115,5 @@ int main(int argc, const char **argv) talloc_free(ldb); - return 0; + return ret; } -- cgit From 4889eb9f7aae9349e426d0f6d2217adff67eaebd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 00:59:34 +0000 Subject: r19831: Big ldb_dn optimization and interfaces enhancement patch This patch changes a lot of the code in ldb_dn.c, and also removes and add a number of manipulation functions around. The aim is to avoid validating a dn if not necessary as the validation code is necessarily slow. This is mainly to speed up internal operations where input is not user generated and so we can assume the DNs need no validation. The code is designed to keep the data as a string if possible. The code is not yet 100% perfect, but pass all the tests so far. A memleak is certainly present, I'll work on that next. Simo. (This used to be commit a580c871d3784602a9cce32d33419e63c8236e63) --- source4/lib/ldb/tools/ldbdel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 94f1da9903..b4da806b51 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -36,7 +36,7 @@ #include "ldb/include/includes.h" #include "ldb/tools/cmdline.h" -static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn) +static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn) { int ret, i, total=0; const char *attrs[] = { NULL }; @@ -91,10 +91,10 @@ int main(int argc, const char **argv) } for (i=0;iargc;i++) { - const struct ldb_dn *dn; + struct ldb_dn *dn; - dn = ldb_dn_explode(ldb, options->argv[i]); - if (dn == NULL) { + dn = ldb_dn_new(ldb, ldb, options->argv[i]); + if ( ! ldb_dn_validate(dn)) { printf("Invalid DN format\n"); exit(1); } -- cgit From a9e31b33b55a873c2f01db5e348560176adf863d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 02:05:19 +0000 Subject: r19832: better prototypes for the linearization functions: - ldb_dn_get_linearized returns a const string - ldb_dn_alloc_linearized allocs astring with the linearized dn (This used to be commit 3929c086d5d0b3f08b1c4f2f3f9602c3f4a9a4bd) --- source4/lib/ldb/tools/ldbdel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index b4da806b51..c6c691d875 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -108,7 +108,7 @@ int main(int argc, const char **argv) } if (ret != 0) { printf("delete of '%s' failed - %s\n", - ldb_dn_linearize(ldb, dn), + ldb_dn_get_linearized(dn), ldb_errstring(ldb)); } } -- cgit From 52fb06edc25e8538c413df1aaabba18c859a00cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 May 2007 18:50:56 +0000 Subject: r22681: Fix standalone ldb build when parent directory name != ldb. (This used to be commit 1093875d59f1ea9b8bd82277d4f9d8366e584952) --- source4/lib/ldb/tools/ldbdel.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index c6c691d875..187a0de7af 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -32,9 +32,8 @@ * Author: Andrew Tridgell */ -#include "includes.h" -#include "ldb/include/includes.h" -#include "ldb/tools/cmdline.h" +#include "ldb_includes.h" +#include "tools/cmdline.h" static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn) { -- 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/ldbdel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 187a0de7af..9e0f3a3fac 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.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/ldbdel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 9e0f3a3fac..fcd0978779 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.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 . */ /* -- 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/ldbdel.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index fcd0978779..184172b22b 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -77,8 +77,6 @@ int main(int argc, const char **argv) int ret = 0, i; struct ldb_cmdline *options; - ldb_global_init(); - ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); -- cgit From 929adc9efa5cf985f0585214d30d18521aa1a821 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 11:24:17 -0400 Subject: Make up the right dependencies now that ldb depends on libevents (This used to be commit 3b8eec7ca334528cad3cdcd5e3fc5ee555d8d0e0) --- source4/lib/ldb/tools/ldbdel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbdel.c') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 184172b22b..e66d4fb973 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -77,7 +77,7 @@ int main(int argc, const char **argv) int ret = 0, i; struct ldb_cmdline *options; - ldb = ldb_init(NULL); + ldb = ldb_init(NULL, NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); -- cgit