summaryrefslogtreecommitdiffstats
path: root/source3/passdb/pdb_interface.c
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2014-11-25 14:45:26 +1300
committerGarming Sam <garming@samba.org>2014-12-03 04:21:09 +0100
commit7979c6cc50eaa792e5094866878c63df36e715c3 (patch)
tree114195414f6efaa628aaeb4e8c21f07199a02a0e /source3/passdb/pdb_interface.c
parent3b90bfb1089e6a4b7e05e7ed62bb642521f57917 (diff)
downloadsamba-7979c6cc50eaa792e5094866878c63df36e715c3.tar.gz
samba-7979c6cc50eaa792e5094866878c63df36e715c3.tar.xz
samba-7979c6cc50eaa792e5094866878c63df36e715c3.zip
idmap: unify passdb *id_to_sid methods
Instead of passing down gid or uid, a pointer to a unixid is now sent down. This acts as an in-out variable so that the idmap functions can correctly receive ID_TYPE_BOTH, filling in cache details correctly rather than forcing the cache to store ID_TYPE_UID or ID_TYPE_GID. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10720 Change-Id: I11409a0f498e61a3c0a6ae606dd7af1135e6b066 Pair-programmed-with: Andrew Bartlett <abarlet@samba.org> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/passdb/pdb_interface.c')
-rw-r--r--source3/passdb/pdb_interface.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index ed42961435..9dee9d28b4 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -1204,35 +1204,23 @@ bool pdb_get_seq_num(time_t *seq_num)
return NT_STATUS_IS_OK(pdb->get_seq_num(pdb, seq_num));
}
-bool pdb_uid_to_sid(uid_t uid, struct dom_sid *sid)
-{
- struct pdb_methods *pdb = pdb_get_methods();
- bool ret;
-
- ret = pdb->uid_to_sid(pdb, uid, sid);
-
- if (ret == true) {
- struct unixid id;
- id.id = uid;
- id.type = ID_TYPE_UID;
- idmap_cache_set_sid2unixid(sid, &id);
- }
-
- return ret;
-}
-
-bool pdb_gid_to_sid(gid_t gid, struct dom_sid *sid)
+/*
+ * Instead of passing down a gid or uid, this function sends down a pointer
+ * to a unixid.
+ *
+ * This acts as an in-out variable so that the idmap functions can correctly
+ * receive ID_TYPE_BOTH, filling in cache details correctly rather than forcing
+ * the cache to store ID_TYPE_UID or ID_TYPE_GID.
+ */
+bool pdb_id_to_sid(struct unixid *id, struct dom_sid *sid)
{
struct pdb_methods *pdb = pdb_get_methods();
bool ret;
- ret = pdb->gid_to_sid(pdb, gid, sid);
+ ret = pdb->id_to_sid(pdb, id, sid);
if (ret == true) {
- struct unixid id;
- id.id = gid;
- id.type = ID_TYPE_GID;
- idmap_cache_set_sid2unixid(sid, &id);
+ idmap_cache_set_sid2unixid(sid, id);
}
return ret;
@@ -1458,6 +1446,20 @@ static bool pdb_default_gid_to_sid(struct pdb_methods *methods, gid_t gid,
return true;
}
+static bool pdb_default_id_to_sid(struct pdb_methods *methods, struct unixid *id,
+ struct dom_sid *sid)
+{
+ switch (id->type) {
+ case ID_TYPE_UID:
+ return pdb_default_uid_to_sid(methods, id->id, sid);
+
+ case ID_TYPE_GID:
+ return pdb_default_gid_to_sid(methods, id->id, sid);
+
+ default:
+ return false;
+ }
+}
/**
* The "Unix User" and "Unix Group" domains have a special
* id mapping that is a rid-algorithm with range starting at 0.
@@ -2614,8 +2616,7 @@ NTSTATUS make_pdb_method( struct pdb_methods **methods )
(*methods)->get_account_policy = pdb_default_get_account_policy;
(*methods)->set_account_policy = pdb_default_set_account_policy;
(*methods)->get_seq_num = pdb_default_get_seq_num;
- (*methods)->uid_to_sid = pdb_default_uid_to_sid;
- (*methods)->gid_to_sid = pdb_default_gid_to_sid;
+ (*methods)->id_to_sid = pdb_default_id_to_sid;
(*methods)->sid_to_id = pdb_default_sid_to_id;
(*methods)->search_groups = pdb_default_search_groups;