s3:rpc_server: pass down local and remote tsocket_address to np_open()
authorStefan Metzmacher <metze@samba.org>
Tue, 27 Apr 2010 13:12:32 +0000 (15:12 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 27 May 2010 05:13:56 +0000 (07:13 +0200)
metze

source3/include/proto.h
source3/rpc_server/srv_pipe_hnd.c
source3/smbd/pipes.c

index 116db698e6294d248ceadd22076e35c8e0372f47..6c9790bc12a96afd1b3dee2e77167116143eb94a 100644 (file)
@@ -5205,8 +5205,10 @@ pipes_struct *get_first_internal_pipe(void);
 pipes_struct *get_next_internal_pipe(pipes_struct *p);
 
 bool fsp_is_np(struct files_struct *fsp);
+struct tsocket_address;
 NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
-                const char *client_address,
+                const struct tsocket_address *local_address,
+                const struct tsocket_address *remote_address,
                 struct auth_serversupplied_info *server_info,
                 struct fake_file_handle **phandle);
 bool np_read_in_progress(struct fake_file_handle *handle);
index b5b8379efa9a4d95de95a9fb39430548299bf5e4..215557dd7b0f0deae190f68bbfb7b140c93f454c 100644 (file)
@@ -1132,7 +1132,8 @@ static struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx,
 }
 
 NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
-                const char *client_address,
+                const struct tsocket_address *local_address,
+                const struct tsocket_address *remote_address,
                 struct auth_serversupplied_info *server_info,
                 struct fake_file_handle **phandle)
 {
@@ -1156,12 +1157,25 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
        } else {
                struct pipes_struct *p;
                struct ndr_syntax_id syntax;
+               const char *client_address;
 
                if (!is_known_pipename(name, &syntax)) {
                        TALLOC_FREE(handle);
                        return NT_STATUS_OBJECT_NAME_NOT_FOUND;
                }
 
+               if (tsocket_address_is_inet(remote_address, "ip")) {
+                       client_address = tsocket_address_inet_addr_string(
+                                               remote_address,
+                                               talloc_tos());
+                       if (client_address == NULL) {
+                               TALLOC_FREE(handle);
+                               return NT_STATUS_NO_MEMORY;
+                       }
+               } else {
+                       client_address = "";
+               }
+
                p = make_internal_rpc_pipe_p(handle, &syntax, client_address,
                                             server_info);
 
index e2c0cdc2f3436b4233174102a18a34f316470f91..17d2678e354515d235034acc1917ed7b9a40059f 100644 (file)
@@ -26,6 +26,7 @@
 
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 #define        PIPE            "\\PIPE\\"
 #define        PIPELEN         strlen(PIPE)
@@ -65,7 +66,9 @@ NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
                return status;
        }
 
-       status = np_open(fsp, name, conn->client_address,
+       status = np_open(fsp, name,
+                        conn->sconn->local_address,
+                        conn->sconn->remote_address,
                         conn->server_info, &fsp->fake_file_handle);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("np_open(%s) returned %s\n", name,