summaryrefslogtreecommitdiff
path: root/source3/sam/idmap_tdb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2003-05-01 11:47:48 +0000
committerSimo Sorce <idra@samba.org>2003-05-01 11:47:48 +0000
commit75cace04fdcb672cc6c3c3ec8403206f2b222c50 (patch)
treea0e30d36b57bb698cd4af43c769c6deee0ca232d /source3/sam/idmap_tdb.c
parented454fe3d677a27e19b904f5d0d3199b62c9a1b0 (diff)
downloadsamba-75cace04fdcb672cc6c3c3ec8403206f2b222c50.tar.gz
samba-75cace04fdcb672cc6c3c3ec8403206f2b222c50.tar.bz2
samba-75cace04fdcb672cc6c3c3ec8403206f2b222c50.zip
*id_to_*id call reshape to return NTSTATUS errors
plus internal fixes 1st stage (This used to be commit 6d036761e565bc93964bb3c939d5b7d78d5778a3)
Diffstat (limited to 'source3/sam/idmap_tdb.c')
-rw-r--r--source3/sam/idmap_tdb.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source3/sam/idmap_tdb.c b/source3/sam/idmap_tdb.c
index f85d2db086..ab86eaf4eb 100644
--- a/source3/sam/idmap_tdb.c
+++ b/source3/sam/idmap_tdb.c
@@ -213,7 +213,7 @@ idok:
static NTSTATUS db_set_mapping(const DOM_SID *sid, unid_t id, int id_type)
{
- TDB_DATA ksid, kid;
+ TDB_DATA ksid, kid, data;
fstring ksidstr;
fstring kidstr;
@@ -235,6 +235,20 @@ static NTSTATUS db_set_mapping(const DOM_SID *sid, unid_t id, int id_type)
kid.dptr = kidstr;
kid.dsize = strlen(kidstr) + 1;
+ /* *DELETE* prevoius mappings if any.
+ * This is done both SID and [U|G]ID passed in */
+
+ data = tdb_fetch(idmap_tdb, ksid);
+ if (data.dptr) {
+ tdb_delete(idmap_tdb, data);
+ tdb_delete(idmap_tdb, ksid);
+ }
+ data = tdb_fetch(idmap_tdb, kid);
+ if (data.dptr) {
+ tdb_delete(idmap_tdb, data);
+ tdb_delete(idmap_tdb, kid);
+ }
+
if (tdb_store(idmap_tdb, ksid, kid, TDB_INSERT) == -1) {
DEBUG(0, ("idb_set_mapping: tdb_store 1 error: %s\n", tdb_errorstr(idmap_tdb)));
return NT_STATUS_UNSUCCESSFUL;
@@ -427,4 +441,3 @@ NTSTATUS idmap_reg_tdb(struct idmap_methods **meth)
return NT_STATUS_OK;
}
-