static bool ignore_builtin = false;
+static NTSTATUS idmap_autorid_get_alloc_range(struct idmap_domain *dom,
+ struct autorid_range_config *range)
+{
+ NTSTATUS status;
+
+ ZERO_STRUCT(*range);
+
+ fstrcpy(range->domsid, ALLOC_RANGE);
+
+ status = idmap_autorid_get_domainrange(autorid_db,
+ range,
+ dom->read_only);
+
+ return status;
+}
+
static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom,
struct unixid *xid) {
/* fetch the range for the allocation pool */
- ZERO_STRUCT(range);
-
- fstrcpy(range.domsid, ALLOC_RANGE);
-
- ret = idmap_autorid_get_domainrange(autorid_db, &range, dom->read_only);
-
+ ret = idmap_autorid_get_alloc_range(dom, &range);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(3, ("Could not determine range for allocation pool, "
"check previous messages for reason\n"));
/*
* map a SID to xid using the idmap_tdb like pool
*/
-static NTSTATUS idmap_autorid_map_id_to_sid(struct idmap_domain *dom,
- struct id_map *map)
+static NTSTATUS idmap_autorid_id_to_sid_alloc(struct idmap_domain *dom,
+ struct id_map *map)
{
NTSTATUS ret;
"checking for mapping\n",
map->xid.id));
TALLOC_FREE(data.dptr);
- return idmap_autorid_map_id_to_sid(dom, map);
+ return idmap_autorid_id_to_sid_alloc(dom, map);
}
ok = dom_sid_parse_endp((const char *)data.dptr, &domsid, &q);
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->xid.id = reduced_rid + range->low_id;
map->xid.type = ID_TYPE_BOTH;
-
- /* We **really** should have some way of validating
- the SID exists and is the correct type here. But
- that is a deficiency in the idmap_rid design. */
-
map->status = ID_MAPPED;
return NT_STATUS_OK;
/*
* 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);
/* bad things happened */
if (!NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED)) {
- DEBUG(1, ("Looking up SID->ID mapping for %s failed\n",
- sid_string_dbg(map->sid)));
+ DEBUG(1, ("Looking up SID->ID mapping for %s failed: %s\n",
+ sid_string_dbg(map->sid), nt_errstr(ret)));
return ret;
}
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))) {
common = (struct idmap_tdb_common_context *)dom->private_data;
config = (struct autorid_global_config *)common->private_data;
- status = idmap_autorid_init_hwms(autorid_db);
+ status = idmap_autorid_init_hwms(db);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- status = idmap_autorid_saveconfig(autorid_db, config);
+ status = idmap_autorid_saveconfig(db, config);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to store configuration data!\n"));
return status;