mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
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
This commit is contained in:
@ -563,7 +563,7 @@ struct pdb_methods
|
|||||||
bool (*gid_to_sid)(struct pdb_methods *methods, gid_t gid,
|
bool (*gid_to_sid)(struct pdb_methods *methods, gid_t gid,
|
||||||
struct dom_sid *sid);
|
struct dom_sid *sid);
|
||||||
bool (*sid_to_id)(struct pdb_methods *methods, const 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);
|
uint32_t (*capabilities)(struct pdb_methods *methods);
|
||||||
bool (*new_rid)(struct pdb_methods *methods, uint32_t *rid);
|
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_get_seq_num(time_t *seq_num);
|
||||||
bool pdb_uid_to_sid(uid_t uid, struct dom_sid *sid);
|
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_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);
|
enum lsa_SidType *type);
|
||||||
uint32_t pdb_capabilities(void);
|
uint32_t pdb_capabilities(void);
|
||||||
bool pdb_new_rid(uint32_t *rid);
|
bool pdb_new_rid(uint32_t *rid);
|
||||||
|
@ -1193,11 +1193,12 @@ static bool legacy_sid_to_uid(const struct dom_sid *psid, uid_t *puid)
|
|||||||
enum lsa_SidType type;
|
enum lsa_SidType type;
|
||||||
|
|
||||||
if (sid_check_is_in_our_domain(psid)) {
|
if (sid_check_is_in_our_domain(psid)) {
|
||||||
union unid_t id;
|
uid_t uid;
|
||||||
|
gid_t gid;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
become_root();
|
become_root();
|
||||||
ret = pdb_sid_to_id(psid, &id, &type);
|
ret = pdb_sid_to_id(psid, &uid, &gid, &type);
|
||||||
unbecome_root();
|
unbecome_root();
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -1207,7 +1208,7 @@ static bool legacy_sid_to_uid(const struct dom_sid *psid, uid_t *puid)
|
|||||||
sid_type_lookup(type)));
|
sid_type_lookup(type)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*puid = id.uid;
|
*puid = uid;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,7 +1235,6 @@ done:
|
|||||||
static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
|
static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
|
||||||
{
|
{
|
||||||
GROUP_MAP *map;
|
GROUP_MAP *map;
|
||||||
union unid_t id;
|
|
||||||
enum lsa_SidType type;
|
enum lsa_SidType type;
|
||||||
|
|
||||||
map = talloc_zero(NULL, GROUP_MAP);
|
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)) {
|
if (sid_check_is_in_our_domain(psid)) {
|
||||||
|
uid_t uid;
|
||||||
|
gid_t gid;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
become_root();
|
become_root();
|
||||||
ret = pdb_sid_to_id(psid, &id, &type);
|
ret = pdb_sid_to_id(psid, &uid, &gid, &type);
|
||||||
unbecome_root();
|
unbecome_root();
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -1274,7 +1276,7 @@ static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
|
|||||||
sid_type_lookup(type)));
|
sid_type_lookup(type)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*pgid = id.gid;
|
*pgid = gid;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,
|
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(
|
struct pdb_ads_state *state = talloc_get_type_abort(
|
||||||
m->private_data, struct pdb_ads_state);
|
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;
|
int rc;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
*uid = -1;
|
||||||
|
*gid = -1;
|
||||||
|
|
||||||
sidstr = sid_binstring_hex(sid);
|
sidstr = sid_binstring_hex(sid);
|
||||||
if (sidstr == NULL) {
|
if (sidstr == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@ -2244,21 +2247,17 @@ static bool pdb_ads_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (atype == ATYPE_ACCOUNT) {
|
if (atype == ATYPE_ACCOUNT) {
|
||||||
uint32_t uid;
|
|
||||||
*type = SID_NAME_USER;
|
*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"));
|
DEBUG(10, ("Did not find uidNumber\n"));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
id->uid = uid;
|
|
||||||
} else {
|
} else {
|
||||||
uint32_t gid;
|
|
||||||
*type = SID_NAME_DOM_GRP;
|
*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"));
|
DEBUG(10, ("Did not find gidNumber\n"));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
id->gid = gid;
|
|
||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
fail:
|
fail:
|
||||||
|
@ -53,7 +53,7 @@ static void lazy_initialize_passdb(void)
|
|||||||
static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
|
static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
|
||||||
const char **name,
|
const char **name,
|
||||||
enum lsa_SidType *psid_name_use,
|
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)
|
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);
|
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)
|
enum lsa_SidType *type)
|
||||||
{
|
{
|
||||||
struct pdb_methods *pdb = pdb_get_methods();
|
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)
|
uint32_t pdb_capabilities(void)
|
||||||
@ -1292,7 +1292,7 @@ bool pdb_new_rid(uint32_t *rid)
|
|||||||
|
|
||||||
/* validate that the RID is not in use */
|
/* 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;
|
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,
|
static bool pdb_default_sid_to_id(struct pdb_methods *methods,
|
||||||
const struct dom_sid *sid,
|
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;
|
TALLOC_CTX *mem_ctx;
|
||||||
bool ret = False;
|
bool ret = False;
|
||||||
const char *name;
|
const char *name;
|
||||||
uint32_t rid;
|
uint32_t rid;
|
||||||
|
|
||||||
|
*uid = -1;
|
||||||
|
*gid = -1;
|
||||||
|
|
||||||
mem_ctx = talloc_new(NULL);
|
mem_ctx = talloc_new(NULL);
|
||||||
|
|
||||||
if (mem_ctx == 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)) {
|
if (sid_peek_check_rid(get_global_sam_sid(), sid, &rid)) {
|
||||||
/* Here we might have users as well as groups and aliases */
|
/* 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;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for "Unix User" */
|
/* check for "Unix User" */
|
||||||
|
|
||||||
if ( sid_peek_check_rid(&global_sid_Unix_Users, sid, &rid) ) {
|
if ( sid_peek_check_rid(&global_sid_Unix_Users, sid, &rid) ) {
|
||||||
id->uid = rid;
|
*uid = rid;
|
||||||
*type = SID_NAME_USER;
|
*type = SID_NAME_USER;
|
||||||
ret = True;
|
ret = True;
|
||||||
goto done;
|
goto done;
|
||||||
@ -1472,7 +1476,7 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods,
|
|||||||
/* check for "Unix Group" */
|
/* check for "Unix Group" */
|
||||||
|
|
||||||
if ( sid_peek_check_rid(&global_sid_Unix_Groups, sid, &rid) ) {
|
if ( sid_peek_check_rid(&global_sid_Unix_Groups, sid, &rid) ) {
|
||||||
id->gid = rid;
|
*gid = rid;
|
||||||
*type = SID_NAME_ALIAS;
|
*type = SID_NAME_ALIAS;
|
||||||
ret = True;
|
ret = True;
|
||||||
goto done;
|
goto done;
|
||||||
@ -1504,7 +1508,7 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
id->gid = map->gid;
|
*gid = map->gid;
|
||||||
*type = SID_NAME_ALIAS;
|
*type = SID_NAME_ALIAS;
|
||||||
ret = True;
|
ret = True;
|
||||||
goto done;
|
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,
|
static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
|
||||||
const char **name,
|
const char **name,
|
||||||
enum lsa_SidType *psid_name_use,
|
enum lsa_SidType *psid_name_use,
|
||||||
union unid_t *unix_id)
|
uid_t *uid, gid_t *gid)
|
||||||
{
|
{
|
||||||
struct samu *sam_account = NULL;
|
struct samu *sam_account = NULL;
|
||||||
GROUP_MAP *map = 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);
|
TALLOC_FREE(sam_account);
|
||||||
|
|
||||||
if (unix_id == NULL) {
|
if (uid == NULL) {
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1729,7 +1733,7 @@ static bool lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32_t rid,
|
|||||||
if (pw == NULL) {
|
if (pw == NULL) {
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
unix_id->uid = pw->pw_uid;
|
*uid = pw->pw_uid;
|
||||||
TALLOC_FREE(pw);
|
TALLOC_FREE(pw);
|
||||||
return True;
|
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);
|
*name = talloc_steal(mem_ctx, map->nt_name);
|
||||||
*psid_name_use = map->sid_name_use;
|
*psid_name_use = map->sid_name_use;
|
||||||
|
|
||||||
if ( unix_id ) {
|
if (gid) {
|
||||||
unix_id->gid = map->gid;
|
*gid = map->gid;
|
||||||
}
|
}
|
||||||
|
|
||||||
TALLOC_FREE(map);
|
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
|
/* Windows will always map RID 513 to something. On a non-domain
|
||||||
controller, this gets mapped to SERVER\None. */
|
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"));
|
DEBUG(5, ("Can't find a unix id for an unmapped group\n"));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
@ -1809,7 +1813,7 @@ static NTSTATUS pdb_default_lookup_rids(struct pdb_methods *methods,
|
|||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
if (lookup_global_sam_rid(names, rids[i], &name, &attrs[i],
|
if (lookup_global_sam_rid(names, rids[i], &name, &attrs[i],
|
||||||
NULL)) {
|
NULL, NULL)) {
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -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,
|
static bool ldapsam_sid_to_id(struct pdb_methods *methods,
|
||||||
const struct dom_sid *sid,
|
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 *priv =
|
||||||
(struct ldapsam_privates *)methods->private_data;
|
(struct ldapsam_privates *)methods->private_data;
|
||||||
@ -5055,10 +5056,10 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
id->gid = strtoul(gid_str, NULL, 10);
|
*gid = strtoul(gid_str, NULL, 10);
|
||||||
*type = (enum lsa_SidType)strtoul(value, NULL, 10);
|
*type = (enum lsa_SidType)strtoul(value, NULL, 10);
|
||||||
store_gid_sid_cache(sid, id->gid);
|
store_gid_sid_cache(sid, *gid);
|
||||||
idmap_cache_set_sid2gid(sid, id->gid);
|
idmap_cache_set_sid2gid(sid, *gid);
|
||||||
ret = True;
|
ret = True;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -5073,10 +5074,10 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
id->uid = strtoul(value, NULL, 10);
|
*uid = strtoul(value, NULL, 10);
|
||||||
*type = SID_NAME_USER;
|
*type = SID_NAME_USER;
|
||||||
store_uid_sid_cache(sid, id->uid);
|
store_uid_sid_cache(sid, *uid);
|
||||||
idmap_cache_set_sid2uid(sid, id->uid);
|
idmap_cache_set_sid2uid(sid, *uid);
|
||||||
|
|
||||||
ret = True;
|
ret = True;
|
||||||
done:
|
done:
|
||||||
|
@ -50,7 +50,7 @@ static NTSTATUS pdb_samba4_getsamupriv(struct pdb_samba4_state *state,
|
|||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct ldb_message **pmsg);
|
struct ldb_message **pmsg);
|
||||||
static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *sid,
|
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,
|
static bool pdb_samba4_pull_time(struct ldb_message *msg, const char *attr,
|
||||||
time_t *ptime)
|
time_t *ptime)
|
||||||
@ -852,7 +852,7 @@ static NTSTATUS pdb_samba4_getgrfilter(struct pdb_methods *m, GROUP_MAP *map,
|
|||||||
struct dom_sid *sid;
|
struct dom_sid *sid;
|
||||||
const char *str;
|
const char *str;
|
||||||
int rc;
|
int rc;
|
||||||
union unid_t id;
|
uid_t uid;
|
||||||
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
||||||
NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
|
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;
|
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);
|
talloc_free(tmp_ctx);
|
||||||
return NT_STATUS_NO_SUCH_GROUP;
|
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));
|
DEBUG(1, (__location__ "Got SID_NAME_USER when searching for a group with %s", expression));
|
||||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||||
}
|
}
|
||||||
map->gid = id.gid;
|
|
||||||
|
|
||||||
str = ldb_msg_find_attr_as_string(msg, "samAccountName",
|
str = ldb_msg_find_attr_as_string(msg, "samAccountName",
|
||||||
NULL);
|
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,
|
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(
|
struct pdb_samba4_state *state = talloc_get_type_abort(
|
||||||
m->private_data, struct pdb_samba4_state);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2076,7 +2075,7 @@ static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *si
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (id_map.xid.type == ID_TYPE_UID || id_map.xid.type == ID_TYPE_BOTH) {
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -2664,7 +2664,8 @@ static PyObject *py_pdb_sid_to_id(pytalloc_Object *self, PyObject *args)
|
|||||||
TALLOC_CTX *tframe;
|
TALLOC_CTX *tframe;
|
||||||
PyObject *py_sid;
|
PyObject *py_sid;
|
||||||
struct dom_sid *sid;
|
struct dom_sid *sid;
|
||||||
union unid_t id;
|
uid_t uid = -1;
|
||||||
|
gid_t gid = -1;
|
||||||
enum lsa_SidType type;
|
enum lsa_SidType type;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O!:sid_to_id", dom_sid_Type, &py_sid)) {
|
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);
|
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");
|
PyErr_Format(py_pdb_error, "Unable to get id for sid");
|
||||||
talloc_free(tframe);
|
talloc_free(tframe);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2688,7 +2689,7 @@ static PyObject *py_pdb_sid_to_id(pytalloc_Object *self, PyObject *args)
|
|||||||
|
|
||||||
talloc_free(tframe);
|
talloc_free(tframe);
|
||||||
|
|
||||||
return Py_BuildValue("(II)", id.uid, type);
|
return Py_BuildValue("(II)", (uid != -1)?uid:gid, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,12 +77,13 @@ static NTSTATUS idmap_pdb_sids_to_unixids(struct idmap_domain *dom, struct id_ma
|
|||||||
|
|
||||||
for (i = 0; ids[i]; i++) {
|
for (i = 0; ids[i]; i++) {
|
||||||
enum lsa_SidType type;
|
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) {
|
switch (type) {
|
||||||
case SID_NAME_USER:
|
case SID_NAME_USER:
|
||||||
ids[i]->xid.id = id.uid;
|
ids[i]->xid.id = uid;
|
||||||
ids[i]->xid.type = ID_TYPE_UID;
|
ids[i]->xid.type = ID_TYPE_UID;
|
||||||
ids[i]->status = ID_MAPPED;
|
ids[i]->status = ID_MAPPED;
|
||||||
break;
|
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_DOM_GRP:
|
||||||
case SID_NAME_ALIAS:
|
case SID_NAME_ALIAS:
|
||||||
case SID_NAME_WKN_GRP:
|
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]->xid.type = ID_TYPE_GID;
|
||||||
ids[i]->status = ID_MAPPED;
|
ids[i]->status = ID_MAPPED;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user