autorid: explicitly return NTSTATUS_OK in idmap_autorid_sid_to_id_alloc().
[obnox/samba/samba-obnox.git] / source3 / winbindd / idmap_autorid.c
index 4d3736319db3b7f11eab566b754c503568d15071..0bdc96dd477a90c64bc93549d3493fdec0af9a0f 100644 (file)
@@ -261,7 +261,8 @@ static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg,
  Single sid to id lookup function.
 **********************************/
 
-static NTSTATUS idmap_autorid_sid_to_id(struct autorid_global_config *global,
+static NTSTATUS idmap_autorid_sid_to_id_rid(
+                                       struct autorid_global_config *global,
                                        struct autorid_range_config *range,
                                        struct id_map *map)
 {
@@ -347,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);
 
@@ -365,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;
        }
 
@@ -379,19 +383,18 @@ 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) {
-               return ret;
+               map->status = ID_MAPPED;
+               return NT_STATUS_OK;
        }
 
        DEBUG(2, ("transaction_commit failed\n"));
@@ -511,7 +514,7 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
                        goto failure;
                }
 
-               ret = idmap_autorid_sid_to_id(global, &range, ids[i]);
+               ret = idmap_autorid_sid_to_id_rid(global, &range, ids[i]);
 
                if ((!NT_STATUS_IS_OK(ret)) &&
                    (!NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) {