summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/tools
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-07-16 13:35:07 +0300
committerAndrew Bartlett <abartlet@samba.org>2010-07-19 17:33:33 +1000
commitfa0db46af16080dd3a540072f7ad664c0b9270ca (patch)
treea2c9603bf6e2605bd03794bcfec4ceced13332cf /source4/lib/ldb/tools
parentfb1c0796c7c533f468b74d55507e9877b93ead72 (diff)
downloadsamba-fa0db46af16080dd3a540072f7ad664c0b9270ca.tar.gz
samba-fa0db46af16080dd3a540072f7ad664c0b9270ca.tar.bz2
samba-fa0db46af16080dd3a540072f7ad664c0b9270ca.zip
s4-tools: use ldb_msg_difference() in ldbedit - modify_record()
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/lib/ldb/tools')
-rw-r--r--source4/lib/ldb/tools/ldbedit.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index f28964b06a..bb23f56377 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -67,16 +67,17 @@ static int modify_record(struct ldb_context *ldb,
struct ldb_message *msg2,
struct ldb_control **req_ctrls)
{
+ int ret;
struct ldb_message *mod;
- mod = ldb_msg_diff(ldb, msg1, msg2);
- if (mod == NULL) {
+ if (ldb_msg_difference(ldb, ldb, msg1, msg2, &mod) != LDB_SUCCESS) {
fprintf(stderr, "Failed to calculate message differences\n");
return -1;
}
- if (mod->num_elements == 0) {
- return 0;
+ ret = mod->num_elements;
+ if (ret == 0) {
+ goto done;
}
if (options->verbose > 0) {
@@ -86,10 +87,13 @@ static int modify_record(struct ldb_context *ldb,
if (ldb_modify_ctrl(ldb, mod, req_ctrls) != 0) {
fprintf(stderr, "failed to modify %s - %s\n",
ldb_dn_get_linearized(msg1->dn), ldb_errstring(ldb));
- return -1;
+ ret = -1;
+ goto done;
}
- return mod->num_elements;
+done:
+ talloc_free(mod);
+ return ret;
}
/*