cli_get_pipe_name_from_interface does not really need a talloc_ctx
authorVolker Lendecke <vl@samba.org>
Sat, 31 Jan 2009 23:30:04 +0000 (00:30 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 1 Feb 2009 13:34:22 +0000 (14:34 +0100)
source3/include/proto.h
source3/lib/netapi/cm.c
source3/rpc_client/cli_pipe.c
source3/rpc_client/rpc_transport_np.c
source3/rpcclient/rpcclient.c
source3/utils/net_rpc.c

index fd556690aa1281bd7c85c24ee8122221b366ce94..6a97d81a61094f8c6ff1dd122cd1b001153b040a 100644 (file)
@@ -5852,8 +5852,7 @@ bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
 
 /* The following definitions come from rpc_parse/parse_rpc.c  */
 
-const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx,
-                                        const struct ndr_syntax_id *interface);
+const char *get_pipe_name_from_iface(const struct ndr_syntax_id *interface);
 void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
                                uint32 call_id, int data_len, int auth_len);
 bool smb_io_rpc_hdr(const char *desc,  RPC_HDR *rpc, prs_struct *ps, int depth);
index d5ef09d831ab5db4435985e21e4a293c563bb236..233255fed4fe8c075fab08203a5c22681697dff7 100644 (file)
@@ -184,7 +184,7 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx,
        status = pipe_cm_open(ctx, cli, interface, &result);
        if (!NT_STATUS_IS_OK(status)) {
                libnetapi_set_error_string(ctx, "failed to open PIPE %s: %s",
-                       cli_get_pipe_name_from_iface(debug_ctx(), interface),
+                       get_pipe_name_from_iface(interface),
                        get_friendly_nt_error_msg(status));
                return WERR_DEST_NOT_FOUND;
        }
index a741dec70644adc8ea26a78c96ab75a70fe520e2..cee5d1cfc83f203d2a72c10f79653dbc3d0358dd 100644 (file)
@@ -81,9 +81,10 @@ static const struct pipe_id_info {
  Return the pipe name from the interface.
  ****************************************************************************/
 
-const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx,
-                                        const struct ndr_syntax_id *interface)
+const char *get_pipe_name_from_iface(const struct ndr_syntax_id *interface)
 {
+       char *guid_str;
+       const char *result;
        int i;
        for (i = 0; pipe_names[i].client_pipe; i++) {
                if (ndr_syntax_id_equal(pipe_names[i].abstr_syntax,
@@ -97,7 +98,18 @@ const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx,
         * interested in the known pipes mentioned in pipe_names[]
         */
 
-       return NULL;
+       guid_str = GUID_string(talloc_tos(), &interface->uuid);
+       if (guid_str == NULL) {
+               return NULL;
+       }
+       result = talloc_asprintf(talloc_tos(), "Interface %s.%d", guid_str,
+                                (int)interface->if_version);
+       TALLOC_FREE(guid_str);
+
+       if (result == NULL) {
+               return "PIPE";
+       }
+       return result;
 }
 
 /********************************************************************
@@ -3649,8 +3661,7 @@ NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
                }
                DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe "
                            "%s failed with error %s\n",
-                           cli_get_pipe_name_from_iface(debug_ctx(),
-                                                        interface),
+                           get_pipe_name_from_iface(interface),
                            nt_errstr(status) ));
                TALLOC_FREE(result);
                return status;
@@ -3658,8 +3669,7 @@ NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
 
        DEBUG(10,("cli_rpc_pipe_open_noauth: opened pipe %s to machine "
                  "%s and bound anonymously.\n",
-                 cli_get_pipe_name_from_iface(debug_ctx(), interface),
-                 cli->desthost ));
+                 get_pipe_name_from_iface(interface), cli->desthost));
 
        *presult = result;
        return NT_STATUS_OK;
@@ -3705,8 +3715,8 @@ static NTSTATUS cli_rpc_pipe_open_ntlmssp_internal(struct cli_state *cli,
 
        DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to "
                "machine %s and bound NTLMSSP as user %s\\%s.\n",
-                 cli_get_pipe_name_from_iface(debug_ctx(), interface),
-                 cli->desthost, domain, username ));
+                 get_pipe_name_from_iface(interface), cli->desthost, domain,
+                 username ));
 
        *presult = result;
        return NT_STATUS_OK;
@@ -3897,7 +3907,7 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
 
        DEBUG(10,("cli_rpc_pipe_open_schannel_with_key: opened pipe %s to machine %s "
                  "for domain %s and bound using schannel.\n",
-                 cli_get_pipe_name_from_iface(debug_ctx(), interface),
+                 get_pipe_name_from_iface(interface),
                  cli->desthost, domain ));
 
        *presult = result;
index 68aae6a0cc62e923d9cdcfb56a103f6223c552cc..a11e0e0f22ff5203f31d96a3a33788d0725789b4 100644 (file)
@@ -286,7 +286,6 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
 {
        struct async_req *result, *subreq;
        struct rpc_transport_np_init_state *state;
-       NTSTATUS status;
 
        if (!async_req_setup(mem_ctx, &result, &state,
                             struct rpc_transport_np_init_state)) {
@@ -304,12 +303,8 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
        }
        state->transport->priv = state->transport_np;
 
-       state->transport_np->pipe_name = cli_get_pipe_name_from_iface(
-               state, abstract_syntax);
-       if (state->transport_np->pipe_name == NULL) {
-               status = NT_STATUS_PIPE_NOT_AVAILABLE;
-               goto post_status;
-       }
+       state->transport_np->pipe_name = get_pipe_name_from_iface(
+               abstract_syntax);
        state->transport_np->cli = cli;
 
        subreq = cli_ntcreate_send(
@@ -323,10 +318,6 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
        subreq->async.priv = result;
        return result;
 
- post_status:
-       if (async_post_status(result, ev, status)) {
-               return result;
-       }
  fail:
        TALLOC_FREE(result);
        return NULL;
index 050e78d27485227772f8f4ec475d619770586bbb..9a02c129b5486be1398247b3b619efce516651ad 100644 (file)
@@ -619,16 +619,14 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                        default:
                                DEBUG(0, ("Could not initialise %s. Invalid "
                                          "auth type %u\n",
-                                         cli_get_pipe_name_from_iface(
-                                                 debug_ctx(),
+                                         get_pipe_name_from_iface(
                                                  cmd_entry->interface),
                                          pipe_default_auth_type ));
                                return NT_STATUS_UNSUCCESSFUL;
                }
                if (!NT_STATUS_IS_OK(ntresult)) {
                        DEBUG(0, ("Could not initialise %s. Error was %s\n",
-                                 cli_get_pipe_name_from_iface(
-                                         debug_ctx(),
+                                 get_pipe_name_from_iface(
                                          cmd_entry->interface),
                                  nt_errstr(ntresult) ));
                        return ntresult;
@@ -657,8 +655,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
 
                        if (!NT_STATUS_IS_OK(ntresult)) {
                                DEBUG(0, ("Could not initialise credentials for %s.\n",
-                                         cli_get_pipe_name_from_iface(
-                                                 debug_ctx(),
+                                         get_pipe_name_from_iface(
                                                  cmd_entry->interface)));
                                return ntresult;
                        }
index a37bbbd56671eb03fc142ab9aec4a9bf5a7e3881..bdf92a4e4b3f3df92fbd8da8a511f03d19c8b26d 100644 (file)
@@ -181,8 +181,7 @@ int run_rpc_command(struct net_context *c,
                        }
                        if (!NT_STATUS_IS_OK(nt_status)) {
                                DEBUG(0, ("Could not initialise pipe %s. Error was %s\n",
-                                       cli_get_pipe_name_from_iface(
-                                               debug_ctx(), interface),
+                                       get_pipe_name_from_iface(interface),
                                        nt_errstr(nt_status) ));
                                cli_shutdown(cli);
                                return -1;