summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/winbindd_ads.c64
-rw-r--r--source3/winbindd/winbindd_proto.h16
-rw-r--r--source3/winbindd/winbindd_remove_mapping.c2
-rw-r--r--source3/winbindd/winbindd_rpc.c161
-rw-r--r--source3/winbindd/winbindd_set_hwm.c2
-rw-r--r--source3/winbindd/winbindd_set_mapping.c2
6 files changed, 128 insertions, 119 deletions
diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c
index 450d2ee3e5..119e81d3e2 100644
--- a/source3/winbindd/winbindd_ads.c
+++ b/source3/winbindd/winbindd_ads.c
@@ -983,8 +983,6 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
int i;
size_t num_members = 0;
ads_control args;
- struct rpc_pipe_client *cli;
- struct policy_handle lsa_policy;
DOM_SID *sid_mem_nocache = NULL;
char **names_nocache = NULL;
enum lsa_SidType *name_types_nocache = NULL;
@@ -1126,31 +1124,14 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
/* handle sids not resolved from cache by lsa_lookup_sids */
if (num_nocache > 0) {
- unsigned int orig_timeout;
- status = cm_connect_lsa(domain, tmp_ctx, &cli, &lsa_policy);
-
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-
- /*
- * This call can take a long time
- * allow the server to time out.
- * 35 seconds should do it.
- */
- orig_timeout = rpccli_set_timeout(cli, 35000);
-
- status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
- &lsa_policy,
- num_nocache,
- sid_mem_nocache,
- &domains_nocache,
- &names_nocache,
- &name_types_nocache);
-
- /* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
+ status = winbindd_lookup_sids(tmp_ctx,
+ domain,
+ num_nocache,
+ sid_mem_nocache,
+ &domains_nocache,
+ &names_nocache,
+ &name_types_nocache);
if (!(NT_STATUS_IS_OK(status) ||
NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED) ||
@@ -1159,30 +1140,13 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
DEBUG(1, ("lsa_lookupsids call failed with %s "
"- retrying...\n", nt_errstr(status)));
- status = cm_connect_lsa(domain, tmp_ctx, &cli,
- &lsa_policy);
-
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-
- /*
- * This call can take a long time
- * allow the server to time out.
- * 35 seconds should do it.
- */
- orig_timeout = rpccli_set_timeout(cli, 35000);
-
- status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
- &lsa_policy,
- num_nocache,
- sid_mem_nocache,
- &domains_nocache,
- &names_nocache,
- &name_types_nocache);
-
- /* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
+ status = winbindd_lookup_sids(tmp_ctx,
+ domain,
+ num_nocache,
+ sid_mem_nocache,
+ &domains_nocache,
+ &names_nocache,
+ &name_types_nocache);
}
if (NT_STATUS_IS_OK(status) ||
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index f1fc0f6a2a..427579faf1 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -63,6 +63,22 @@ int main(int argc, char **argv, char **envp);
/* The following definitions come from winbindd/winbindd_ads.c */
+/* The following definitions come from winbindd/winbindd_rpc.c */
+
+NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
+ struct winbindd_domain *domain,
+ uint32_t num_sids,
+ const struct dom_sid *sids,
+ char ***domains,
+ char ***names,
+ enum lsa_SidType **types);
+NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
+ struct winbindd_domain *domain,
+ uint32_t num_names,
+ const char **names,
+ const char ***domains,
+ struct dom_sid **sids,
+ enum lsa_SidType **types);
/* The following definitions come from winbindd/winbindd_async.c */
diff --git a/source3/winbindd/winbindd_remove_mapping.c b/source3/winbindd/winbindd_remove_mapping.c
index e94f6c28a1..055694d63c 100644
--- a/source3/winbindd/winbindd_remove_mapping.c
+++ b/source3/winbindd/winbindd_remove_mapping.c
@@ -96,7 +96,7 @@ static void winbindd_remove_mapping_done(struct tevent_req *subreq)
tevent_req_nterror(req, result);
return;
}
- return tevent_req_done(req);
+ tevent_req_done(req);
}
NTSTATUS winbindd_remove_mapping_recv(struct tevent_req *req,
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index f664f22232..70eeae6408 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -278,11 +278,8 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
DOM_SID *sids = NULL;
enum lsa_SidType *types = NULL;
char *full_name = NULL;
- struct rpc_pipe_client *cli;
- struct policy_handle lsa_policy;
NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
char *mapped_name = NULL;
- unsigned int orig_timeout;
if (name == NULL || *name=='\0') {
full_name = talloc_asprintf(mem_ctx, "%s", domain_name);
@@ -312,23 +309,9 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
DEBUG(3,("name_to_sid [rpc] %s for domain %s\n",
full_name?full_name:"", domain_name ));
- result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
- if (!NT_STATUS_IS_OK(result))
- return result;
-
- /*
- * This call can take a long time
- * allow the server to time out.
- * 35 seconds should do it.
- */
- orig_timeout = rpccli_set_timeout(cli, 35000);
-
- result = rpccli_lsa_lookup_names(cli, mem_ctx, &lsa_policy, 1,
- (const char**) &full_name, NULL, 1, &sids, &types);
-
- /* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
-
+ result = winbindd_lookup_names(mem_ctx, domain, 1,
+ (const char **)&full_name, NULL,
+ &sids, &types);
if (!NT_STATUS_IS_OK(result))
return result;
@@ -354,42 +337,26 @@ static NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
char **names;
enum lsa_SidType *types = NULL;
NTSTATUS result;
- struct rpc_pipe_client *cli;
- struct policy_handle lsa_policy;
NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
char *mapped_name = NULL;
- unsigned int orig_timeout;
DEBUG(3,("sid_to_name [rpc] %s for domain %s\n", sid_string_dbg(sid),
domain->name ));
- result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
+ result = winbindd_lookup_sids(mem_ctx,
+ domain,
+ 1,
+ sid,
+ &domains,
+ &names,
+ &types);
if (!NT_STATUS_IS_OK(result)) {
- DEBUG(2,("msrpc_sid_to_name: cm_connect_lsa() failed (%s)\n",
- nt_errstr(result)));
+ DEBUG(2,("msrpc_sid_to_name: failed to lookup sids: %s\n",
+ nt_errstr(result)));
return result;
}
- /*
- * This call can take a long time
- * allow the server to time out.
- * 35 seconds should do it.
- */
- orig_timeout = rpccli_set_timeout(cli, 35000);
-
- result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
- 1, sid, &domains, &names, &types);
-
- /* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
-
- if (!NT_STATUS_IS_OK(result)) {
- DEBUG(2,("msrpc_sid_to_name: rpccli_lsa_lookup_sids() failed (%s)\n",
- nt_errstr(result)));
- return result;
- }
-
*type = (enum lsa_SidType)types[0];
*domain_name = domains[0];
*name = names[0];
@@ -419,12 +386,9 @@ static NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
{
char **domains;
NTSTATUS result;
- struct rpc_pipe_client *cli;
- struct policy_handle lsa_policy;
DOM_SID *sids;
size_t i;
char **ret_names;
- unsigned int orig_timeout;
DEBUG(3, ("rids_to_names [rpc] for domain %s\n", domain->name ));
@@ -443,24 +407,13 @@ static NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
}
}
- result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
- if (!NT_STATUS_IS_OK(result)) {
- return result;
- }
-
- /*
- * This call can take a long time
- * allow the server to time out.
- * 35 seconds should do it.
- */
- orig_timeout = rpccli_set_timeout(cli, 35000);
-
- result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
- num_rids, sids, &domains,
- names, types);
-
- /* And restore our original timeout. */
- rpccli_set_timeout(cli, orig_timeout);
+ result = winbindd_lookup_sids(mem_ctx,
+ domain,
+ num_rids,
+ sids,
+ &domains,
+ names,
+ types);
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
@@ -1225,6 +1178,82 @@ static NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
return result;
}
+NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
+ struct winbindd_domain *domain,
+ uint32_t num_sids,
+ const struct dom_sid *sids,
+ char ***domains,
+ char ***names,
+ enum lsa_SidType **types)
+{
+ NTSTATUS status;
+ struct rpc_pipe_client *cli = NULL;
+ struct policy_handle lsa_policy;
+ unsigned int orig_timeout;
+
+ status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ /*
+ * This call can take a long time
+ * allow the server to time out.
+ * 35 seconds should do it.
+ */
+ orig_timeout = rpccli_set_timeout(cli, 35000);
+
+ status = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
+ num_sids, sids, domains,
+ names, types);
+
+ /* And restore our original timeout. */
+ rpccli_set_timeout(cli, orig_timeout);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return status;
+}
+
+NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
+ struct winbindd_domain *domain,
+ uint32_t num_names,
+ const char **names,
+ const char ***domains,
+ struct dom_sid **sids,
+ enum lsa_SidType **types)
+{
+ NTSTATUS status;
+ struct rpc_pipe_client *cli = NULL;
+ struct policy_handle lsa_policy;
+ unsigned int orig_timeout;
+
+ status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ /*
+ * This call can take a long time
+ * allow the server to time out.
+ * 35 seconds should do it.
+ */
+ orig_timeout = rpccli_set_timeout(cli, 35000);
+
+ status = rpccli_lsa_lookup_names(cli, mem_ctx, &lsa_policy, num_names,
+ names, domains, 1, sids, types);
+
+ /* And restore our original timeout. */
+ rpccli_set_timeout(cli, orig_timeout);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return status;
+}
/* the rpc backend methods are exposed via this structure */
struct winbindd_methods msrpc_methods = {
diff --git a/source3/winbindd/winbindd_set_hwm.c b/source3/winbindd/winbindd_set_hwm.c
index e648ee5bcd..4446ae22f0 100644
--- a/source3/winbindd/winbindd_set_hwm.c
+++ b/source3/winbindd/winbindd_set_hwm.c
@@ -85,7 +85,7 @@ static void winbindd_set_hwm_done(struct tevent_req *subreq)
tevent_req_nterror(req, result);
return;
}
- return tevent_req_done(req);
+ tevent_req_done(req);
}
NTSTATUS winbindd_set_hwm_recv(struct tevent_req *req,
diff --git a/source3/winbindd/winbindd_set_mapping.c b/source3/winbindd/winbindd_set_mapping.c
index 970ba7a4e1..8274c1eb10 100644
--- a/source3/winbindd/winbindd_set_mapping.c
+++ b/source3/winbindd/winbindd_set_mapping.c
@@ -96,7 +96,7 @@ static void winbindd_set_mapping_done(struct tevent_req *subreq)
tevent_req_nterror(req, result);
return;
}
- return tevent_req_done(req);
+ tevent_req_done(req);
}
NTSTATUS winbindd_set_mapping_recv(struct tevent_req *req,