]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_server3: Remove pipes_struct->local_address
authorVolker Lendecke <vl@samba.org>
Mon, 4 Oct 2021 10:19:57 +0000 (12:19 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 5 Jan 2022 00:11:37 +0000 (00:11 +0000)
Also available via dcesrv_connection_get_local_address(p->dce_call->conn)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpc_server/dfs/srv_dfs_nt.c
source3/rpc_server/epmapper/srv_epmapper.c
source3/rpc_server/netlogon/srv_netlog_nt.c
source3/rpc_server/rpc_pipes.h
source3/rpc_server/rpc_worker.c
source3/winbindd/winbindd_dual_srv.c

index 4821bea245780012ec874666009c3a6009730fe9..bf29bf9126882db3d42ce9d41cb8115dfa85943b 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "includes.h"
 #include "ntdomain.h"
+#include "librpc/rpc/dcesrv_core.h"
 #include "librpc/gen_ndr/ndr_dfs.h"
 #include "librpc/gen_ndr/ndr_dfs_scompat.h"
 #include "msdfs.h"
@@ -47,6 +48,10 @@ void _dfs_GetManagerVersion(struct pipes_struct *p, struct dfs_GetManagerVersion
 
 WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *local_address =
+               dcesrv_connection_get_local_address(dcesrv_conn);
        struct junction_map *jn = NULL;
        struct referral *old_referral_list = NULL;
        bool self_ref = False;
@@ -80,7 +85,7 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
                                   p->session_info,
                                   r->in.path,
                                   p->remote_address,
-                                  p->local_address,
+                                  local_address,
                                   true, /*allow_broken_path */
                                   jn, &consumedcnt, &self_ref);
        if(!NT_STATUS_IS_OK(status)) {
@@ -118,6 +123,10 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
 
 WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *local_address =
+               dcesrv_connection_get_local_address(dcesrv_conn);
        struct junction_map *jn = NULL;
        bool self_ref = False;
        int consumedcnt = 0;
@@ -154,7 +163,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
                                   p->session_info,
                                   r->in.dfs_entry_path,
                                   p->remote_address,
-                                  p->local_address,
+                                  local_address,
                                   true, /*allow_broken_path */
                                   jn, &consumedcnt, &self_ref);
        if(!NT_STATUS_IS_OK(status)) {
@@ -364,6 +373,10 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
 
 WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *local_address =
+               dcesrv_connection_get_local_address(dcesrv_conn);
        int consumedcnt = strlen(r->in.dfs_entry_path);
        struct junction_map *jn = NULL;
        bool self_ref = False;
@@ -388,7 +401,7 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
                                   p->session_info,
                                   r->in.dfs_entry_path,
                                   p->remote_address,
-                                  p->local_address,
+                                  local_address,
                                   true, /*allow_broken_path */
                                   jn, &consumedcnt, &self_ref);
        if(!NT_STATUS_IS_OK(status) ||
index b2b8935af15c1cf7bd82ab5fe33f32ffce4463b0..64f53cb49982c88724827734d6747a56269c9bef 100644 (file)
@@ -286,6 +286,8 @@ error_status_t _epm_Delete(struct pipes_struct *p,
 error_status_t _epm_Lookup(struct pipes_struct *p,
                           struct epm_Lookup *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        struct policy_handle *entry_handle;
        struct rpc_eps *eps;
        TALLOC_CTX *tmp_ctx;
@@ -310,6 +312,8 @@ error_status_t _epm_Lookup(struct pipes_struct *p,
 
        if (r->in.entry_handle == NULL ||
            ndr_policy_handle_empty(r->in.entry_handle)) {
+               const struct tsocket_address *local_address =
+                       dcesrv_connection_get_local_address(dcesrv_conn);
                char *srv_addr = NULL;
 
                DEBUG(7, ("_epm_Lookup: No entry_handle found, creating it.\n"));
@@ -320,11 +324,11 @@ error_status_t _epm_Lookup(struct pipes_struct *p,
                        goto done;
                }
 
-               if (p->local_address != NULL &&
-                   tsocket_address_is_inet(p->local_address, "ipv4"))
+               if (local_address != NULL &&
+                   tsocket_address_is_inet(local_address, "ipv4"))
                {
-                       srv_addr = tsocket_address_inet_addr_string(p->local_address,
-                                                                   tmp_ctx);
+                       srv_addr = tsocket_address_inet_addr_string(
+                               local_address, tmp_ctx);
                }
 
                switch (r->in.inquiry_type) {
@@ -740,6 +744,8 @@ fail:
 error_status_t _epm_Map(struct pipes_struct *p,
                        struct epm_Map *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        struct policy_handle *entry_handle;
        enum dcerpc_transport_t transport;
        struct ndr_syntax_id ifid;
@@ -818,6 +824,8 @@ error_status_t _epm_Map(struct pipes_struct *p,
 
        if (r->in.entry_handle == NULL ||
            ndr_policy_handle_empty(r->in.entry_handle)) {
+               const struct tsocket_address *local_addr =
+                       dcesrv_connection_get_local_address(dcesrv_conn);
                char *local_address = NULL;
                struct ndr_syntax_id_buf buf;
                char *if_string = NULL;
@@ -837,14 +845,14 @@ error_status_t _epm_Map(struct pipes_struct *p,
                DBG_INFO("Mapping interface %s\n", if_string);
 
                if ((transport == NCACN_IP_TCP) &&
-                   tsocket_address_is_inet(p->local_address, "ip")) {
+                   tsocket_address_is_inet(local_addr, "ip")) {
                        /*
                         * We don't have the host ip in the epm
                         * database. For NCACN_IP_TCP, add the IP that
                         * the client connected to.
                         */
                        local_address = tsocket_address_inet_addr_string(
-                               p->local_address, tmp_ctx);
+                               local_addr, tmp_ctx);
                }
 
                eps = epm_map_get_towers(
index 2bcf0addf5545e9e790944e02b8cf58edeb26535..4399f1fd73da4bd6b818b75d0c107de185d30b95 100644 (file)
@@ -407,6 +407,10 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
 NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p,
                                           struct netr_NetrEnumerateTrustedDomains *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *local_address =
+               dcesrv_connection_get_local_address(dcesrv_conn);
        NTSTATUS status;
        NTSTATUS result = NT_STATUS_OK;
        DATA_BLOB blob;
@@ -424,7 +428,7 @@ NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p,
        status = rpcint_binding_handle(p->mem_ctx,
                                       &ndr_table_lsarpc,
                                       p->remote_address,
-                                      p->local_address,
+                                      local_address,
                                       p->session_info,
                                       p->msg_ctx,
                                       &h);
@@ -1734,6 +1738,9 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
                                         struct netlogon_creds_CredentialState *creds)
 {
        struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *local_address =
+               dcesrv_connection_get_local_address(dcesrv_conn);
        NTSTATUS status = NT_STATUS_OK;
        union netr_LogonLevel *logon = r->in.logon;
        const char *nt_username, *nt_domain, *nt_workstation;
@@ -1866,7 +1873,7 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
                                                     nt_username, nt_domain,
                                                     wksname,
                                                     p->remote_address,
-                                                    p->local_address,
+                                                    local_address,
                                                     logon->network->identity_info.parameter_control,
                                                     logon->network->lm.data,
                                                     logon->network->lm.length,
@@ -1921,7 +1928,7 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
                                                         nt_username, nt_domain,
                                                         nt_workstation,
                                                         p->remote_address,
-                                                        p->local_address,
+                                                        local_address,
                                                         logon->password->identity_info.parameter_control,
                                                         chal,
                                                         logon->password->lmpassword.hash,
index 60fce8f0fa24ebe0563cef26bd8f1c2ab0729cc5..788f4964315c163a4b3f797f5ea969fb1398ee99 100644 (file)
@@ -37,7 +37,6 @@ struct dcesrv_context;
 struct pipes_struct {
        struct pipes_struct *next, *prev;
 
-       const struct tsocket_address *local_address;
        const struct tsocket_address *remote_address;
 
        enum dcerpc_transport_t transport;
index f1ee7efad2e8e441765ba451a59679bf104f634f..34d770415aaf23a03e74ebe2e0dd1a892dd48bbc 100644 (file)
@@ -167,7 +167,6 @@ static int make_base_pipes_struct(
        const char *pipe_name,
        enum dcerpc_transport_t transport,
        const struct tsocket_address *remote_address,
-       const struct tsocket_address *local_address,
        struct pipes_struct **_p)
 {
        struct pipes_struct *p;
@@ -186,14 +185,6 @@ static int make_base_pipes_struct(
                return ENOMEM;
        }
 
-       if (local_address) {
-               p->local_address = tsocket_address_copy(local_address, p);
-               if (p->local_address == NULL) {
-                       talloc_free(p);
-                       return ENOMEM;
-               }
-       }
-
        *_p = p;
        return 0;
 }
@@ -429,7 +420,6 @@ static void rpc_worker_new_client(
                client->binding,
                transport,
                ncacn_conn->remote_client_addr,
-               ncacn_conn->local_server_addr,
                &ncacn_conn->p);
        if (ret != 0) {
                DBG_DEBUG("make_base_pipes_struct failed: %s\n",
index 0be5ae5554bd51cca98769e17b4735c7bf66bbbd..d77c3fa4e0cf768684b15c901d06ba15932257e3 100644 (file)
@@ -25,6 +25,7 @@
 #include "winbindd/winbindd_proto.h"
 #include "rpc_client/cli_pipe.h"
 #include "ntdomain.h"
+#include "librpc/rpc/dcesrv_core.h"
 #include "librpc/gen_ndr/ndr_winbind.h"
 #include "librpc/gen_ndr/ndr_winbind_scompat.h"
 #include "../librpc/gen_ndr/ndr_netlogon_c.h"
@@ -930,6 +931,10 @@ reconnect:
 NTSTATUS _winbind_SamLogon(struct pipes_struct *p,
                        struct winbind_SamLogon *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *local_address =
+               dcesrv_connection_get_local_address(dcesrv_conn);
        struct winbindd_domain *domain;
        NTSTATUS status;
        struct netr_IdentityInfo *identity_info = NULL;
@@ -1027,7 +1032,7 @@ NTSTATUS _winbind_SamLogon(struct pipes_struct *p,
                                       challenge,
                                       lm_response, nt_response,
                                       p->remote_address,
-                                      p->local_address,
+                                      local_address,
                                       &r->out.authoritative,
                                       true, /* skip_sam */
                                       &flags,