X-Git-Url: http://git.samba.org/samba.git/?p=nivanova%2Fsamba-autobuild%2F.git;a=blobdiff_plain;f=source3%2Fwinbindd%2Fidmap_hash%2Fidmap_hash.c;h=816e3a05320a6583224f0c9383aca13915aed852;hp=a050f99bc80f11e37f993261de629a226141f85d;hb=82785957f0eca5722914ac0607ba2b3a53198d58;hpb=06999ae473b5a1fdf21b44fa5866ad1dbc47d749 diff --git a/source3/winbindd/idmap_hash/idmap_hash.c b/source3/winbindd/idmap_hash/idmap_hash.c index a050f99bc80..816e3a05320 100644 --- a/source3/winbindd/idmap_hash/idmap_hash.c +++ b/source3/winbindd/idmap_hash/idmap_hash.c @@ -20,22 +20,24 @@ #include "includes.h" #include "winbindd/winbindd.h" +#include "idmap.h" #include "idmap_hash.h" +#include "ads.h" +#include "nss_info.h" +#include "../libcli/security/dom_sid.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_IDMAP struct sid_hash_table { - DOM_SID *sid; + struct dom_sid *sid; }; -struct sid_hash_table *hashed_domains = NULL; - /********************************************************************* Hash a domain SID (S-1-5-12-aaa-bbb-ccc) to a 12bit number ********************************************************************/ -static uint32_t hash_domain_sid(const DOM_SID *sid) +static uint32_t hash_domain_sid(const struct dom_sid *sid) { uint32_t hash; @@ -105,15 +107,16 @@ static void separate_hashes(uint32_t id, static NTSTATUS be_init(struct idmap_domain *dom, const char *params) { + struct sid_hash_table *hashed_domains; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; struct winbindd_tdc_domain *dom_list = NULL; size_t num_domains = 0; int i; - /* If the domain SID hash talbe has been initialized, assume + /* If the domain SID hash table has been initialized, assume that we completed this function previously */ - if ( hashed_domains ) { + if (dom->private_data != NULL) { nt_status = NT_STATUS_OK; goto done; } @@ -125,7 +128,7 @@ static NTSTATUS be_init(struct idmap_domain *dom, /* Create the hash table of domain SIDs */ - hashed_domains = TALLOC_ZERO_ARRAY(NULL, struct sid_hash_table, 4096); + hashed_domains = TALLOC_ZERO_ARRAY(dom, struct sid_hash_table, 4096); BAIL_ON_PTR_NT_ERROR(hashed_domains, nt_status); /* create the hash table of domain SIDs */ @@ -143,10 +146,12 @@ static NTSTATUS be_init(struct idmap_domain *dom, sid_string_dbg(&dom_list[i].sid), hash)); - hashed_domains[hash].sid = talloc(hashed_domains, DOM_SID); + hashed_domains[hash].sid = talloc(hashed_domains, struct dom_sid); sid_copy(hashed_domains[hash].sid, &dom_list[i].sid); } + dom->private_data = hashed_domains; + done: return nt_status; } @@ -157,9 +162,16 @@ done: static NTSTATUS unixids_to_sids(struct idmap_domain *dom, struct id_map **ids) { + struct sid_hash_table *hashed_domains = talloc_get_type_abort( + dom->private_data, struct sid_hash_table); NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; int i; + /* initialize the status to avoid suprise */ + for (i = 0; ids[i]; i++) { + ids[i]->status = ID_UNKNOWN; + } + nt_status = be_init(dom, NULL); BAIL_ON_NTSTATUS_ERROR(nt_status); @@ -188,8 +200,7 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom, if (!hashed_domains[h_domain].sid) continue; - sid_copy(ids[i]->sid, hashed_domains[h_domain].sid); - sid_append_rid(ids[i]->sid, h_rid); + sid_compose(ids[i]->sid, hashed_domains[h_domain].sid, h_rid); ids[i]->status = ID_MAPPED; } @@ -206,6 +217,11 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom, NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; int i; + /* initialize the status to avoid suprise */ + for (i = 0; ids[i]; i++) { + ids[i]->status = ID_UNKNOWN; + } + nt_status = be_init(dom, NULL); BAIL_ON_NTSTATUS_ERROR(nt_status); @@ -215,7 +231,7 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom, } for (i=0; ids[i]; i++) { - DOM_SID sid; + struct dom_sid sid; uint32_t rid; uint32_t h_domain, h_rid; @@ -244,9 +260,6 @@ done: static NTSTATUS be_close(struct idmap_domain *dom) { - if (hashed_domains) - talloc_free(hashed_domains); - return NT_STATUS_OK; } @@ -262,13 +275,11 @@ static NTSTATUS nss_hash_init(struct nss_domain_entry *e ) *********************************************************************/ static NTSTATUS nss_hash_get_info(struct nss_domain_entry *e, - const DOM_SID *sid, + const struct dom_sid *sid, TALLOC_CTX *ctx, - ADS_STRUCT *ads, - LDAPMessage *msg, - char **homedir, - char **shell, - char **gecos, + const char **homedir, + const char **shell, + const char **gecos, gid_t *p_gid ) { NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; @@ -304,14 +315,14 @@ done: *********************************************************************/ static NTSTATUS nss_hash_map_to_alias(TALLOC_CTX *mem_ctx, - const char *domain, + struct nss_domain_entry *e, const char *name, char **alias) { NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; const char *value; - value = talloc_asprintf(mem_ctx, "%s\\%s", domain, name); + value = talloc_asprintf(mem_ctx, "%s\\%s", e->domain, name); BAIL_ON_PTR_NT_ERROR(value, nt_status); nt_status = mapfile_lookup_key(mem_ctx, value, alias); @@ -325,7 +336,7 @@ done: *********************************************************************/ static NTSTATUS nss_hash_map_from_alias(TALLOC_CTX *mem_ctx, - const char *domain, + struct nss_domain_entry *e, const char *alias, char **name) {