summaryrefslogtreecommitdiff
path: root/source3/lib/ldb/tools
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-10-21 00:10:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:35 -0500
commit7a390a0dabcdadb30196662b6cdec512bf81dcb4 (patch)
tree8ed126e072e4446ad47d25f277059af5ccd556cc /source3/lib/ldb/tools
parentaa3ca346d82da2501406cc1f482643b20905e467 (diff)
downloadsamba-7a390a0dabcdadb30196662b6cdec512bf81dcb4.tar.gz
samba-7a390a0dabcdadb30196662b6cdec512bf81dcb4.tar.bz2
samba-7a390a0dabcdadb30196662b6cdec512bf81dcb4.zip
r19430: merge recent ldb changes from Samba4. This includes memory leak fixes
and significant speedups (This used to be commit bb5c205fef90aa8b89ba400fb9f2f37a111676a8)
Diffstat (limited to 'source3/lib/ldb/tools')
-rw-r--r--source3/lib/ldb/tools/ad2oLschema.c4
-rw-r--r--source3/lib/ldb/tools/ldbadd.c16
-rw-r--r--source3/lib/ldb/tools/ldbdel.c4
-rw-r--r--source3/lib/ldb/tools/ldbmodify.c22
-rw-r--r--source3/lib/ldb/tools/ldbsearch.c2
5 files changed, 22 insertions, 26 deletions
diff --git a/source3/lib/ldb/tools/ad2oLschema.c b/source3/lib/ldb/tools/ad2oLschema.c
index 8b1203bff0..62c6e01c2e 100644
--- a/source3/lib/ldb/tools/ad2oLschema.c
+++ b/source3/lib/ldb/tools/ad2oLschema.c
@@ -330,7 +330,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
int j;
/* We have been asked to skip some attributes/objectClasses */
- if (str_list_check_ci(attrs_skip, name)) {
+ if (attrs_skip && str_list_check_ci(attrs_skip, name)) {
ret.skipped++;
continue;
}
@@ -436,7 +436,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
int j;
/* We have been asked to skip some attributes/objectClasses */
- if (str_list_check_ci(attrs_skip, name)) {
+ if (attrs_skip && str_list_check_ci(attrs_skip, name)) {
ret.skipped++;
continue;
}
diff --git a/source3/lib/ldb/tools/ldbadd.c b/source3/lib/ldb/tools/ldbadd.c
index 6a0f510244..9595703e92 100644
--- a/source3/lib/ldb/tools/ldbadd.c
+++ b/source3/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;i<options->argc;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;
}
diff --git a/source3/lib/ldb/tools/ldbdel.c b/source3/lib/ldb/tools/ldbdel.c
index aee911efaf..94f1da9903 100644
--- a/source3/lib/ldb/tools/ldbdel.c
+++ b/source3/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;
}
diff --git a/source3/lib/ldb/tools/ldbmodify.c b/source3/lib/ldb/tools/ldbmodify.c
index 24f9386266..962045ef7d 100644
--- a/source3/lib/ldb/tools/ldbmodify.c
+++ b/source3/lib/ldb/tools/ldbmodify.c
@@ -53,10 +53,10 @@ static void usage(void)
/*
process modifies for one 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 = -1, count = 0;
+ int ret = LDB_SUCCESS;
while ((ldif = ldb_ldif_read_file(ldb, f))) {
switch (ldif->changetype) {
@@ -71,24 +71,24 @@ static int process_file(struct ldb_context *ldb, FILE *f)
ret = ldb_modify(ldb, ldif->msg);
break;
}
- if (ret != 0) {
+ if (ret != LDB_SUCCESS) {
fprintf(stderr, "ERR: \"%s\" on DN %s\n",
ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn));
failures++;
} else {
- count++;
+ (*count)++;
}
ldb_ldif_read_free(ldb, ldif);
}
- return count;
+ return ret;
}
int main(int argc, const char **argv)
{
struct ldb_context *ldb;
int count=0;
- int i;
+ int i, ret=LDB_SUCCESS;
struct ldb_cmdline *options;
ldb_global_init();
@@ -98,7 +98,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;i<options->argc;i++) {
const char *fname = options->argv[i];
@@ -108,7 +108,7 @@ int main(int argc, const char **argv)
perror(fname);
exit(1);
}
- count += process_file(ldb, f);
+ ret = process_file(ldb, f, &count);
}
}
@@ -116,9 +116,5 @@ int main(int argc, const char **argv)
printf("Modified %d records with %d failures\n", count, failures);
- if (failures != 0) {
- return -1;
- }
-
- return 0;
+ return ret;
}
diff --git a/source3/lib/ldb/tools/ldbsearch.c b/source3/lib/ldb/tools/ldbsearch.c
index 23d8115c20..837dfc9088 100644
--- a/source3/lib/ldb/tools/ldbsearch.c
+++ b/source3/lib/ldb/tools/ldbsearch.c
@@ -215,7 +215,7 @@ static int do_search(struct ldb_context *ldb,
req->operation = LDB_SEARCH;
req->op.search.base = basedn;
req->op.search.scope = options->scope;
- req->op.search.tree = ldb_parse_tree(ldb, expression);
+ req->op.search.tree = ldb_parse_tree(req, expression);
if (req->op.search.tree == NULL) return -1;
req->op.search.attrs = attrs;
req->controls = sctx->req_ctrls;