]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_server3: Remove pipes_struct->remote_address
authorVolker Lendecke <vl@samba.org>
Mon, 4 Oct 2021 10:26:18 +0000 (12:26 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 5 Jan 2022 00:11:37 +0000 (00:11 +0000)
Also available via dcesrv_connection_get_remote_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/netlogon/srv_netlog_nt.c
source3/rpc_server/rpc_pipes.h
source3/rpc_server/rpc_worker.c
source3/rpc_server/samr/srv_samr_nt.c
source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/winbindd/winbindd_dual_srv.c

index bf29bf9126882db3d42ce9d41cb8115dfa85943b..23ddf11ac77a38657c366b6c009e5f89ff9d1728 100644 (file)
@@ -52,6 +52,8 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
        struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        const struct tsocket_address *local_address =
                dcesrv_connection_get_local_address(dcesrv_conn);
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        struct junction_map *jn = NULL;
        struct referral *old_referral_list = NULL;
        bool self_ref = False;
@@ -84,7 +86,7 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
        status = get_referred_path(ctx,
                                   p->session_info,
                                   r->in.path,
-                                  p->remote_address,
+                                  remote_address,
                                   local_address,
                                   true, /*allow_broken_path */
                                   jn, &consumedcnt, &self_ref);
@@ -127,6 +129,8 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
        struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        const struct tsocket_address *local_address =
                dcesrv_connection_get_local_address(dcesrv_conn);
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        struct junction_map *jn = NULL;
        bool self_ref = False;
        int consumedcnt = 0;
@@ -162,7 +166,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
        status = get_referred_path(ctx,
                                   p->session_info,
                                   r->in.dfs_entry_path,
-                                  p->remote_address,
+                                  remote_address,
                                   local_address,
                                   true, /*allow_broken_path */
                                   jn, &consumedcnt, &self_ref);
@@ -377,6 +381,8 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
        struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        const struct tsocket_address *local_address =
                dcesrv_connection_get_local_address(dcesrv_conn);
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        int consumedcnt = strlen(r->in.dfs_entry_path);
        struct junction_map *jn = NULL;
        bool self_ref = False;
@@ -400,7 +406,7 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
        status = get_referred_path(ctx,
                                   p->session_info,
                                   r->in.dfs_entry_path,
-                                  p->remote_address,
+                                  remote_address,
                                   local_address,
                                   true, /*allow_broken_path */
                                   jn, &consumedcnt, &self_ref);
index 4399f1fd73da4bd6b818b75d0c107de185d30b95..d38822f9bb2b0d49a72a0e5843fcfcf6048ce2d5 100644 (file)
@@ -411,6 +411,8 @@ NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p,
        struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        const struct tsocket_address *local_address =
                dcesrv_connection_get_local_address(dcesrv_conn);
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        NTSTATUS status;
        NTSTATUS result = NT_STATUS_OK;
        DATA_BLOB blob;
@@ -427,7 +429,7 @@ NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p,
 
        status = rpcint_binding_handle(p->mem_ctx,
                                       &ndr_table_lsarpc,
-                                      p->remote_address,
+                                      remote_address,
                                       local_address,
                                       p->session_info,
                                       p->msg_ctx,
@@ -1741,6 +1743,8 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
        struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        const struct tsocket_address *local_address =
                dcesrv_connection_get_local_address(dcesrv_conn);
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        NTSTATUS status = NT_STATUS_OK;
        union netr_LogonLevel *logon = r->in.logon;
        const char *nt_username, *nt_domain, *nt_workstation;
@@ -1872,7 +1876,7 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
                                                     &user_info,
                                                     nt_username, nt_domain,
                                                     wksname,
-                                                    p->remote_address,
+                                                    remote_address,
                                                     local_address,
                                                     logon->network->identity_info.parameter_control,
                                                     logon->network->lm.data,
@@ -1927,7 +1931,7 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
                                                         &user_info,
                                                         nt_username, nt_domain,
                                                         nt_workstation,
-                                                        p->remote_address,
+                                                        remote_address,
                                                         local_address,
                                                         logon->password->identity_info.parameter_control,
                                                         chal,
index 788f4964315c163a4b3f797f5ea969fb1398ee99..48e15dfdf52b48cbcc97a5b258c9a199ee6a8260 100644 (file)
@@ -37,8 +37,6 @@ struct dcesrv_context;
 struct pipes_struct {
        struct pipes_struct *next, *prev;
 
-       const struct tsocket_address *remote_address;
-
        enum dcerpc_transport_t transport;
 
        struct auth_session_info *session_info;
index 34d770415aaf23a03e74ebe2e0dd1a892dd48bbc..ce41bf564b37ffe3ea897fbc90ecfe0c84c0675c 100644 (file)
@@ -166,7 +166,6 @@ static int make_base_pipes_struct(
        struct messaging_context *msg_ctx,
        const char *pipe_name,
        enum dcerpc_transport_t transport,
-       const struct tsocket_address *remote_address,
        struct pipes_struct **_p)
 {
        struct pipes_struct *p;
@@ -179,12 +178,6 @@ static int make_base_pipes_struct(
        p->msg_ctx = msg_ctx;
        p->transport = transport;
 
-       p->remote_address = tsocket_address_copy(remote_address, p);
-       if (p->remote_address == NULL) {
-               talloc_free(p);
-               return ENOMEM;
-       }
-
        *_p = p;
        return 0;
 }
@@ -419,7 +412,6 @@ static void rpc_worker_new_client(
                ncacn_conn->msg_ctx,
                client->binding,
                transport,
-               ncacn_conn->remote_client_addr,
                &ncacn_conn->p);
        if (ret != 0) {
                DBG_DEBUG("make_base_pipes_struct failed: %s\n",
index 8b4ce2262525680208c4fe79cdc2329c71985f10..9ca7a8aff0db866661f9ea5745db7add02c04a52 100644 (file)
@@ -1888,6 +1888,10 @@ NTSTATUS _samr_ChangePasswordUser(struct pipes_struct *p,
 NTSTATUS _samr_ChangePasswordUser2(struct pipes_struct *p,
                                   struct samr_ChangePasswordUser2 *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        NTSTATUS status;
        char *user_name = NULL;
        char *rhost;
@@ -1915,7 +1919,7 @@ NTSTATUS _samr_ChangePasswordUser2(struct pipes_struct *p,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rhost = tsocket_address_inet_addr_string(p->remote_address,
+       rhost = tsocket_address_inet_addr_string(remote_address,
                                                 talloc_tos());
        if (rhost == NULL) {
                return NT_STATUS_NO_MEMORY;
@@ -1956,6 +1960,10 @@ NTSTATUS _samr_ChangePasswordUser2(struct pipes_struct *p,
 NTSTATUS _samr_OemChangePasswordUser2(struct pipes_struct *p,
                                      struct samr_OemChangePasswordUser2 *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        NTSTATUS status;
        char *user_name = NULL;
        const char *wks = NULL;
@@ -1992,7 +2000,7 @@ NTSTATUS _samr_OemChangePasswordUser2(struct pipes_struct *p,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       rhost = tsocket_address_inet_addr_string(p->remote_address,
+       rhost = tsocket_address_inet_addr_string(remote_address,
                                                 talloc_tos());
        if (rhost == NULL) {
                return NT_STATUS_NO_MEMORY;
@@ -2028,6 +2036,10 @@ NTSTATUS _samr_OemChangePasswordUser2(struct pipes_struct *p,
 NTSTATUS _samr_ChangePasswordUser3(struct pipes_struct *p,
                                   struct samr_ChangePasswordUser3 *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        NTSTATUS status;
        char *user_name = NULL;
        const char *wks = NULL;
@@ -2060,7 +2072,7 @@ NTSTATUS _samr_ChangePasswordUser3(struct pipes_struct *p,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rhost = tsocket_address_inet_addr_string(p->remote_address,
+       rhost = tsocket_address_inet_addr_string(remote_address,
                                                 talloc_tos());
        if (rhost == NULL) {
                return NT_STATUS_NO_MEMORY;
@@ -5212,6 +5224,10 @@ out:
 NTSTATUS _samr_SetUserInfo(struct pipes_struct *p,
                           struct samr_SetUserInfo *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        struct samr_info *uinfo;
        NTSTATUS status;
        struct samu *pwd = NULL;
@@ -5314,7 +5330,7 @@ NTSTATUS _samr_SetUserInfo(struct pipes_struct *p,
                return NT_STATUS_NO_SUCH_USER;
        }
 
-       rhost = tsocket_address_inet_addr_string(p->remote_address,
+       rhost = tsocket_address_inet_addr_string(remote_address,
                                                 talloc_tos());
        if (rhost == NULL) {
                return NT_STATUS_NO_MEMORY;
index 83e9665a748a30f7a907135478bd159f85dd4fba..8d9121f584c385a91a2daa718aafff2a2de0b425 100644 (file)
@@ -1676,6 +1676,10 @@ static WERROR copy_devicemode(TALLOC_CTX *mem_ctx,
 WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
                              struct spoolss_OpenPrinterEx *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        int snum;
        char *raddr;
        char *rhost;
@@ -1858,13 +1862,13 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
                }
 
                /* check smb.conf parameters and the the sec_desc */
-               raddr = tsocket_address_inet_addr_string(p->remote_address,
+               raddr = tsocket_address_inet_addr_string(remote_address,
                                                         p->mem_ctx);
                if (raddr == NULL) {
                        return WERR_NOT_ENOUGH_MEMORY;
                }
 
-               rc = get_remote_hostname(p->remote_address,
+               rc = get_remote_hostname(remote_address,
                                         &rhost,
                                         p->mem_ctx);
                if (rc < 0) {
@@ -2658,6 +2662,10 @@ static struct spoolss_NotifyOption *dup_spoolss_NotifyOption(TALLOC_CTX *mem_ctx
 WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p,
                                                     struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        int snum = -1;
        struct spoolss_NotifyOption *option = r->in.notify_options;
        struct sockaddr_storage client_ss;
@@ -2694,7 +2702,7 @@ WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p,
 
        DEBUG(10,("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
                  "remote_address is %s\n",
-                 tsocket_address_string(p->remote_address, p->mem_ctx)));
+                 tsocket_address_string(remote_address, p->mem_ctx)));
 
        if (!lp_print_notify_backchannel(snum)) {
                DEBUG(10, ("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
@@ -2702,7 +2710,7 @@ WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p,
                return WERR_RPC_S_SERVER_UNAVAILABLE;
        }
 
-       client_len = tsocket_address_bsd_sockaddr(p->remote_address,
+       client_len = tsocket_address_bsd_sockaddr(remote_address,
                                                  (struct sockaddr *) &client_ss,
                                                  sizeof(struct sockaddr_storage));
        if (client_len < 0) {
@@ -5927,6 +5935,10 @@ WERROR _spoolss_EndPagePrinter(struct pipes_struct *p,
 WERROR _spoolss_StartDocPrinter(struct pipes_struct *p,
                                struct spoolss_StartDocPrinter *r)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        struct spoolss_DocumentInfo1 *info_1;
        int snum;
        struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -5980,14 +5992,14 @@ WERROR _spoolss_StartDocPrinter(struct pipes_struct *p,
                return WERR_INVALID_HANDLE;
        }
 
-       rc = get_remote_hostname(p->remote_address,
+       rc = get_remote_hostname(remote_address,
                                 &rhost,
                                 p->mem_ctx);
        if (rc < 0) {
                return WERR_NOT_ENOUGH_MEMORY;
        }
        if (strequal(rhost,"UNKNOWN")) {
-               rhost = tsocket_address_inet_addr_string(p->remote_address,
+               rhost = tsocket_address_inet_addr_string(remote_address,
                                                         p->mem_ctx);
                if (rhost == NULL) {
                        return WERR_NOT_ENOUGH_MEMORY;
@@ -6950,6 +6962,10 @@ static WERROR update_printer(struct pipes_struct *p,
                             struct spoolss_SetPrinterInfoCtr *info_ctr,
                             struct spoolss_DeviceMode *devmode)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        uint32_t printer_mask = SPOOLSS_PRINTER_INFO_ALL;
        struct spoolss_SetPrinterInfo2 *printer = info_ctr->info.info2;
        struct spoolss_PrinterInfo2 *old_printer;
@@ -7021,7 +7037,7 @@ static WERROR update_printer(struct pipes_struct *p,
        {
                char *raddr;
 
-               raddr = tsocket_address_inet_addr_string(p->remote_address,
+               raddr = tsocket_address_inet_addr_string(remote_address,
                                                         p->mem_ctx);
                if (raddr == NULL) {
                        result = WERR_NOT_ENOUGH_MEMORY;
@@ -8435,6 +8451,10 @@ static WERROR spoolss_addprinterex_level_2(struct pipes_struct *p,
                                           struct spoolss_UserLevelCtr *user_ctr,
                                           struct policy_handle *handle)
 {
+       struct dcesrv_call_state *dce_call = p->dce_call;
+       struct dcesrv_connection *dcesrv_conn = dce_call->conn;
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        struct spoolss_SetPrinterInfo2 *info2 = info_ctr->info.info2;
        uint32_t info2_mask = SPOOLSS_PRINTER_INFO_ALL;
        const struct loadparm_substitution *lp_sub =
@@ -8487,7 +8507,7 @@ static WERROR spoolss_addprinterex_level_2(struct pipes_struct *p,
        if (*lp_addprinter_command(talloc_tos(), lp_sub) ) {
                char *raddr;
 
-               raddr = tsocket_address_inet_addr_string(p->remote_address,
+               raddr = tsocket_address_inet_addr_string(remote_address,
                                                         p->mem_ctx);
                if (raddr == NULL) {
                        return WERR_NOT_ENOUGH_MEMORY;
index d77c3fa4e0cf768684b15c901d06ba15932257e3..cefd134f2c6ad322eb4248833a925af22b24a5b7 100644 (file)
@@ -935,6 +935,8 @@ NTSTATUS _winbind_SamLogon(struct pipes_struct *p,
        struct dcesrv_connection *dcesrv_conn = dce_call->conn;
        const struct tsocket_address *local_address =
                dcesrv_connection_get_local_address(dcesrv_conn);
+       const struct tsocket_address *remote_address =
+               dcesrv_connection_get_remote_address(dcesrv_conn);
        struct winbindd_domain *domain;
        NTSTATUS status;
        struct netr_IdentityInfo *identity_info = NULL;
@@ -1031,7 +1033,7 @@ NTSTATUS _winbind_SamLogon(struct pipes_struct *p,
                                       0,
                                       challenge,
                                       lm_response, nt_response,
-                                      p->remote_address,
+                                      remote_address,
                                       local_address,
                                       &r->out.authoritative,
                                       true, /* skip_sam */