diff options
author | Michael Adam <obnox@samba.org> | 2010-06-17 08:44:04 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2010-08-14 02:10:51 +0200 |
commit | 4f2bb1a2595a23d3bba0d0b3bb7bb38872e47c95 (patch) | |
tree | 28135bec79a2716afcd5e5828115871fcabf9246 /source3/winbindd | |
parent | 47387b3ebb0d4d04403d0d65312d29af6bccc95a (diff) | |
download | samba-4f2bb1a2595a23d3bba0d0b3bb7bb38872e47c95.tar.gz samba-4f2bb1a2595a23d3bba0d0b3bb7bb38872e47c95.tar.bz2 samba-4f2bb1a2595a23d3bba0d0b3bb7bb38872e47c95.zip |
s3:idmap_tdb: add a idmap_tdb_new_mapping().
High level function to create a new mapping for an unmapped sid.
This builds logic that used to reside in the top level idmap code
in the backend. To be called inside a transaction to guarantee
atomicity of the operation.
Diffstat (limited to 'source3/winbindd')
-rw-r--r-- | source3/winbindd/idmap_tdb.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c index b155bde81d..854b24c601 100644 --- a/source3/winbindd/idmap_tdb.c +++ b/source3/winbindd/idmap_tdb.c @@ -610,6 +610,58 @@ done: return ret; } +/** + * Create a new mapping for an unmapped SID, also allocating a new ID. + * This should be run inside a transaction. + * + * TODO: + * Properly integrate this with multi domain idmap config: + * Currently, the allocator is default-config only. + */ +static NTSTATUS idmap_tdb_new_mapping(struct idmap_domain *dom, struct id_map *map) +{ + NTSTATUS ret; + + if (map == NULL) { + ret = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + if ((map->xid.type != ID_TYPE_UID) && (map->xid.type != ID_TYPE_GID)) { + ret = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + if (map->sid == NULL) { + ret = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + ret = idmap_tdb_get_new_id(dom, &map->xid); + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(3, ("Could not allocate id: %s\n", nt_errstr(ret))); + goto done; + } + + DEBUG(10, ("Setting mapping: %s <-> %s %lu\n", + sid_string_dbg(map->sid), + (map->xid.type == ID_TYPE_UID) ? "UID" : "GID", + (unsigned long)map->xid.id)); + + map->status = ID_MAPPED; + + /* store the mapping */ + ret = idmap_tdb_set_mapping(dom, map); + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(3, ("Could not store the new mapping: %s\n", + nt_errstr(ret))); + } + +done: + return ret; +} + + /********************************** Single id to sid lookup function. **********************************/ |