From: Volker Lendecke Date: Tue, 23 Feb 2021 15:16:39 +0000 (+0100) Subject: winbindd: Remove unused code X-Git-Tag: tevent-0.11.0~1313 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=02eef74e609e685177accbc494ed8b8d3e5b6abd;p=thirdparty%2Fsamba.git winbindd: Remove unused code Those calls were only used in winbindd_samr which now does direct and simpler samr calls. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 793ebe0df56..6e353cd453d 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -240,220 +240,6 @@ NTSTATUS rpc_enum_local_groups(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -/* convert a single name to a sid in a domain */ -NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx, - struct rpc_pipe_client *lsa_pipe, - struct policy_handle *lsa_policy, - const char *domain_name, - const char *name, - uint32_t flags, - const char **pdom_name, - struct dom_sid *sid, - enum lsa_SidType *type) -{ - enum lsa_SidType *types = NULL; - struct dom_sid *sids = NULL; - char *full_name = NULL; - const char *names[1]; - const char **domains; - char *mapped_name = NULL; - NTSTATUS status; - - if (name == NULL || name[0] == '\0') { - full_name = talloc_asprintf(mem_ctx, "%s", domain_name); - } else if (domain_name == NULL || domain_name[0] == '\0') { - full_name = talloc_asprintf(mem_ctx, "%s", name); - } else { - full_name = talloc_asprintf(mem_ctx, "%s\\%s", domain_name, name); - } - - if (full_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - - status = normalize_name_unmap(mem_ctx, full_name, &mapped_name); - /* Reset the full_name pointer if we mapped anything */ - if (NT_STATUS_IS_OK(status) || - NT_STATUS_EQUAL(status, NT_STATUS_FILE_RENAMED)) { - full_name = mapped_name; - } - - DEBUG(3,("name_to_sid: %s for domain %s\n", - full_name ? full_name : "", domain_name )); - - names[0] = full_name; - - /* - * We don't run into deadlocks here, cause winbind_off() is - * called in the main function. - */ - status = rpccli_lsa_lookup_names(lsa_pipe, - mem_ctx, - lsa_policy, - 1, /* num_names */ - names, - &domains, - 1, /* level */ - &sids, - &types); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(2,("name_to_sid: failed to lookup name: %s\n", - nt_errstr(status))); - return status; - } - - if (pdom_name != NULL) { - const char *dom_name; - - dom_name = talloc_strdup(mem_ctx, domains[0]); - if (dom_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - - *pdom_name = dom_name; - } - - sid_copy(sid, &sids[0]); - *type = types[0]; - - return NT_STATUS_OK; -} - -/* Convert a domain SID to a user or group name */ -NTSTATUS rpc_sid_to_name(TALLOC_CTX *mem_ctx, - struct rpc_pipe_client *lsa_pipe, - struct policy_handle *lsa_policy, - struct winbindd_domain *domain, - const struct dom_sid *sid, - char **pdomain_name, - char **pname, - enum lsa_SidType *ptype) -{ - char *mapped_name = NULL; - char **domains = NULL; - char **names = NULL; - enum lsa_SidType *types = NULL; - NTSTATUS map_status; - NTSTATUS status; - - status = rpccli_lsa_lookup_sids(lsa_pipe, - mem_ctx, - lsa_policy, - 1, /* num_sids */ - sid, - &domains, - &names, - &types); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(2,("sid_to_name: failed to lookup sids: %s\n", - nt_errstr(status))); - return status; - } - - *ptype = (enum lsa_SidType) types[0]; - - map_status = normalize_name_map(mem_ctx, - domain->name, - names[0], - &mapped_name); - if (NT_STATUS_IS_OK(map_status) || - NT_STATUS_EQUAL(map_status, NT_STATUS_FILE_RENAMED)) { - *pname = talloc_strdup(mem_ctx, mapped_name); - DEBUG(5,("returning mapped name -- %s\n", *pname)); - } else { - *pname = talloc_strdup(mem_ctx, names[0]); - } - if ((names[0] != NULL) && (*pname == NULL)) { - return NT_STATUS_NO_MEMORY; - } - - *pdomain_name = talloc_strdup(mem_ctx, domains[0]); - if (*pdomain_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - - return NT_STATUS_OK; -} - -/* Convert a bunch of rids to user or group names */ -NTSTATUS rpc_rids_to_names(TALLOC_CTX *mem_ctx, - struct rpc_pipe_client *lsa_pipe, - struct policy_handle *lsa_policy, - struct winbindd_domain *domain, - const struct dom_sid *sid, - uint32_t *rids, - size_t num_rids, - char **pdomain_name, - char ***pnames, - enum lsa_SidType **ptypes) -{ - enum lsa_SidType *types = NULL; - char *domain_name = NULL; - char **domains = NULL; - char **names = NULL; - struct dom_sid *sids; - size_t i; - NTSTATUS status; - - if (num_rids > 0) { - sids = talloc_array(mem_ctx, struct dom_sid, num_rids); - if (sids == NULL) { - return NT_STATUS_NO_MEMORY; - } - } else { - sids = NULL; - } - - for (i = 0; i < num_rids; i++) { - if (!sid_compose(&sids[i], sid, rids[i])) { - return NT_STATUS_INTERNAL_ERROR; - } - } - - status = rpccli_lsa_lookup_sids(lsa_pipe, - mem_ctx, - lsa_policy, - num_rids, - sids, - &domains, - &names, - &types); - if (!NT_STATUS_IS_OK(status) && - !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { - DEBUG(2,("rids_to_names: failed to lookup sids: %s\n", - nt_errstr(status))); - return status; - } - - for (i = 0; i < num_rids; i++) { - char *mapped_name = NULL; - NTSTATUS map_status; - - if (types[i] != SID_NAME_UNKNOWN) { - map_status = normalize_name_map(mem_ctx, - domain->name, - names[i], - &mapped_name); - if (NT_STATUS_IS_OK(map_status) || - NT_STATUS_EQUAL(map_status, NT_STATUS_FILE_RENAMED)) { - TALLOC_FREE(names[i]); - names[i] = talloc_strdup(names, mapped_name); - if (names[i] == NULL) { - return NT_STATUS_NO_MEMORY; - } - } - - domain_name = domains[i]; - } - } - - *pdomain_name = domain_name; - *ptypes = types; - *pnames = names; - - return NT_STATUS_OK; -} - /* Lookup groups a user is a member of. */ NTSTATUS rpc_lookup_usergroups(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *samr_pipe, diff --git a/source3/winbindd/winbindd_rpc.h b/source3/winbindd/winbindd_rpc.h index a5cfe77f289..c7e3dd6ff2d 100644 --- a/source3/winbindd/winbindd_rpc.h +++ b/source3/winbindd/winbindd_rpc.h @@ -46,39 +46,6 @@ NTSTATUS rpc_enum_local_groups(TALLOC_CTX *mem_ctx, uint32_t *pnum_info, struct wb_acct_info **pinfo); -/* Convert a single name to a sid in a domain */ -NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx, - struct rpc_pipe_client *lsa_pipe, - struct policy_handle *lsa_policy, - const char *domain_name, - const char *name, - uint32_t flags, - const char **pdom_name, - struct dom_sid *psid, - enum lsa_SidType *ptype); - -/* Convert a domain SID to a user or group name */ -NTSTATUS rpc_sid_to_name(TALLOC_CTX *mem_ctx, - struct rpc_pipe_client *lsa_pipe, - struct policy_handle *lsa_policy, - struct winbindd_domain *domain, - const struct dom_sid *sid, - char **pdomain_name, - char **pname, - enum lsa_SidType *ptype); - -/* Convert a bunch of rids to user or group names */ -NTSTATUS rpc_rids_to_names(TALLOC_CTX *mem_ctx, - struct rpc_pipe_client *lsa_pipe, - struct policy_handle *lsa_policy, - struct winbindd_domain *domain, - const struct dom_sid *sid, - uint32_t *rids, - size_t num_rids, - char **pdomain_name, - char ***pnames, - enum lsa_SidType **ptypes); - /* Lookup groups a user is a member of. */ NTSTATUS rpc_lookup_usergroups(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *samr_pipe,