summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/tools
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/tools')
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c4
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c6
-rw-r--r--source4/lib/ldb/tools/ldbtest.c31
4 files changed, 28 insertions, 15 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 739c3b6301..debe06c231 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -218,7 +218,7 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int coun
fclose(f);
- ldb_asprintf(ldb, &cmd, "%s %s", editor, template);
+ asprintf(&cmd, "%s %s", editor, template);
if (!cmd) {
unlink(template);
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index 9f7cbe4527..828b7d4865 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -144,6 +144,10 @@ static int process_file(struct ldb_context *ldb, FILE *f)
ldb_close(ldb);
printf("Modified %d records with %d failures\n", count, failures);
+
+ if (failures != 0) {
+ return -1;
+ }
return 0;
}
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index f80f81b50e..478601ec7e 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -49,7 +49,7 @@ static int do_search(struct ldb_context *ldb,
const char *basedn,
int scope,
const char *expression,
- char * const *attrs)
+ const char * const *attrs)
{
int ret, i;
struct ldb_message **msgs;
@@ -86,7 +86,7 @@ static int do_search(struct ldb_context *ldb,
int main(int argc, char * const argv[])
{
struct ldb_context *ldb;
- char * const * attrs = NULL;
+ const char * const * attrs = NULL;
const char *ldb_url;
const char *basedn = NULL;
int opt;
@@ -140,7 +140,7 @@ static int do_search(struct ldb_context *ldb,
}
if (argc > 1) {
- attrs = argv+1;
+ attrs = (const char * const *)(argv+1);
}
ldb = ldb_connect(ldb_url, 0, NULL);
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index fc224115f5..d7b4023895 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -59,7 +59,8 @@ static void add_records(struct ldb_context *ldb,
struct ldb_message_element el[6];
struct ldb_val vals[6][1];
char *name;
-
+ int j;
+
asprintf(&name, "Test%d", i);
asprintf(&msg.dn, "cn=%s,%s", name, basedn);
@@ -67,42 +68,42 @@ static void add_records(struct ldb_context *ldb,
msg.elements = el;
el[0].flags = 0;
- el[0].name = "cn";
+ el[0].name = strdup("cn");
el[0].num_values = 1;
el[0].values = vals[0];
vals[0][0].data = name;
vals[0][0].length = strlen(name);
el[1].flags = 0;
- el[1].name = "title";
+ el[1].name = strdup("title");
el[1].num_values = 1;
el[1].values = vals[1];
asprintf((char **)&vals[1][0].data, "The title of %s", name);
vals[1][0].length = strlen(vals[1][0].data);
el[2].flags = 0;
- el[2].name = "uid";
+ el[2].name = strdup("uid");
el[2].num_values = 1;
el[2].values = vals[2];
vals[2][0].data = ldb_casefold(ldb, name);
vals[2][0].length = strlen(vals[2][0].data);
el[3].flags = 0;
- el[3].name = "mail";
+ el[3].name = strdup("mail");
el[3].num_values = 1;
el[3].values = vals[3];
asprintf((char **)&vals[3][0].data, "%s@example.com", name);
vals[3][0].length = strlen(vals[3][0].data);
el[4].flags = 0;
- el[4].name = "objectClass";
+ el[4].name = strdup("objectClass");
el[4].num_values = 1;
el[4].values = vals[4];
- vals[4][0].data = "OpenLDAPperson";
+ vals[4][0].data = strdup("OpenLDAPperson");
vals[4][0].length = strlen(vals[4][0].data);
el[5].flags = 0;
- el[5].name = "sn";
+ el[5].name = strdup("sn");
el[5].num_values = 1;
el[5].values = vals[5];
vals[5][0].data = name;
@@ -118,11 +119,15 @@ static void add_records(struct ldb_context *ldb,
printf("adding uid %s\r", name);
fflush(stdout);
+ for (j=0;j<msg.num_elements;j++) {
+ free(el[j].name);
+ }
free(name);
free(msg.dn);
free(vals[1][0].data);
ldb_free(ldb, vals[2][0].data);
free(vals[3][0].data);
+ free(vals[4][0].data);
}
printf("\n");
@@ -139,6 +144,7 @@ static void modify_records(struct ldb_context *ldb,
struct ldb_message_element el[3];
struct ldb_val vals[3];
char *name;
+ int j;
asprintf(&name, "Test%d", i);
asprintf(&msg.dn, "cn=%s,%s", name, basedn);
@@ -147,18 +153,18 @@ static void modify_records(struct ldb_context *ldb,
msg.elements = el;
el[0].flags = LDB_FLAG_MOD_DELETE;
- el[0].name = "mail";
+ el[0].name = strdup("mail");
el[0].num_values = 0;
el[1].flags = LDB_FLAG_MOD_ADD;
- el[1].name = "mail";
+ el[1].name = strdup("mail");
el[1].num_values = 1;
el[1].values = &vals[1];
asprintf((char **)&vals[1].data, "%s@other.example.com", name);
vals[1].length = strlen(vals[1].data);
el[2].flags = LDB_FLAG_MOD_REPLACE;
- el[2].name = "mail";
+ el[2].name = strdup("mail");
el[2].num_values = 1;
el[2].values = &vals[2];
asprintf((char **)&vals[2].data, "%s@other2.example.com", name);
@@ -172,6 +178,9 @@ static void modify_records(struct ldb_context *ldb,
printf("Modifying uid %s\r", name);
fflush(stdout);
+ for (j=0;j<msg.num_elements;j++) {
+ free(el[j].name);
+ }
free(name);
free(msg.dn);
free(vals[1].data);