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/ldbadd.c | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 source4/lib/ldb/tools/ldbadd.c (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c new file mode 100644 index 0000000000..3eb7cb8de2 --- /dev/null +++ b/source4/lib/ldb/tools/ldbadd.c @@ -0,0 +1,74 @@ +/* + 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: ldbadd + * + * Description: utility to add records - modelled on ldapadd + * + * Author: Andrew Tridgell + */ + +#include "includes.h" + + int main(void) +{ + static struct ldb_context *ldb; + struct ldb_message *msg; + int ret; + int count=0, failures=0; + const char *ldb_url; + + ldb_url = getenv("LDB_URL"); + if (!ldb_url) { + ldb_url = "tdb://test.ldb"; + } + + ldb = ldb_connect(ldb_url, 0, NULL); + + if (!ldb) { + perror("ldb_connect"); + exit(1); + } + + while ((msg = ldif_read_file(stdin))) { + ret = ldb_add(ldb, msg); + if (ret != 0) { + fprintf(stderr, "ERR: \"%s\" on DN %s\n", + ldb_errstring(ldb), msg->dn); + failures++; + } else { + count++; + } + ldif_read_free(msg); + } + + ldb_close(ldb); + + printf("Added %d records with %d failures\n", count, failures); + + return 0; +} -- cgit From ee44733f94864fb0a1ae15d48e3335c0705a82ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Apr 2004 12:29:21 +0000 Subject: added the rest of the ldb_modify() code, which required a fairly large change in the ldb API. The API is now much closer to LDAP. (This used to be commit e9e85c464411c561c5073d262a2e3533fec175ca) --- source4/lib/ldb/tools/ldbadd.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 3eb7cb8de2..92ed29e6b8 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -37,7 +37,7 @@ int main(void) { static struct ldb_context *ldb; - struct ldb_message *msg; + struct ldb_ldif *ldif; int ret; int count=0, failures=0; const char *ldb_url; @@ -54,16 +54,23 @@ exit(1); } - while ((msg = ldif_read_file(stdin))) { - ret = ldb_add(ldb, msg); + while ((ldif = ldif_read_file(stdin))) { + + if (ldif->changetype != LDB_CHANGETYPE_ADD && + ldif->changetype != LDB_CHANGETYPE_NONE) { + fprintf(stderr, "Only CHANGETYPE_ADD records allowed\n"); + break; + } + + ret = ldb_add(ldb, &ldif->msg); if (ret != 0) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", - ldb_errstring(ldb), msg->dn); + ldb_errstring(ldb), ldif->msg.dn); failures++; } else { count++; } - ldif_read_free(msg); + ldif_read_free(ldif); } ldb_close(ldb); -- cgit From ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell 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/ldbadd.c | 99 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 18 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 92ed29e6b8..446c0d80f9 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -34,28 +34,28 @@ #include "includes.h" - int main(void) -{ - static struct ldb_context *ldb; - struct ldb_ldif *ldif; - int ret; - int count=0, failures=0; - const char *ldb_url; - - ldb_url = getenv("LDB_URL"); - if (!ldb_url) { - ldb_url = "tdb://test.ldb"; - } +static int failures; - ldb = ldb_connect(ldb_url, 0, NULL); +static void usage(void) +{ + printf("Usage: ldbadd \n"); + printf("Options:\n"); + printf(" -H ldb_url choose the database (or $LDB_URL)\n"); + printf("\n"); + printf("Adds records to a ldb, reading ldif the specified list of files\n\n"); + exit(1); +} - if (!ldb) { - perror("ldb_connect"); - exit(1); - } - while ((ldif = ldif_read_file(stdin))) { +/* + add records from an opened file +*/ +static int process_file(struct ldb_context *ldb, FILE *f) +{ + struct ldb_ldif *ldif; + int ret, count=0; + while ((ldif = ldif_read_file(f))) { if (ldif->changetype != LDB_CHANGETYPE_ADD && ldif->changetype != LDB_CHANGETYPE_NONE) { fprintf(stderr, "Only CHANGETYPE_ADD records allowed\n"); @@ -73,6 +73,69 @@ ldif_read_free(ldif); } + return count; +} + + + + int main(int argc, char * const argv[]) +{ + struct ldb_context *ldb; + int count=0; + const char *ldb_url; + int opt, i; + + 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) { + fprintf(stderr, "You must specify a ldb URL\n"); + exit(1); + } + + argc -= optind; + argv += optind; + + ldb = ldb_connect(ldb_url, 0, NULL); + + if (!ldb) { + perror("ldb_connect"); + exit(1); + } + + if (argc == 0) { + usage(); + } + + for (i=0;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/ldbadd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 446c0d80f9..15febb76e7 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -101,8 +101,8 @@ static int process_file(struct ldb_context *ldb, FILE *f) } 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 d8ce7c6a2acbf371509a23775470e7614bcb6027 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 04:40:15 +0000 Subject: r502: modified ldb to allow the use of an external pool memory allocator. The way to use this is to call ldb_set_alloc() with a function pointer to whatever memory allocator you like. It includes a context pointer to allow for pool based allocators. (This used to be commit 3955c482e6c2c9e975a4bb809ec8cb6068e48e34) --- source4/lib/ldb/tools/ldbadd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 15febb76e7..6d89f67e0f 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -55,7 +55,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) struct ldb_ldif *ldif; int ret, count=0; - while ((ldif = ldif_read_file(f))) { + while ((ldif = ldif_read_file(ldb, f))) { if (ldif->changetype != LDB_CHANGETYPE_ADD && ldif->changetype != LDB_CHANGETYPE_NONE) { fprintf(stderr, "Only CHANGETYPE_ADD records allowed\n"); @@ -70,7 +70,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) } else { count++; } - ldif_read_free(ldif); + ldif_read_free(ldb, ldif); } return count; -- 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/ldbadd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 6d89f67e0f..a45021c1d9 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -115,6 +115,8 @@ static int process_file(struct ldb_context *ldb, FILE *f) exit(1); } + ldb_set_debug_stderr(ldb); + if (argc == 0) { usage(); } -- cgit From f0a8f718ff474009300af6746fa0fbb61c649ea9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell 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/ldbadd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index a45021c1d9..9383197ed0 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -55,7 +55,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) struct ldb_ldif *ldif; int ret, count=0; - while ((ldif = ldif_read_file(ldb, f))) { + while ((ldif = ldb_ldif_read_file(ldb, f))) { if (ldif->changetype != LDB_CHANGETYPE_ADD && ldif->changetype != LDB_CHANGETYPE_NONE) { fprintf(stderr, "Only CHANGETYPE_ADD records allowed\n"); @@ -70,7 +70,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) } else { count++; } - ldif_read_free(ldb, ldif); + ldb_ldif_read_free(ldb, ldif); } return count; -- cgit From 679e95db033fd11d17c1f1ac5e44f6cc4df2220e Mon Sep 17 00:00:00 2001 From: Simo Sorce 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/ldbadd.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 9383197ed0..6d04800502 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -83,16 +83,34 @@ static int process_file(struct ldb_context *ldb, FILE *f) struct ldb_context *ldb; int count=0; const char *ldb_url; + const char **options = NULL; + int ldbopts; int opt, i; ldb_url = getenv("LDB_URL"); - while ((opt = getopt(argc, argv, "hH:")) != EOF) { + ldbopts = 0; + while ((opt = getopt(argc, argv, "hH:o:")) != EOF) { switch (opt) { case 'H': ldb_url = optarg; 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 int process_file(struct ldb_context *ldb, FILE *f) argc -= optind; argv += optind; - ldb = ldb_connect(ldb_url, 0, NULL); + ldb = ldb_connect(ldb_url, 0, options); if (!ldb) { perror("ldb_connect"); -- 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/ldbadd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 6d04800502..b0c9d8a366 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -41,6 +41,8 @@ static void usage(void) printf("Usage: ldbadd \n"); printf("Options:\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("Adds records to a ldb, reading ldif the specified list of files\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/ldbadd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index b0c9d8a366..d7f890b155 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static int failures; -- 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/ldbadd.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index d7f890b155..9d19a1db0a 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -34,6 +34,7 @@ #include "includes.h" #include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" static int failures; @@ -100,18 +101,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) 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 1a988ec9af7960616fb4661b20d86ff05146d836 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 07:49:29 +0000 Subject: r4474: - converted ldb to use talloc internally - added gcov flags to Makefile.ldb - expanded ldb test suite to get more coverage (This used to be commit 0ab98f50a7e0fe15347a99e5c29a6590a87729a0) --- source4/lib/ldb/tools/ldbadd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 9d19a1db0a..d95036497a 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -66,10 +66,10 @@ static int process_file(struct ldb_context *ldb, FILE *f) break; } - ret = ldb_add(ldb, &ldif->msg); + ret = ldb_add(ldb, ldif->msg); if (ret != 0) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", - ldb_errstring(ldb), ldif->msg.dn); + ldb_errstring(ldb), ldif->msg->dn); failures++; } else { count++; -- 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/ldbadd.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index d95036497a..927debc65e 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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 failures; static void usage(void) -- 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/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 927debc65e..41273a08da 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -153,7 +153,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) } } - ldb_close(ldb); + talloc_free(ldb); printf("Added %d records with %d failures\n", count, failures); -- cgit From da3816690419401d85ab8bf7cee89ac912b152b0 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Wed, 30 Mar 2005 00:15:16 +0000 Subject: r6118: Make it so that we can do --with-zlib=no in configure and also a couple of small typos. (This used to be commit 9b4069e84573f85ce4341ceacd35737a18726a0b) --- source4/lib/ldb/tools/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 41273a08da..818c33a11d 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -116,7 +116,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) } if (!ldb_url) { - fprintf(stderr, "You must specify a ldb URL\n\n"); + fprintf(stderr, "You must specify an ldb URL\n\n"); usage(); } -- 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/ldbadd.c | 78 +++++++++++++----------------------------- 1 file changed, 23 insertions(+), 55 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 818c33a11d..35a41527be 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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" @@ -86,69 +87,36 @@ static int process_file(struct ldb_context *ldb, FILE *f) - int main(int argc, char * const argv[]) + int main(int argc, const char **argv) { struct ldb_context *ldb; - int count=0; - const char *ldb_url; - const char **options = NULL; - int ldbopts; - int opt, i; - - ldb_url = getenv("LDB_URL"); - - ldbopts = 0; - while ((opt = getopt(argc, argv, "hH:o:")) != EOF) { - switch (opt) { - case 'H': - ldb_url = optarg; - break; - - case 'o': - options = ldb_options_parse(options, &ldbopts, optarg); - break; - - case 'h': - default: - usage(); - break; - } - } + int i, ret, count=0; + struct ldb_cmdline *options; - if (!ldb_url) { - fprintf(stderr, "You must specify an ldb URL\n\n"); - usage(); - } + ldb = ldb_init(NULL); - argc -= optind; - argv += optind; + options = ldb_cmdline_process(ldb, argc, argv, usage); - 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); - - if (argc == 0) { - usage(); - } - - for (i=0;iargc == 0) { + count += process_file(ldb, stdin); + } else { + for (i=0;iargc;i++) { + const char *fname = options->argv[i]; + FILE *f; + f = fopen(fname, "r"); + if (!f) { + perror(fname); + exit(1); + } + count += process_file(ldb, f); fclose(f); } } -- 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/ldbadd.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 35a41527be..7794b9de39 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -90,21 +90,13 @@ static int process_file(struct ldb_context *ldb, FILE *f) int main(int argc, const char **argv) { struct ldb_context *ldb; - int i, ret, count=0; + int i, count=0; struct ldb_cmdline *options; ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); - 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); - } - if (options->argc == 0) { count += process_file(ldb, stdin); } else { -- cgit From b818ff3ede56ab905418dddbc0bdc2011ebf62ab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 24 Jun 2005 01:58:40 +0000 Subject: r7868: canonicalise the message before using ldb_add() in the ldbadd utility. (This used to be commit 56f4af5f210da472d41d9bcf6918647181f6ad16) --- source4/lib/ldb/tools/ldbadd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 7794b9de39..5be3b7fc75 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -71,6 +71,8 @@ static int process_file(struct ldb_context *ldb, FILE *f) break; } + ldif->msg = ldb_msg_canonicalize(ldb, ldif->msg); + ret = ldb_add(ldb, ldif->msg); if (ret != 0) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", -- 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/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 5be3b7fc75..de6da0eb5b 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -76,7 +76,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) ret = ldb_add(ldb, ldif->msg); if (ret != 0) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", - ldb_errstring(ldb), ldif->msg->dn); + ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn)); failures++; } else { count++; -- cgit From 16aff2a184f7fab64d718b356056070e305e99e9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 18 Sep 2005 18:49:06 +0000 Subject: r10305: start implementing better error handling changed the prioivate modules API error string are now not spread over all modules but are kept in a single place. This allows a better control of memory and error reporting. (This used to be commit 3fc676ac1d6f59d08bedbbd9377986154cf84ce4) --- source4/lib/ldb/tools/ldbadd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index de6da0eb5b..ba58f782f0 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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" @@ -74,7 +75,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) ldif->msg = ldb_msg_canonicalize(ldb, ldif->msg); ret = ldb_add(ldb, ldif->msg); - if (ret != 0) { + if (ret != LDB_ERR_SUCCESS) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn)); failures++; -- cgit From 63b43dd12fb579aaaccedd07aaa630cb1cd7aa88 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 24 Sep 2005 15:42:15 +0000 Subject: r10477: expose transactions outside ldb and change the API once more do not autostart transactions on ldb operations if a transaction is already in place test transactions on winsdb all my tests passes so far tridge please confirm this is ok for you (This used to be commit c2bb2a36bdbe0ec7519697a9a9ba7526a0defac2) --- source4/lib/ldb/tools/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index ba58f782f0..058f4dc751 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -75,7 +75,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) ldif->msg = ldb_msg_canonicalize(ldb, ldif->msg); ret = ldb_add(ldb, ldif->msg); - if (ret != LDB_ERR_SUCCESS) { + if (ret != LDB_SUCCESS) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn)); failures++; -- 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/ldbadd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 058f4dc751..c22cfde4ec 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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/ldbadd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index c22cfde4ec..058f4dc751 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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/ldbadd.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 058f4dc751..0d5acd3787 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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 failures; static void usage(void) -- 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/ldbadd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 0d5acd3787..6a0f510244 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -84,12 +84,14 @@ static int process_file(struct ldb_context *ldb, FILE *f) - int main(int argc, const char **argv) +int main(int argc, const char **argv) { struct ldb_context *ldb; int i, count=0; struct ldb_cmdline *options; + ldb_global_init(); + ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); -- cgit From 2ad8e1443de55a005cb9249ba317ab8541ec7c90 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 14 Oct 2006 04:43:51 +0000 Subject: r19273: - fixed error handling with the ldap backend - propogate errors to the ldbadd command line tool - use the rdn_name module when testing the tdb backend to allow the same test code to correctly test the ldap and non-ldap backends (This used to be commit dd82c474a123d90329bda653a4cb73c93e087b15) --- source4/lib/ldb/tools/ldbadd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 6a0f510244..9595703e92 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -54,10 +54,10 @@ static void usage(void) /* add records from an opened file */ -static int process_file(struct ldb_context *ldb, FILE *f) +static int process_file(struct ldb_context *ldb, FILE *f, int *count) { struct ldb_ldif *ldif; - int ret, count=0; + int ret = LDB_SUCCESS; while ((ldif = ldb_ldif_read_file(ldb, f))) { if (ldif->changetype != LDB_CHANGETYPE_ADD && @@ -74,12 +74,12 @@ static int process_file(struct ldb_context *ldb, FILE *f) ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn)); failures++; } else { - count++; + (*count)++; } ldb_ldif_read_free(ldb, ldif); } - return count; + return ret; } @@ -87,7 +87,7 @@ static int process_file(struct ldb_context *ldb, FILE *f) int main(int argc, const char **argv) { struct ldb_context *ldb; - int i, count=0; + int i, ret=0, count=0; struct ldb_cmdline *options; ldb_global_init(); @@ -97,7 +97,7 @@ int main(int argc, const char **argv) options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc == 0) { - count += process_file(ldb, stdin); + ret = process_file(ldb, stdin, &count); } else { for (i=0;iargc;i++) { const char *fname = options->argv[i]; @@ -107,7 +107,7 @@ int main(int argc, const char **argv) perror(fname); exit(1); } - count += process_file(ldb, f); + ret = process_file(ldb, f, &count); fclose(f); } } @@ -116,5 +116,5 @@ int main(int argc, const char **argv) printf("Added %d records with %d failures\n", count, failures); - return 0; + return ret; } -- 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/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 9595703e92..8e75bccacc 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -71,7 +71,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count) ret = ldb_add(ldb, ldif->msg); if (ret != LDB_SUCCESS) { fprintf(stderr, "ERR: \"%s\" on DN %s\n", - ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn)); + ldb_errstring(ldb), ldb_dn_get_linearized(ldif->msg->dn)); failures++; } else { (*count)++; -- 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/ldbadd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 8e75bccacc..93147dc715 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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 failures; -- 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/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 93147dc715..2432ab2d8f 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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/ldbadd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 2432ab2d8f..d34193b86c 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.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/ldbadd.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index d34193b86c..4ee66c4fc0 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -88,8 +88,6 @@ int main(int argc, const char **argv) int i, ret=0, count=0; 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/ldbadd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 4ee66c4fc0..15376e7342 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -88,7 +88,7 @@ int main(int argc, const char **argv) int i, ret=0, count=0; struct ldb_cmdline *options; - ldb = ldb_init(NULL); + ldb = ldb_init(NULL, NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); -- cgit