summaryrefslogtreecommitdiffstats
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-02-14 01:08:31 +0100
committerAndrew Bartlett <abartlet@samba.org>2014-05-26 03:31:28 +0200
commite4f7b90295c461da8acdf1c4f23ae02c00211ed1 (patch)
tree3ce0e1dd8c49b2ac3bb041993914e8d31bdf3c22 /source4
parent3aebaf4c1340292baec0db8448e60af2079600c1 (diff)
downloadsamba-e4f7b90295c461da8acdf1c4f23ae02c00211ed1.tar.gz
samba-e4f7b90295c461da8acdf1c4f23ae02c00211ed1.tar.xz
samba-e4f7b90295c461da8acdf1c4f23ae02c00211ed1.zip
s4:librpc/rpc: avoid using dcerpc_socket_peer_addr()
We use information stored in the dcerpc_binding in order to open a secondary connection. The goals are: - dcerpc_secondary_connection_* should just use the dcerpc_binding information for the first connection and just call dcerpc_pipe_connect_* - Get rid of dcerpc_pipe->transport.* and just use a tstream_context. All other details should be maintained only by the higher levels. - Hide dcerpc_pipe and dcecli_connection behind dcerpc_binding_handle. - Have just one entry point to create a new connection. For source4/librpc this will be dcerpc_pipe_connect_*. For source3/rpc_client we need a similar function. - We'll have a new dcerpc_connection layer, with also just one entry point to create a new connection. - Replace dcerpc_pipe and dcecli_connection with the new dcerpc_connection layer. - Replace rpc_pipe_client with the new dcerpc_connection layer. - When the client side is unified we can change the server as it needs to act as a client in order to register the endpoint mappings. - Then the core of the server will be changed to use the new dcerpc_connection layer. As dcerpc_socket_peer_addr() uses p->transport.private_data as 'struct sock_private', we should avoid it. We can then remove dcerpc_unix_socket_path() and 'struct sock_private'. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/rpc/dcerpc_secondary.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c
index a84f3e6b1e6..9f5234519cf 100644
--- a/source4/librpc/rpc/dcerpc_secondary.c
+++ b/source4/librpc/rpc/dcerpc_secondary.c
@@ -31,14 +31,12 @@
#include "auth/credentials/credentials.h"
#include "param/param.h"
#include "libcli/resolve/resolve.h"
-#include "lib/socket/socket.h"
+#include "lib/util/util_net.h"
struct sec_conn_state {
struct dcerpc_pipe *pipe;
struct dcerpc_pipe *pipe2;
struct dcerpc_binding *binding;
- struct socket_address *peer_addr;
- const char *localaddress;
};
@@ -60,9 +58,11 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp
struct sec_conn_state *s;
struct composite_context *pipe_smb_req;
struct composite_context *pipe_tcp_req;
+ const char *localaddress = NULL;
struct composite_context *pipe_ncalrpc_req;
const char *ncalrpc_dir = NULL;
struct composite_context *pipe_unix_req;
+ const char *host;
const char *target_hostname;
const char *endpoint;
@@ -85,7 +85,22 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp
if (DEBUGLEVEL >= 10)
s->pipe2->conn->packet_log_dir = s->pipe->conn->packet_log_dir;
+ host = dcerpc_binding_get_string_option(s->binding, "host");
+ if (host == NULL) {
+ /*
+ * We may fallback to the host of the given connection
+ */
+ host = dcerpc_binding_get_string_option(s->pipe->binding,
+ "host");
+ }
target_hostname = dcerpc_binding_get_string_option(s->binding, "target_hostname");
+ if (target_hostname == NULL) {
+ /*
+ * We may fallback to the target_hostname of the given connection
+ */
+ target_hostname = dcerpc_binding_get_string_option(s->pipe->binding,
+ "target_hostname");
+ }
endpoint = dcerpc_binding_get_string_option(s->binding, "endpoint");
if (endpoint == NULL) {
/*
@@ -108,18 +123,40 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp
return c;
case NCACN_IP_TCP:
- s->peer_addr = dcerpc_socket_peer_addr(s->pipe->conn, s);
- if (!s->peer_addr) {
- composite_error(c, NT_STATUS_INVALID_PARAMETER);
+ if (host == NULL) {
+ composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX);
return c;
}
- s->localaddress = dcerpc_binding_get_string_option(s->binding,
+ if (!is_ipaddress(host)) {
+ /*
+ * We may fallback to the host of the given connection
+ */
+ host = dcerpc_binding_get_string_option(s->pipe->binding,
+ "host");
+ if (host == NULL) {
+ composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX);
+ return c;
+ }
+ if (!is_ipaddress(host)) {
+ composite_error(c, NT_STATUS_INVALID_PARAMETER_MIX);
+ return c;
+ }
+ }
+
+ localaddress = dcerpc_binding_get_string_option(s->binding,
"localaddress");
+ if (localaddress == NULL) {
+ /*
+ * We may fallback to the localaddress of the given connection
+ */
+ localaddress = dcerpc_binding_get_string_option(s->pipe->binding,
+ "localaddress");
+ }
pipe_tcp_req = dcerpc_pipe_open_tcp_send(s->pipe2->conn,
- s->localaddress,
- s->peer_addr->addr,
+ localaddress,
+ host,
target_hostname,
atoi(endpoint),
resolve_context_init(s));