summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-10-18 10:44:52 -0400
committerSimo Sorce <idra@samba.org>2011-10-18 20:57:16 +0200
commit605d7d965a33d6a4be632dde9b15abb42801fdaf (patch)
tree01ae99dca9bf63e666e23bef155b40427f05a30e
parent94799db9b5d33ded34ad3e934da673a44d48094a (diff)
downloadsamba-605d7d965a33d6a4be632dde9b15abb42801fdaf.tar.gz
samba-605d7d965a33d6a4be632dde9b15abb42801fdaf.tar.bz2
samba-605d7d965a33d6a4be632dde9b15abb42801fdaf.zip
pdb-interface: Do not use unid_t here
This interface needs to be publicly available, unid_t here is not really useful and makes it harder to use it as unid_t is not a public union. Autobuild-User: Simo Sorce <idra@samba.org> Autobuild-Date: Tue Oct 18 20:57:16 CEST 2011 on sn-devel-104
-rw-r--r--source3/include/passdb.h4
-rw-r--r--source3/passdb/lookup_sid.c14
-rw-r--r--source3/passdb/pdb_ads.c13
-rw-r--r--source3/passdb/pdb_interface.c36
-rw-r--r--source3/passdb/pdb_ldap.c15
-rw-r--r--source3/passdb/pdb_samba4.c13
-rw-r--r--source3/passdb/py_passdb.c7
-rw-r--r--source3/winbindd/idmap_passdb.c9
8 files changed, 59 insertions, 52 deletions
diff --git a/source3/include/passdb.h b/source3/include/passdb.h
index cd3880c296..70b21c9b04 100644
--- a/source3/include/passdb.h
+++ b/source3/include/passdb.h
@@ -563,7 +563,7 @@ struct pdb_methods
bool (*gid_to_sid)(struct pdb_methods *methods, gid_t gid,
struct dom_sid *sid);
bool (*sid_to_id)(struct pdb_methods *methods, const struct dom_sid *sid,
- union unid_t *id, enum lsa_SidType *type);
+ uid_t *uid, gid_t *gid, enum lsa_SidType *type);
uint32_t (*capabilities)(struct pdb_methods *methods);
bool (*new_rid)(struct pdb_methods *methods, uint32_t *rid);
@@ -868,7 +868,7 @@ bool pdb_set_account_policy(enum pdb_policy_type type, uint32_t value);
bool pdb_get_seq_num(time_t *seq_num);
bool pdb_uid_to_sid(uid_t uid, struct dom_sid *sid);
bool pdb_gid_to_sid(gid_t gid, struct dom_sid *sid);
-bool pdb_sid_to_id(const struct dom_sid *sid, union unid_t *id,
+bool pdb_sid_to_id(const struct dom_sid *sid, uid_t *uid, gid_t *gid,
enum lsa_SidType *type);
uint32_t pdb_capabilities(void);
bool pdb_new_rid(uint32_t *rid);
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index a02c941d8e..cfc78ad000 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1193,11 +1193,12 @@ static bool legacy_sid_to_uid(const struct dom_sid *psid, uid_t *puid)
enum lsa_SidType type;
if (sid_check_is_in_our_domain(psid)) {
- union unid_t id;
+ uid_t uid;
+ gid_t gid;
bool ret;
become_root();
- ret = pdb_sid_to_id(psid, &id, &type);
+ ret = pdb_sid_to_id(psid, &uid, &gid, &type);
unbecome_root();
if (ret) {
@@ -1207,7 +1208,7 @@ static bool legacy_sid_to_uid(const struct dom_sid *psid, uid_t *puid)
sid_type_lookup(type)));
return false;
}
- *puid = id.uid;
+ *puid = uid;
goto done;
}
@@ -1234,7 +1235,6 @@ done:
static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
{
GROUP_MAP *map;
- union unid_t id;
enum lsa_SidType type;
map = talloc_zero(NULL, GROUP_MAP);
@@ -1260,10 +1260,12 @@ static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
}
if (sid_check_is_in_our_domain(psid)) {
+ uid_t uid;
+ gid_t gid;
bool ret;
become_root();
- ret = pdb_sid_to_id(psid, &id, &type);
+ ret = pdb_sid_to_id(psid, &uid, &gid, &type);
unbecome_root();
if (ret) {
@@ -1274,7 +1276,7 @@ static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
sid_type_lookup(type)));
return false;
}
- *pgid = id.gid;
+ *pgid = gid;
goto done;
}
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c
index 57425349f8..8dc9585b40 100644
--- a/source3/passdb/pdb_ads.c
+++ b/source3/passdb/pdb_ads.c
@@ -2204,7 +2204,7 @@ static bool pdb_ads_gid_to_sid(struct pdb_methods *m, gid_t gid,
}
static bool pdb_ads_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
- union unid_t *id, enum lsa_SidType *type)
+ uid_t *uid, gid_t *gid, enum lsa_SidType *type)
{
struct pdb_ads_state *state = talloc_get_type_abort(
m->private_data, struct pdb_ads_state);
@@ -2216,6 +2216,9 @@ static bool pdb_ads_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
int rc;
bool ret = false;
+ *uid = -1;
+ *gid = -1;
+
sidstr = sid_binstring_hex(sid);
if (sidstr == NULL) {
return false;
@@ -2244,21 +2247,17 @@ static bool pdb_ads_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
goto fail;
}
if (atype == ATYPE_ACCOUNT) {
- uint32_t uid;
*type = SID_NAME_USER;
- if (!tldap_pull_uint32(msg[0], "uidNumber", &uid)) {
+ if (!tldap_pull_uint32(msg[0], "uidNumber", uid)) {
DEBUG(10, ("Did not find uidNumber\n"));
goto fail;
}
- id->uid = uid;
} else {
- uint32_t gid;
*type = SID_NAME_DOM_GRP;
- if (!tldap_pull_uint32(msg[0], "gidNumber", &gid)) {
+ if (!tldap_pull_uint32(msg[0], "gidNumber", gid)) {
DEBUG(10, ("Did not find gidNumber\n"));
goto fail;
}
- id->gid = gid;
}
ret = true;
fail:
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 03d9821012..a6a777436e 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -53,7 +53,7 @@ static void lazy_initialize_passdb(void)
static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
const char **name,
enum lsa_SidType *psid_name_use,
- union unid_t *unix_id);
+ uid_t *uid, gid_t *gid);
NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init)
{
@@ -1231,11 +1231,11 @@ bool pdb_gid_to_sid(gid_t gid, struct dom_sid *sid)
return pdb->gid_to_sid(pdb, gid, sid);
}
-bool pdb_sid_to_id(const struct dom_sid *sid, union unid_t *id,
+bool pdb_sid_to_id(const struct dom_sid *sid, uid_t *uid, gid_t *gid,
enum lsa_SidType *type)
{
struct pdb_methods *pdb = pdb_get_methods();
- return pdb->sid_to_id(pdb, sid, id, type);
+ return pdb->sid_to_id(pdb, sid, uid, gid, type);
}
uint32_t pdb_capabilities(void)
@@ -1292,7 +1292,7 @@ bool pdb_new_rid(uint32_t *rid)
/* validate that the RID is not in use */
- if ( lookup_global_sam_rid( ctx, allocated_rid, &name, &type, NULL ) ) {
+ if (lookup_global_sam_rid(ctx, allocated_rid, &name, &type, NULL, NULL)) {
allocated_rid = 0;
}
}
@@ -1440,13 +1440,17 @@ static bool pdb_default_gid_to_sid(struct pdb_methods *methods, gid_t gid,
static bool pdb_default_sid_to_id(struct pdb_methods *methods,
const struct dom_sid *sid,
- union unid_t *id, enum lsa_SidType *type)
+ uid_t *uid, gid_t *gid,
+ enum lsa_SidType *type)
{
TALLOC_CTX *mem_ctx;
bool ret = False;
const char *name;
uint32_t rid;
+ *uid = -1;
+ *gid = -1;
+
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
@@ -1456,14 +1460,14 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods,
if (sid_peek_check_rid(get_global_sam_sid(), sid, &rid)) {
/* Here we might have users as well as groups and aliases */
- ret = lookup_global_sam_rid(mem_ctx, rid, &name, type, id);
+ ret = lookup_global_sam_rid(mem_ctx, rid, &name, type, uid, gid);
goto done;
}
/* check for "Unix User" */
if ( sid_peek_check_rid(&global_sid_Unix_Users, sid, &rid) ) {
- id->uid = rid;
+ *uid = rid;
*type = SID_NAME_USER;
ret = True;
goto done;
@@ -1472,7 +1476,7 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods,
/* check for "Unix Group" */
if ( sid_peek_check_rid(&global_sid_Unix_Groups, sid, &rid) ) {
- id->gid = rid;
+ *gid = rid;
*type = SID_NAME_ALIAS;
ret = True;
goto done;
@@ -1504,7 +1508,7 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods,
goto done;
}
- id->gid = map->gid;
+ *gid = map->gid;
*type = SID_NAME_ALIAS;
ret = True;
goto done;
@@ -1669,7 +1673,7 @@ static NTSTATUS pdb_default_enum_group_memberships(struct pdb_methods *methods,
static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
const char **name,
enum lsa_SidType *psid_name_use,
- union unid_t *unix_id)
+ uid_t *uid, gid_t *gid)
{
struct samu *sam_account = NULL;
GROUP_MAP *map = NULL;
@@ -1721,7 +1725,7 @@ static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
TALLOC_FREE(sam_account);
- if (unix_id == NULL) {
+ if (uid == NULL) {
return True;
}
@@ -1729,7 +1733,7 @@ static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
if (pw == NULL) {
return False;
}
- unix_id->uid = pw->pw_uid;
+ *uid = pw->pw_uid;
TALLOC_FREE(pw);
return True;
@@ -1741,8 +1745,8 @@ static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
*name = talloc_steal(mem_ctx, map->nt_name);
*psid_name_use = map->sid_name_use;
- if ( unix_id ) {
- unix_id->gid = map->gid;
+ if (gid) {
+ *gid = map->gid;
}
TALLOC_FREE(map);
@@ -1754,7 +1758,7 @@ static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
/* Windows will always map RID 513 to something. On a non-domain
controller, this gets mapped to SERVER\None. */
- if ( unix_id ) {
+ if (uid || gid) {
DEBUG(5, ("Can't find a unix id for an unmapped group\n"));
return False;
}
@@ -1809,7 +1813,7 @@ static NTSTATUS pdb_default_lookup_rids(struct pdb_methods *methods,
const char *name;
if (lookup_global_sam_rid(names, rids[i], &name, &attrs[i],
- NULL)) {
+ NULL, NULL)) {
if (name == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index dd46f8f87f..feda002d13 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -4993,7 +4993,8 @@ static bool ldapsam_new_rid(struct pdb_methods *methods, uint32_t *rid)
static bool ldapsam_sid_to_id(struct pdb_methods *methods,
const struct dom_sid *sid,
- union unid_t *id, enum lsa_SidType *type)
+ uid_t *uid, gid_t *gid,
+ enum lsa_SidType *type)
{
struct ldapsam_privates *priv =
(struct ldapsam_privates *)methods->private_data;
@@ -5055,10 +5056,10 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
goto done;
}
- id->gid = strtoul(gid_str, NULL, 10);
+ *gid = strtoul(gid_str, NULL, 10);
*type = (enum lsa_SidType)strtoul(value, NULL, 10);
- store_gid_sid_cache(sid, id->gid);
- idmap_cache_set_sid2gid(sid, id->gid);
+ store_gid_sid_cache(sid, *gid);
+ idmap_cache_set_sid2gid(sid, *gid);
ret = True;
goto done;
}
@@ -5073,10 +5074,10 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
goto done;
}
- id->uid = strtoul(value, NULL, 10);
+ *uid = strtoul(value, NULL, 10);
*type = SID_NAME_USER;
- store_uid_sid_cache(sid, id->uid);
- idmap_cache_set_sid2uid(sid, id->uid);
+ store_uid_sid_cache(sid, *uid);
+ idmap_cache_set_sid2uid(sid, *uid);
ret = True;
done:
diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c
index af252143cd..8da9b3cf5a 100644
--- a/source3/passdb/pdb_samba4.c
+++ b/source3/passdb/pdb_samba4.c
@@ -50,7 +50,7 @@ static NTSTATUS pdb_samba4_getsamupriv(struct pdb_samba4_state *state,
TALLOC_CTX *mem_ctx,
struct ldb_message **pmsg);
static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
- union unid_t *id, enum lsa_SidType *type);
+ uid_t *uid, gid_t *gid, enum lsa_SidType *type);
static bool pdb_samba4_pull_time(struct ldb_message *msg, const char *attr,
time_t *ptime)
@@ -852,7 +852,7 @@ static NTSTATUS pdb_samba4_getgrfilter(struct pdb_methods *m, GROUP_MAP *map,
struct dom_sid *sid;
const char *str;
int rc;
- union unid_t id;
+ uid_t uid;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
@@ -885,7 +885,7 @@ static NTSTATUS pdb_samba4_getgrfilter(struct pdb_methods *m, GROUP_MAP *map,
map->sid = *sid;
- if (!pdb_samba4_sid_to_id(m, sid, &id, &map->sid_name_use)) {
+ if (!pdb_samba4_sid_to_id(m, sid, &uid, &map->gid, &map->sid_name_use)) {
talloc_free(tmp_ctx);
return NT_STATUS_NO_SUCH_GROUP;
}
@@ -893,7 +893,6 @@ static NTSTATUS pdb_samba4_getgrfilter(struct pdb_methods *m, GROUP_MAP *map,
DEBUG(1, (__location__ "Got SID_NAME_USER when searching for a group with %s", expression));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- map->gid = id.gid;
str = ldb_msg_find_attr_as_string(msg, "samAccountName",
NULL);
@@ -2001,7 +2000,7 @@ static bool pdb_samba4_gid_to_sid(struct pdb_methods *m, gid_t gid,
}
static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
- union unid_t *id, enum lsa_SidType *type)
+ uid_t *uid, gid_t *gid, enum lsa_SidType *type)
{
struct pdb_samba4_state *state = talloc_get_type_abort(
m->private_data, struct pdb_samba4_state);
@@ -2059,7 +2058,7 @@ static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *si
return false;
}
if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
- id->gid = id_map.xid.id;
+ *gid = id_map.xid.id;
return true;
}
return false;
@@ -2076,7 +2075,7 @@ static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *si
return false;
}
if (id_map.xid.type == ID_TYPE_UID || id_map.xid.type == ID_TYPE_BOTH) {
- id->uid = id_map.xid.id;
+ *uid = id_map.xid.id;
return true;
}
return false;
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
index 025e82812c..4c8dbcdbd2 100644
--- a/source3/passdb/py_passdb.c
+++ b/source3/passdb/py_passdb.c
@@ -2664,7 +2664,8 @@ static PyObject *py_pdb_sid_to_id(pytalloc_Object *self, PyObject *args)
TALLOC_CTX *tframe;
PyObject *py_sid;
struct dom_sid *sid;
- union unid_t id;
+ uid_t uid = -1;
+ gid_t gid = -1;
enum lsa_SidType type;
if (!PyArg_ParseTuple(args, "O!:sid_to_id", dom_sid_Type, &py_sid)) {
@@ -2680,7 +2681,7 @@ static PyObject *py_pdb_sid_to_id(pytalloc_Object *self, PyObject *args)
sid = pytalloc_get_ptr(py_sid);
- if (!methods->sid_to_id(methods, sid, &id, &type)) {
+ if (!methods->sid_to_id(methods, sid, &uid, &gid, &type)) {
PyErr_Format(py_pdb_error, "Unable to get id for sid");
talloc_free(tframe);
return NULL;
@@ -2688,7 +2689,7 @@ static PyObject *py_pdb_sid_to_id(pytalloc_Object *self, PyObject *args)
talloc_free(tframe);
- return Py_BuildValue("(II)", id.uid, type);
+ return Py_BuildValue("(II)", (uid != -1)?uid:gid, type);
}
diff --git a/source3/winbindd/idmap_passdb.c b/source3/winbindd/idmap_passdb.c
index 4731756d5a..4c26c5c466 100644
--- a/source3/winbindd/idmap_passdb.c
+++ b/source3/winbindd/idmap_passdb.c
@@ -77,12 +77,13 @@ static NTSTATUS idmap_pdb_sids_to_unixids(struct idmap_domain *dom, struct id_ma
for (i = 0; ids[i]; i++) {
enum lsa_SidType type;
- union unid_t id;
+ uid_t uid;
+ gid_t gid;
- if (pdb_sid_to_id(ids[i]->sid, &id, &type)) {
+ if (pdb_sid_to_id(ids[i]->sid, &uid, &gid, &type)) {
switch (type) {
case SID_NAME_USER:
- ids[i]->xid.id = id.uid;
+ ids[i]->xid.id = uid;
ids[i]->xid.type = ID_TYPE_UID;
ids[i]->status = ID_MAPPED;
break;
@@ -90,7 +91,7 @@ static NTSTATUS idmap_pdb_sids_to_unixids(struct idmap_domain *dom, struct id_ma
case SID_NAME_DOM_GRP:
case SID_NAME_ALIAS:
case SID_NAME_WKN_GRP:
- ids[i]->xid.id = id.gid;
+ ids[i]->xid.id = gid;
ids[i]->xid.type = ID_TYPE_GID;
ids[i]->status = ID_MAPPED;
break;