diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-18 01:47:10 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-01-18 03:41:59 +0100 |
commit | 73626c266c3ea1b477185a428b2c1be64feff598 (patch) | |
tree | 428037597935fc6c2d581c5eb104d39587a6c472 /source4 | |
parent | 873c7457c61584aec8c051849863151af79e2894 (diff) | |
download | samba-73626c266c3ea1b477185a428b2c1be64feff598.tar.gz samba-73626c266c3ea1b477185a428b2c1be64feff598.tar.bz2 samba-73626c266c3ea1b477185a428b2c1be64feff598.zip |
registry: Check for more specific LDB return codes, handle changing existing values better.
(This used to be commit c8b22ef30c7fc0ccc15e9fc9a38fdc639fc4b976)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/registry/ldb.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 259315cc39..d56b63299d 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -478,13 +478,18 @@ static WERROR ldb_set_value(struct hive_key *parent, ldb_dn_add_child_fmt(msg->dn, "value=%s", name); ret = ldb_add(kd->ldb, msg); - if (ret < 0) { - ret = ldb_modify(kd->ldb, msg); - if (ret < 0) { - DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(kd->ldb))); - talloc_free(mem_ctx); - return WERR_FOOBAR; + if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) { + int i; + for (i = 0; i < msg->num_elements; i++) { + msg->elements[i].flags = LDB_FLAG_MOD_REPLACE; } + ret = ldb_modify(kd->ldb, msg); + } + + if (ret != LDB_SUCCESS) { + DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(kd->ldb))); + talloc_free(mem_ctx); + return WERR_FOOBAR; } talloc_free(mem_ctx); |