s4:librpc/rpc: use dcerpc_binding_get_string_option() for "host" and "target_hostname"
authorStefan Metzmacher <metze@samba.org>
Tue, 4 Feb 2014 09:03:09 +0000 (10:03 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 13 Feb 2014 10:54:18 +0000 (11:54 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/librpc/rpc/dcerpc_connect.c
source4/librpc/rpc/dcerpc_secondary.c

index a67e376186b11bb4ff269acdaab43272a93617ce..3bd6eafabb2c09767b0140ce2068fd7005d50d9b 100644 (file)
@@ -150,12 +150,13 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT
 
        /* prepare smb connection parameters: we're connecting to IPC$ share on
           remote rpc server */
-       conn->in.dest_host              = s->io.binding->host;
-       conn->in.dest_ports                  = lpcfg_smb_ports(lp_ctx);
-       if (s->io.binding->target_hostname == NULL)
-               conn->in.called_name = "*SMBSERVER"; /* FIXME: This is invalid */
-       else
-               conn->in.called_name            = s->io.binding->target_hostname;
+       conn->in.dest_host = dcerpc_binding_get_string_option(s->io.binding, "host");
+       conn->in.dest_ports = lpcfg_smb_ports(lp_ctx);
+       conn->in.called_name =
+               dcerpc_binding_get_string_option(s->io.binding, "target_hostname");
+       if (conn->in.called_name == NULL) {
+               conn->in.called_name = "*SMBSERVER";
+       }
        conn->in.socket_options         = lpcfg_socket_options(lp_ctx);
        conn->in.service                = "IPC$";
        conn->in.service_type           = NULL;
@@ -294,6 +295,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(
        struct pipe_np_smb2_state *s;
        struct tevent_req *subreq;
        struct smbcli_options options;
+       const char *host;
        uint32_t flags;
 
        /* composite context allocation and setup */
@@ -306,6 +308,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(
 
        s->io = *io;
 
+       host = dcerpc_binding_get_string_option(s->io.binding, "host");
        flags = dcerpc_binding_get_flags(s->io.binding);
 
        /*
@@ -321,7 +324,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(
 
        /* send smb2 connect request */
        subreq = smb2_connect_send(s, c->event_ctx,
-                       s->io.binding->host,
+                       host,
                        lpcfg_parm_string_list(mem_ctx, lp_ctx, NULL, "smb2", "ports", NULL),
                        "IPC$",
                        s->io.resolve_ctx,
@@ -394,17 +397,12 @@ static struct composite_context* dcerpc_pipe_connect_ncacn_ip_tcp_send(TALLOC_CT
        c->private_data = s;
 
        /* store input parameters in state structure */
-       s->io               = *io;
+       s->io = *io;
        s->localaddr = dcerpc_binding_get_string_option(io->binding,
                                                        "localaddress");
-       if (io->binding->host != NULL) {
-               s->host = talloc_strdup(s, io->binding->host);
-               if (composite_nomem(s->host, c)) return c;
-       }
-       if (io->binding->target_hostname != NULL) {
-               s->target_hostname = talloc_strdup(s, io->binding->target_hostname);
-               if (composite_nomem(s->target_hostname, c)) return c;
-       }
+       s->host = dcerpc_binding_get_string_option(io->binding, "host");
+       s->target_hostname = dcerpc_binding_get_string_option(io->binding,
+                                                             "target_hostname");
        endpoint = dcerpc_binding_get_string_option(io->binding, "endpoint");
        /* port number is a binding endpoint here */
        if (endpoint != NULL) {
index 68746b6dfe2a14aaf1d973b04f2c75c0ddaec498..b8512e2153482613beb8d2894b7d104f981a4be3 100644 (file)
@@ -60,6 +60,7 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp
        struct composite_context *pipe_smb_req;
        struct composite_context *pipe_tcp_req;
        struct composite_context *pipe_ncalrpc_req;
+       const char *target_hostname;
        const char *endpoint;
 
        /* composite context allocation and setup */
@@ -80,6 +81,7 @@ _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;
 
+       target_hostname = dcerpc_binding_get_string_option(s->binding, "target_hostname");
        endpoint = dcerpc_binding_get_string_option(s->binding, "endpoint");
        if (endpoint == NULL) {
                /*
@@ -114,7 +116,7 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp
                pipe_tcp_req = dcerpc_pipe_open_tcp_send(s->pipe2->conn,
                                                         s->localaddress,
                                                         s->peer_addr->addr,
-                                                        s->binding->target_hostname,
+                                                        target_hostname,
                                                         atoi(endpoint),
                                                         resolve_context_init(s));
                composite_continue(c, pipe_tcp_req, continue_open_tcp, c);