[PATCHES] winbindd: Remove indirection through domain->methods
Christof Schmitt
cs at samba.org
Fri Oct 7 23:52:43 UTC 2016
Is there a reason for the domain->methods indirection? I assume that
this is historical, but in the current code domain->methods is always
set to cache_methods. Unless there are plans to change this, i would
propose to remove this indirection to make the code a bit easier to
understand. See attached patches.
Christof
-------------- next part --------------
From def7c5a2e8fc7ac4e86a357014a20bca18961e90 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 7 Oct 2016 16:19:07 -0700
Subject: [PATCH 1/4] winbindd: Make functions in cache_methods non-static
This is in preparation for calling these directly instead of the
domain->methods indirection.
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/winbindd/winbindd_cache.c | 157 ++++++++++++++++++++------------------
source3/winbindd/winbindd_proto.h | 68 +++++++++++++++++
2 files changed, 149 insertions(+), 76 deletions(-)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 3e01ff0..dd0cbf1 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -1453,10 +1453,10 @@ NTSTATUS wcache_save_creds(struct winbindd_domain *domain,
/* Query display info. This is the basic user list fn */
-static NTSTATUS query_user_list(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- uint32_t *num_entries,
- struct wbint_userinfo **info)
+NTSTATUS wb_cache_query_user_list(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_entries,
+ struct wbint_userinfo **info)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
@@ -1604,10 +1604,10 @@ skip_save:
}
/* list all domain groups */
-static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- uint32_t *num_entries,
- struct wb_acct_info **info)
+NTSTATUS wb_cache_enum_dom_groups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_entries,
+ struct wb_acct_info **info)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
@@ -1699,10 +1699,10 @@ skip_save:
}
/* list all domain groups */
-static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- uint32_t *num_entries,
- struct wb_acct_info **info)
+NTSTATUS wb_cache_enum_local_groups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_entries,
+ struct wb_acct_info **info)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
@@ -1847,13 +1847,13 @@ NTSTATUS wcache_name_to_sid(struct winbindd_domain *domain,
}
/* convert a single name to a sid in a domain */
-static NTSTATUS name_to_sid(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const char *domain_name,
- const char *name,
- uint32_t flags,
- struct dom_sid *sid,
- enum lsa_SidType *type)
+NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const char *domain_name,
+ const char *name,
+ uint32_t flags,
+ struct dom_sid *sid,
+ enum lsa_SidType *type)
{
NTSTATUS status;
bool old_status;
@@ -1961,12 +1961,12 @@ static NTSTATUS wcache_sid_to_name(struct winbindd_domain *domain,
/* convert a sid to a user or group name. The sid is guaranteed to be in the domain
given */
-static NTSTATUS sid_to_name(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *sid,
- char **domain_name,
- char **name,
- enum lsa_SidType *type)
+NTSTATUS wb_cache_sid_to_name(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *sid,
+ char **domain_name,
+ char **name,
+ enum lsa_SidType *type)
{
NTSTATUS status;
bool old_status;
@@ -2024,14 +2024,14 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
return status;
}
-static NTSTATUS rids_to_names(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *domain_sid,
- uint32_t *rids,
- size_t num_rids,
- char **domain_name,
- char ***names,
- enum lsa_SidType **types)
+NTSTATUS wb_cache_rids_to_names(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *domain_sid,
+ uint32_t *rids,
+ size_t num_rids,
+ char **domain_name,
+ char ***names,
+ enum lsa_SidType **types)
{
struct winbind_cache *cache = get_cache(domain);
size_t i;
@@ -2358,10 +2358,10 @@ NTSTATUS wcache_query_user_fullname(struct winbindd_domain *domain,
}
/* Lookup user information from a rid */
-static NTSTATUS query_user(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *user_sid,
- struct wbint_userinfo *info)
+NTSTATUS wb_cache_query_user(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *user_sid,
+ struct wbint_userinfo *info)
{
NTSTATUS status;
bool old_status;
@@ -2467,10 +2467,11 @@ NTSTATUS wcache_lookup_usergroups(struct winbindd_domain *domain,
}
/* Lookup groups a user is a member of. */
-static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *user_sid,
- uint32_t *num_groups, struct dom_sid **user_gids)
+NTSTATUS wb_cache_lookup_usergroups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *user_sid,
+ uint32_t *num_groups,
+ struct dom_sid **user_gids)
{
struct cache_entry *centry = NULL;
NTSTATUS status;
@@ -2618,10 +2619,12 @@ NTSTATUS wcache_lookup_useraliases(struct winbindd_domain *domain,
return status;
}
-static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- uint32_t num_sids, const struct dom_sid *sids,
- uint32_t *num_aliases, uint32_t **alias_rids)
+NTSTATUS wb_cache_lookup_useraliases(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t num_sids,
+ const struct dom_sid *sids,
+ uint32_t *num_aliases,
+ uint32_t **alias_rids)
{
struct cache_entry *centry = NULL;
NTSTATUS status;
@@ -2751,13 +2754,14 @@ NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
return status;
}
-static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *group_sid,
- enum lsa_SidType type,
- uint32_t *num_names,
- struct dom_sid **sid_mem, char ***names,
- uint32_t **name_types)
+NTSTATUS wb_cache_lookup_groupmem(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *group_sid,
+ enum lsa_SidType type,
+ uint32_t *num_names,
+ struct dom_sid **sid_mem,
+ char ***names,
+ uint32_t **name_types)
{
struct cache_entry *centry = NULL;
NTSTATUS status;
@@ -2826,7 +2830,8 @@ skip_save:
}
/* find the sequence number for a domain */
-static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32_t *seq)
+NTSTATUS wb_cache_sequence_number(struct winbindd_domain *domain,
+ uint32_t *seq)
{
refresh_sequence_number(domain);
@@ -2838,9 +2843,9 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32_t *seq)
/* enumerate trusted domains
* (we need to have the list of trustdoms in the cache when we go offline) -
* Guenther */
-static NTSTATUS trusted_domains(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- struct netr_DomainTrustList *trusts)
+NTSTATUS wb_cache_trusted_domains(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct netr_DomainTrustList *trusts)
{
NTSTATUS status;
struct winbind_cache *cache;
@@ -2946,9 +2951,9 @@ do_query:
}
/* get lockout policy */
-static NTSTATUS lockout_policy(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- struct samr_DomInfo12 *policy)
+NTSTATUS wb_cache_lockout_policy(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct samr_DomInfo12 *policy)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
@@ -3016,9 +3021,9 @@ do_query:
}
/* get password policy */
-static NTSTATUS password_policy(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- struct samr_DomInfo1 *policy)
+NTSTATUS wb_cache_password_policy(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct samr_DomInfo1 *policy)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
@@ -4976,20 +4981,20 @@ do_query:
/* the cache backend methods are exposed via this structure */
struct winbindd_methods cache_methods = {
true,
- query_user_list,
- enum_dom_groups,
- enum_local_groups,
- name_to_sid,
- sid_to_name,
- rids_to_names,
- query_user,
- lookup_usergroups,
- lookup_useraliases,
- lookup_groupmem,
- sequence_number,
- lockout_policy,
- password_policy,
- trusted_domains
+ wb_cache_query_user_list,
+ wb_cache_enum_dom_groups,
+ wb_cache_enum_local_groups,
+ wb_cache_name_to_sid,
+ wb_cache_sid_to_name,
+ wb_cache_rids_to_names,
+ wb_cache_query_user,
+ wb_cache_lookup_usergroups,
+ wb_cache_lookup_useraliases,
+ wb_cache_lookup_groupmem,
+ wb_cache_sequence_number,
+ wb_cache_lockout_policy,
+ wb_cache_password_policy,
+ wb_cache_trusted_domains
};
static bool wcache_ndr_key(TALLOC_CTX *mem_ctx, const char *domain_name,
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 5e3d9fb..23900af 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -57,6 +57,74 @@ NTSTATUS rpc_lookup_sids(TALLOC_CTX *mem_ctx,
/* The following definitions come from winbindd/winbindd_cache.c */
+NTSTATUS wb_cache_query_user_list(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_entries,
+ struct wbint_userinfo **info);
+NTSTATUS wb_cache_enum_dom_groups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_entries,
+ struct wb_acct_info **info);
+NTSTATUS wb_cache_enum_local_groups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_entries,
+ struct wb_acct_info **info);
+NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const char *domain_name,
+ const char *name,
+ uint32_t flags,
+ struct dom_sid *sid,
+ enum lsa_SidType *type);
+NTSTATUS wb_cache_sid_to_name(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *sid,
+ char **domain_name,
+ char **name,
+ enum lsa_SidType *type);
+NTSTATUS wb_cache_rids_to_names(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *domain_sid,
+ uint32_t *rids,
+ size_t num_rids,
+ char **domain_name,
+ char ***names,
+ enum lsa_SidType **types);
+NTSTATUS wb_cache_query_user(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *user_sid,
+ struct wbint_userinfo *info);
+NTSTATUS wb_cache_lookup_usergroups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *user_sid,
+ uint32_t *pnum_sids,
+ struct dom_sid **psids);
+NTSTATUS wb_cache_lookup_useraliases(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t num_sids,
+ const struct dom_sid *sids,
+ uint32_t *num_aliases,
+ uint32_t **alias_rids);
+NTSTATUS wb_cache_lookup_groupmem(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *group_sid,
+ enum lsa_SidType type,
+ uint32_t *num_names,
+ struct dom_sid **sid_mem,
+ char ***names,
+ uint32_t **name_types);
+NTSTATUS wb_cache_sequence_number(struct winbindd_domain *domain,
+ uint32_t *seq);
+NTSTATUS wb_cache_lockout_policy(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct samr_DomInfo12 *policy);
+NTSTATUS wb_cache_password_policy(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct samr_DomInfo1 *policy);
+NTSTATUS wb_cache_trusted_domains(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct netr_DomainTrustList *trusts);
+
NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct dom_sid *sid);
NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
--
1.8.3.1
From 1eb6108d0f6b17b1f3580678c75e71b888d82694 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 7 Oct 2016 16:31:40 -0700
Subject: [PATCH 2/4] winbindd: Replace calls to domain->methods
domain->methods is always set to cache_methods; call those functions
directly instead of going through the indirection.
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/winbindd/winbindd_dual.c | 6 ++--
source3/winbindd/winbindd_dual_srv.c | 60 +++++++++++++++++++-----------------
source3/winbindd/winbindd_misc.c | 3 +-
source3/winbindd/winbindd_pam.c | 16 +++-------
4 files changed, 38 insertions(+), 47 deletions(-)
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index c16b94e..c389e00 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -939,7 +939,6 @@ static void account_lockout_policy_handler(struct tevent_context *ctx,
struct winbindd_child *child =
(struct winbindd_child *)private_data;
TALLOC_CTX *mem_ctx = NULL;
- struct winbindd_methods *methods;
struct samr_DomInfo12 lockout_policy;
NTSTATUS result;
@@ -955,13 +954,12 @@ static void account_lockout_policy_handler(struct tevent_context *ctx,
return;
}
- methods = child->domain->methods;
-
mem_ctx = talloc_init("account_lockout_policy_handler ctx");
if (!mem_ctx) {
result = NT_STATUS_NO_MEMORY;
} else {
- result = methods->lockout_policy(child->domain, mem_ctx, &lockout_policy);
+ result = wb_cache_lockout_policy(child->domain, mem_ctx,
+ &lockout_policy);
}
TALLOC_FREE(mem_ctx);
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index aed2781..4a581d33 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -62,8 +62,8 @@ NTSTATUS _wbint_LookupSid(struct pipes_struct *p, struct wbint_LookupSid *r)
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->sid_to_name(domain, p->mem_ctx, r->in.sid,
- &dom_name, &name, &type);
+ status = wb_cache_sid_to_name(domain, p->mem_ctx, r->in.sid,
+ &dom_name, &name, &type);
reset_cm_connection_on_error(domain, status);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -111,9 +111,9 @@ NTSTATUS _wbint_LookupName(struct pipes_struct *p, struct wbint_LookupName *r)
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->name_to_sid(
- domain, p->mem_ctx, r->in.domain, r->in.name, r->in.flags,
- r->out.sid, r->out.type);
+ status = wb_cache_name_to_sid(domain, p->mem_ctx, r->in.domain,
+ r->in.name, r->in.flags,
+ r->out.sid, r->out.type);
reset_cm_connection_on_error(domain, status);
return status;
}
@@ -276,8 +276,8 @@ NTSTATUS _wbint_QueryUser(struct pipes_struct *p, struct wbint_QueryUser *r)
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->query_user(domain, p->mem_ctx, r->in.sid,
- r->out.info);
+ status = wb_cache_query_user(domain, p->mem_ctx, r->in.sid,
+ r->out.info);
reset_cm_connection_on_error(domain, status);
return status;
}
@@ -292,9 +292,11 @@ NTSTATUS _wbint_LookupUserAliases(struct pipes_struct *p,
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->lookup_useraliases(
- domain, p->mem_ctx, r->in.sids->num_sids, r->in.sids->sids,
- &r->out.rids->num_rids, &r->out.rids->rids);
+ status = wb_cache_lookup_useraliases(domain, p->mem_ctx,
+ r->in.sids->num_sids,
+ r->in.sids->sids,
+ &r->out.rids->num_rids,
+ &r->out.rids->rids);
reset_cm_connection_on_error(domain, status);
return status;
}
@@ -309,9 +311,9 @@ NTSTATUS _wbint_LookupUserGroups(struct pipes_struct *p,
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->lookup_usergroups(
- domain, p->mem_ctx, r->in.sid,
- &r->out.sids->num_sids, &r->out.sids->sids);
+ status = wb_cache_lookup_usergroups(domain, p->mem_ctx, r->in.sid,
+ &r->out.sids->num_sids,
+ &r->out.sids->sids);
reset_cm_connection_on_error(domain, status);
return status;
}
@@ -326,7 +328,7 @@ NTSTATUS _wbint_QuerySequenceNumber(struct pipes_struct *p,
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->sequence_number(domain, r->out.sequence);
+ status = wb_cache_sequence_number(domain, r->out.sequence);
reset_cm_connection_on_error(domain, status);
return status;
}
@@ -345,9 +347,9 @@ NTSTATUS _wbint_LookupGroupMembers(struct pipes_struct *p,
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->lookup_groupmem(
- domain, p->mem_ctx, r->in.sid, r->in.type,
- &num_names, &sid_mem, &names, &name_types);
+ status = wb_cache_lookup_groupmem(domain, p->mem_ctx, r->in.sid,
+ r->in.type, &num_names, &sid_mem,
+ &names, &name_types);
reset_cm_connection_on_error(domain, status);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -380,9 +382,9 @@ NTSTATUS _wbint_QueryUserList(struct pipes_struct *p,
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->query_user_list(
- domain, p->mem_ctx, &r->out.users->num_userinfos,
- &r->out.users->userinfos);
+ status = wb_cache_query_user_list(domain, p->mem_ctx,
+ &r->out.users->num_userinfos,
+ &r->out.users->userinfos);
reset_cm_connection_on_error(domain, status);
return status;
}
@@ -426,18 +428,18 @@ NTSTATUS _wbint_QueryGroupList(struct pipes_struct *p,
}
if (include_local_groups) {
- status = domain->methods->enum_local_groups(domain, talloc_tos(),
- &num_local_groups,
- &local_groups);
+ status = wb_cache_enum_local_groups(domain, talloc_tos(),
+ &num_local_groups,
+ &local_groups);
reset_cm_connection_on_error(domain, status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
}
- status = domain->methods->enum_dom_groups(domain, talloc_tos(),
- &num_dom_groups,
- &dom_groups);
+ status = wb_cache_enum_dom_groups(domain, talloc_tos(),
+ &num_dom_groups,
+ &dom_groups);
reset_cm_connection_on_error(domain, status);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -611,9 +613,9 @@ NTSTATUS _wbint_LookupRids(struct pipes_struct *p, struct wbint_LookupRids *r)
return NT_STATUS_REQUEST_NOT_ACCEPTED;
}
- status = domain->methods->rids_to_names(
- domain, talloc_tos(), r->in.domain_sid, r->in.rids->rids,
- r->in.rids->num_rids, &domain_name, &names, &types);
+ status = wb_cache_rids_to_names(domain, talloc_tos(), r->in.domain_sid,
+ r->in.rids->rids, r->in.rids->num_rids,
+ &domain_name, &names, &types);
reset_cm_connection_on_error(domain, status);
if (!NT_STATUS_IS_OK(status)) {
return status;
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index fab41a1..12c5faa 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -160,8 +160,7 @@ enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *
DEBUG(3, ("[%5lu]: list trusted domains\n",
(unsigned long)state->pid));
- result = domain->methods->trusted_domains(domain, state->mem_ctx,
- &trusts);
+ result = wb_cache_trusted_domains(domain, state->mem_ctx, &trusts);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(3, ("winbindd_dual_list_trusted_domains: trusted_domains returned %s\n",
diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index 8456876..9433ad1 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -402,7 +402,6 @@ static NTSTATUS fillup_password_policy(struct winbindd_domain *domain,
struct winbindd_response *response)
{
TALLOC_CTX *frame = talloc_stackframe();
- struct winbindd_methods *methods;
NTSTATUS status;
struct samr_DomInfo1 password_policy;
@@ -413,9 +412,8 @@ static NTSTATUS fillup_password_policy(struct winbindd_domain *domain,
goto done;
}
- methods = domain->methods;
-
- status = methods->password_policy(domain, talloc_tos(), &password_policy);
+ status = wb_cache_password_policy(domain, talloc_tos(),
+ &password_policy);
if (NT_STATUS_IS_ERR(status)) {
goto done;
}
@@ -431,15 +429,12 @@ static NTSTATUS get_max_bad_attempts_from_lockout_policy(struct winbindd_domain
TALLOC_CTX *mem_ctx,
uint16_t *lockout_threshold)
{
- struct winbindd_methods *methods;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
struct samr_DomInfo12 lockout_policy;
*lockout_threshold = 0;
- methods = domain->methods;
-
- status = methods->lockout_policy(domain, mem_ctx, &lockout_policy);
+ status = wb_cache_lockout_policy(domain, mem_ctx, &lockout_policy);
if (NT_STATUS_IS_ERR(status)) {
return status;
}
@@ -453,15 +448,12 @@ static NTSTATUS get_pwd_properties(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32_t *password_properties)
{
- struct winbindd_methods *methods;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
struct samr_DomInfo1 password_policy;
*password_properties = 0;
- methods = domain->methods;
-
- status = methods->password_policy(domain, mem_ctx, &password_policy);
+ status = wb_cache_password_policy(domain, mem_ctx, &password_policy);
if (NT_STATUS_IS_ERR(status)) {
return status;
}
--
1.8.3.1
From d0cb11206d8e87d08b0b00b384fef51f58aac846 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 7 Oct 2016 16:40:22 -0700
Subject: [PATCH 3/4] winbindd: Remove now unused domain->methods
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/winbindd/winbindd.h | 9 ++++-----
source3/winbindd/winbindd_ndr.c | 1 -
source3/winbindd/winbindd_util.c | 1 -
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index 3d49e66..fce2e46 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -168,11 +168,10 @@ struct winbindd_domain {
bool can_do_ncacn_ip_tcp;
- /* Lookup methods for this domain (LDAP or RPC) */
- struct winbindd_methods *methods;
-
- /* the backend methods are used by the cache layer to find the right
- backend */
+ /*
+ * Lookup methods for this domain (LDAP or RPC). The backend
+ * methods are used by the cache layer.
+ */
struct winbindd_methods *backend;
/* Private data for the backends (used for connection cache) */
diff --git a/source3/winbindd/winbindd_ndr.c b/source3/winbindd/winbindd_ndr.c
index 029e883..028eb50 100644
--- a/source3/winbindd/winbindd_ndr.c
+++ b/source3/winbindd/winbindd_ndr.c
@@ -147,7 +147,6 @@ void ndr_print_winbindd_domain(struct ndr_print *ndr,
ndr_print_bool(ndr, "online", r->online);
ndr_print_time_t(ndr, "startup_time", r->startup_time);
ndr_print_bool(ndr, "startup", r->startup);
- ndr_print_winbindd_methods(ndr, "methods", r->methods);
ndr_print_winbindd_methods(ndr, "backend", r->backend);
ndr_print_ptr(ndr, "private_data", r->private_data);
ndr_print_string(ndr, "dcname", r->dcname);
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index d707173..2d1b03e 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -238,7 +238,6 @@ add_trusted_domain_from_tdc(const struct winbindd_tdc_domain *tdc,
}
}
- domain->methods = methods;
domain->backend = NULL;
domain->internal = is_internal_domain(sid);
domain->sequence_number = DOM_SEQUENCE_NONE;
--
1.8.3.1
From b2fbd7ecc0ce2541e07e5de6e9f083a2e59a1dce Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Fri, 7 Oct 2016 16:44:11 -0700
Subject: [PATCH 4/4] winbindd: Remove now unused cache_methods
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/winbindd/winbindd_cache.c | 19 -------------------
source3/winbindd/winbindd_ndr.c | 3 ---
source3/winbindd/winbindd_util.c | 32 +++++++++++---------------------
3 files changed, 11 insertions(+), 43 deletions(-)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index dd0cbf1..c52e9ed 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -4978,25 +4978,6 @@ do_query:
#endif
-/* the cache backend methods are exposed via this structure */
-struct winbindd_methods cache_methods = {
- true,
- wb_cache_query_user_list,
- wb_cache_enum_dom_groups,
- wb_cache_enum_local_groups,
- wb_cache_name_to_sid,
- wb_cache_sid_to_name,
- wb_cache_rids_to_names,
- wb_cache_query_user,
- wb_cache_lookup_usergroups,
- wb_cache_lookup_useraliases,
- wb_cache_lookup_groupmem,
- wb_cache_sequence_number,
- wb_cache_lockout_policy,
- wb_cache_password_policy,
- wb_cache_trusted_domains
-};
-
static bool wcache_ndr_key(TALLOC_CTX *mem_ctx, const char *domain_name,
uint32_t opnum, const DATA_BLOB *req,
TDB_DATA *pkey)
diff --git a/source3/winbindd/winbindd_ndr.c b/source3/winbindd/winbindd_ndr.c
index 028eb50..383de4e 100644
--- a/source3/winbindd/winbindd_ndr.c
+++ b/source3/winbindd/winbindd_ndr.c
@@ -81,7 +81,6 @@ extern struct winbindd_methods msrpc_methods;
extern struct winbindd_methods builtin_passdb_methods;
extern struct winbindd_methods sam_passdb_methods;
extern struct winbindd_methods reconnect_methods;
-extern struct winbindd_methods cache_methods;
void ndr_print_winbindd_methods(struct ndr_print *ndr,
const char *name,
@@ -110,8 +109,6 @@ void ndr_print_winbindd_methods(struct ndr_print *ndr,
ndr_print_string(ndr, name, "sam_passdb_methods");
} else if (r == &reconnect_methods) {
ndr_print_string(ndr, name, "reconnect_methods");
- } else if (r == &cache_methods) {
- ndr_print_string(ndr, name, "cache_methods");
} else {
ndr_print_string(ndr, name, "UNKNOWN");
}
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index 2d1b03e..217c049 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -35,10 +35,7 @@
#define DBGC_CLASS DBGC_WINBIND
static struct winbindd_domain *
-add_trusted_domain_from_tdc(const struct winbindd_tdc_domain *tdc,
- struct winbindd_methods *methods);
-
-extern struct winbindd_methods cache_methods;
+add_trusted_domain_from_tdc(const struct winbindd_tdc_domain *tdc);
/**
* @file winbindd_util.c
@@ -125,7 +122,7 @@ static bool is_in_internal_domain(const struct dom_sid *sid)
static struct winbindd_domain *
add_trusted_domain(const char *domain_name, const char *alt_name,
- struct winbindd_methods *methods, const struct dom_sid *sid)
+ const struct dom_sid *sid)
{
struct winbindd_tdc_domain tdc;
@@ -137,15 +134,14 @@ add_trusted_domain(const char *domain_name, const char *alt_name,
sid_copy(&tdc.sid, sid);
}
- return add_trusted_domain_from_tdc(&tdc, methods);
+ return add_trusted_domain_from_tdc(&tdc);
}
/* Add a trusted domain out of a trusted domain cache
entry
*/
static struct winbindd_domain *
-add_trusted_domain_from_tdc(const struct winbindd_tdc_domain *tdc,
- struct winbindd_methods *methods)
+add_trusted_domain_from_tdc(const struct winbindd_tdc_domain *tdc)
{
struct winbindd_domain *domain;
const char *alternative_name = NULL;
@@ -435,8 +431,7 @@ static void trustdom_list_done(struct tevent_req *req)
* This is important because we need the SID for sibling
* domains.
*/
- (void)add_trusted_domain_from_tdc(&trust_params,
- &cache_methods);
+ (void)add_trusted_domain_from_tdc(&trust_params);
p = q + strlen(q) + 1;
}
@@ -505,8 +500,7 @@ static void rescan_forest_root_trusts( void )
d = find_domain_from_name_noinit( dom_list[i].domain_name );
if ( !d ) {
- d = add_trusted_domain_from_tdc(&dom_list[i],
- &cache_methods);
+ d = add_trusted_domain_from_tdc(&dom_list[i]);
}
if (d == NULL) {
@@ -572,8 +566,7 @@ static void rescan_forest_trusts( void )
about it */
if ( !d ) {
- d = add_trusted_domain_from_tdc(&dom_list[i],
- &cache_methods);
+ d = add_trusted_domain_from_tdc(&dom_list[i]);
}
if (d == NULL) {
@@ -700,7 +693,6 @@ static void wb_imsg_new_trusted_domain(struct imessaging_context *msg,
d = add_trusted_domain(info.netbios_name.string,
info.domain_name.string,
- &cache_methods,
info.sid);
if (d == NULL) {
TALLOC_FREE(frame);
@@ -786,8 +778,7 @@ bool init_domain_list(void)
/* BUILTIN domain */
- (void)add_trusted_domain("BUILTIN", NULL, &cache_methods,
- &global_sid_Builtin);
+ (void)add_trusted_domain("BUILTIN", NULL, &global_sid_Builtin);
/* Local SAM */
@@ -807,7 +798,6 @@ bool init_domain_list(void)
}
domain = add_trusted_domain(pdb_domain_info->name,
pdb_domain_info->dns_domain,
- &cache_methods,
&pdb_domain_info->sid);
TALLOC_FREE(pdb_domain_info);
if (domain == NULL) {
@@ -857,7 +847,7 @@ bool init_domain_list(void)
} else {
(void)add_trusted_domain(get_global_sam_name(), NULL,
- &cache_methods, get_global_sam_sid());
+ get_global_sam_sid());
}
/* Add ourselves as the first entry. */
@@ -870,8 +860,8 @@ bool init_domain_list(void)
return False;
}
- domain = add_trusted_domain( lp_workgroup(), lp_realm(),
- &cache_methods, &our_sid);
+ domain = add_trusted_domain(lp_workgroup(), lp_realm(),
+ &our_sid);
if (domain) {
/* Even in the parent winbindd we'll need to
talk to the DC, so try and see if we can
--
1.8.3.1
More information about the samba-technical
mailing list