#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 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 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;
}
/* 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 */
sid_copy(hashed_domains[hash].sid, &dom_list[i].sid);
}
+ dom->private_data = hashed_domains;
+
done:
return nt_status;
}
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;
for (i = 0; ids[i]; i++) {
ids[i]->status = ID_UNKNOWN;
}
-
+
nt_status = be_init(dom, NULL);
BAIL_ON_NTSTATUS_ERROR(nt_status);
for (i = 0; ids[i]; i++) {
ids[i]->status = ID_UNKNOWN;
}
-
+
nt_status = be_init(dom, NULL);
BAIL_ON_NTSTATUS_ERROR(nt_status);
static NTSTATUS be_close(struct idmap_domain *dom)
{
- if (hashed_domains)
- talloc_free(hashed_domains);
-
return NT_STATUS_OK;
}
static NTSTATUS nss_hash_get_info(struct nss_domain_entry *e,
const struct dom_sid *sid,
TALLOC_CTX *ctx,
- ADS_STRUCT *ads,
- LDAPMessage *msg,
const char **homedir,
const char **shell,
const char **gecos,