diff options
author | Michael Adam <obnox@samba.org> | 2012-12-03 01:34:32 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-12-03 08:48:30 +0100 |
commit | d96aeded6193cb6381540c1073182bfb7f079025 (patch) | |
tree | ee62f6e4cd834101bc96031973939e2861a7a371 /source3/passdb | |
parent | ef0ed56eb15f24db5934f174f90f65d3f5c3c526 (diff) | |
download | samba-d96aeded6193cb6381540c1073182bfb7f079025.tar.gz samba-d96aeded6193cb6381540c1073182bfb7f079025.tar.bz2 samba-d96aeded6193cb6381540c1073182bfb7f079025.zip |
s3:passdb: factor pdb_sid_to_id_unix_users_and_groups() out of pdb_default_sid_to_id()
The special treatment of the "Unix User" and "Unix Group" pseudo domains
can be reused.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_interface.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 1527b39b7f..436e774302 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -1421,6 +1421,32 @@ static bool pdb_default_gid_to_sid(struct pdb_methods *methods, gid_t gid, return true; } +/** + * The "Unix User" and "Unix Group" domains have a special + * id mapping that is a rid-algorithm with range starting at 0. + */ +_PRIVATE_ bool pdb_sid_to_id_unix_users_and_groups(const struct dom_sid *sid, + struct unixid *id) +{ + uint32_t rid; + + id->id = -1; + + if (sid_peek_check_rid(&global_sid_Unix_Users, sid, &rid)) { + id->id = rid; + id->type = ID_TYPE_UID; + return true; + } + + if (sid_peek_check_rid(&global_sid_Unix_Groups, sid, &rid)) { + id->id = rid; + id->type = ID_TYPE_GID; + return true; + } + + return false; +} + static bool pdb_default_sid_to_id(struct pdb_methods *methods, const struct dom_sid *sid, struct unixid *id) @@ -1467,22 +1493,12 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods, goto done; } - /* check for "Unix User" */ - - if ( sid_peek_check_rid(&global_sid_Unix_Users, sid, &rid) ) { - id->id = rid; - id->type = ID_TYPE_UID; - ret = True; - goto done; - } - - /* check for "Unix Group" */ - - if ( sid_peek_check_rid(&global_sid_Unix_Groups, sid, &rid) ) { - id->id = rid; - id->type = ID_TYPE_GID; - ret = True; - goto done; + /* + * "Unix User" and "Unix Group" + */ + ret = pdb_sid_to_id_unix_users_and_groups(sid, id); + if (ret == true) { + goto done; } /* BUILTIN */ |