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)
{
/*
* map a SID to xid using the idmap_tdb like pool
*/
-static NTSTATUS idmap_autorid_map_sid_to_id(struct idmap_domain *dom,
- struct id_map *map,
- struct idmap_tdb_common_context *ctx)
+static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom,
+ struct id_map *map,
+ struct idmap_tdb_common_context *ctx)
{
NTSTATUS ret;
int res;
+ map->status = ID_UNKNOWN;
+
/* see if we already have a mapping */
ret = idmap_tdb_common_sid_to_unixid(dom, map);
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;
}
}
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"));
DEBUG(10, ("SID %s is well-known, using pool\n",
sid_string_dbg(ids[i]->sid)));
- ret = idmap_autorid_map_sid_to_id(dom, ids[i],
- commoncfg);
+ ret = idmap_autorid_sid_to_id_alloc(dom, ids[i],
+ commoncfg);
if (!NT_STATUS_IS_OK(ret) &&
!NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED)) {
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))) {