static struct ldb_message *msg_find(struct ldb_context *ldb,
struct ldb_message **msgs,
int count,
- const struct ldb_dn *dn)
+ struct ldb_dn *dn)
{
int i;
for (i=0;i<count;i++) {
- if (ldb_dn_compare(ldb, dn, msgs[i]->dn) == 0) {
+ if (ldb_dn_compare(dn, msgs[i]->dn) == 0) {
return msgs[i];
}
}
{
int fd, ret;
FILE *f;
- char template[] = "/tmp/ldbedit.XXXXXX";
+ char file_template[] = "/tmp/ldbedit.XXXXXX";
char *cmd;
struct ldb_ldif *ldif;
struct ldb_message **msgs2 = NULL;
/* write out the original set of messages to a temporary
file */
- fd = mkstemp(template);
+ fd = mkstemp(file_template);
if (fd == -1) {
- perror(template);
+ perror(file_template);
return -1;
}
if (!f) {
perror("fopen");
close(fd);
- unlink(template);
+ unlink(file_template);
return -1;
}
fclose(f);
- cmd = talloc_asprintf(ldb, "%s %s", editor, template);
+ cmd = talloc_asprintf(ldb, "%s %s", editor, file_template);
if (!cmd) {
- unlink(template);
+ unlink(file_template);
fprintf(stderr, "out of memory\n");
return -1;
}
talloc_free(cmd);
if (ret != 0) {
- unlink(template);
+ unlink(file_template);
fprintf(stderr, "edit with %s failed\n", editor);
return -1;
}
/* read the resulting ldif into msgs2 */
- f = fopen(template, "r");
+ f = fopen(file_template, "r");
if (!f) {
- perror(template);
+ perror(file_template);
return -1;
}
}
fclose(f);
- unlink(template);
+ unlink(file_template);
return merge_edits(ldb, msgs1, count1, msgs2, count2);
}
}
if (options->basedn != NULL) {
- basedn = ldb_dn_explode(ldb, options->basedn);
- if (basedn == NULL) {
+ basedn = ldb_dn_new(ldb, ldb, options->basedn);
+ if ( ! ldb_dn_validate(basedn)) {
printf("Invalid Base DN format\n");
exit(1);
}