autorid: more explicitly and reasonably set map->state in idmap_autorid_sid_to_id_alloc
authorMichael Adam <obnox@samba.org>
Fri, 11 Apr 2014 16:20:01 +0000 (18:20 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 25 Apr 2014 13:35:09 +0000 (15:35 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/idmap_autorid.c

index 0e7d6d676e4260236635817d4f7b49ddc8a1a094..8cdc37e20fb8a56b63de1758ddd0870d4b6f0f9c 100644 (file)
@@ -348,6 +348,8 @@ static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom,
        NTSTATUS ret;
        int res;
 
+       map->status = ID_UNKNOWN;
+
        /* see if we already have a mapping */
        ret = idmap_tdb_common_sid_to_unixid(dom, map);
 
@@ -366,6 +368,7 @@ static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom,
        if (dom->read_only) {
                DEBUG(3, ("Not allocating new mapping for %s, because backend "
                          "is read-only\n", sid_string_dbg(map->sid)));
+               map->status = ID_UNMAPPED;
                return NT_STATUS_NONE_MAPPED;
        }
 
@@ -380,18 +383,17 @@ static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom,
        }
 
        ret = idmap_tdb_common_new_mapping(dom, map);
-
-       map->status = (NT_STATUS_IS_OK(ret))?ID_MAPPED:ID_UNMAPPED;
-
        if (!NT_STATUS_IS_OK(ret)) {
                if (dbwrap_transaction_cancel(ctx->db) != 0) {
                        smb_panic("Cancelling transaction failed");
                }
+               map->status = ID_UNMAPPED;
                return ret;
        }
 
        res = dbwrap_transaction_commit(ctx->db);
        if (res == 0) {
+               map->status = ID_MAPPED;
                return ret;
        }