Skip to content

Commit

Permalink
ldb_tdb: Re-add of both existing DN and GUID must gives LDB_ERR_ENTRY…
Browse files Browse the repository at this point in the history
…_ALREADY_EXISTS

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
  • Loading branch information
abartlet committed Sep 22, 2017
1 parent e16c8aa commit e8fb451
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/ldb/ldb_tdb/ldb_tdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,24 @@ static int ltdb_add_internal(struct ldb_module *module,

ret = ltdb_store(module, msg, TDB_INSERT);
if (ret != LDB_SUCCESS) {
/*
* Try really hard to get the right error code for
* a re-add situation, as this can matter!
*/
if (ret == LDB_ERR_CONSTRAINT_VIOLATION) {
int ret2;
struct ldb_dn *dn2 = NULL;
TALLOC_CTX *mem_ctx = talloc_new(module);
if (mem_ctx == NULL) {
return ldb_module_operr(module);
}
ret2 = ltdb_search_base(module, module,

This comment has been minimized.

Copy link
@andiges

andiges Jun 12, 2018

Contributor

@abartlet should "mem_ctx" used here as second argument? Or it should be removed, as it is unused.

msg->dn, &dn2);
TALLOC_FREE(mem_ctx);
if (ret2 == LDB_SUCCESS) {
ret = LDB_ERR_ENTRY_ALREADY_EXISTS;
}
}
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
ldb_asprintf_errstring(ldb,
"Entry %s already exists",
Expand Down

0 comments on commit e8fb451

Please sign in to comment.