Refactoring: Change calling conventions for cli_rpc_pipe_open_noauth
authorVolker Lendecke <vl@samba.org>
Sun, 20 Jul 2008 09:04:31 +0000 (11:04 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 20 Jul 2008 15:37:11 +0000 (17:37 +0200)
Pass in ndr_syntax_id instead of pipe_idx, return NTSTATUS
(This used to be commit 9abc9dc4dc13bd3e42f98eff64eacf24b51f5779)

30 files changed:
source3/auth/auth_domain.c
source3/client/client.c
source3/include/proto.h
source3/include/rpc_dce.h
source3/lib/netapi/cm.c
source3/libnet/libnet_join.c
source3/librpc/rpc/dcerpc.c
source3/libsmb/libsmb_dir.c
source3/libsmb/libsmb_server.c
source3/libsmb/passchange.c
source3/libsmb/trusts_util.c
source3/rpc_client/cli_pipe.c
source3/rpc_parse/parse_rpc.c
source3/rpc_parse/parse_spoolss.c
source3/rpc_server/srv_spoolss.c
source3/rpc_server/srv_spoolss_nt.c
source3/rpcclient/cmd_spoolss.c
source3/rpcclient/cmd_test.c
source3/rpcclient/rpcclient.c
source3/smbd/change_trust_pw.c
source3/utils/net_ads.c
source3/utils/net_rpc.c
source3/utils/net_rpc_join.c
source3/utils/net_rpc_shell.c
source3/utils/net_util.c
source3/utils/netlookup.c
source3/utils/smbcacls.c
source3/utils/smbcquotas.c
source3/utils/smbtree.c
source3/winbindd/winbindd_cm.c

index f483718552b9d07c8198a87858d4772efbe2e62f..2c67bf9f1c81dd243939eef1247669b6f20184c3 100644 (file)
@@ -112,10 +112,11 @@ static NTSTATUS connect_to_domain_password_server(struct cli_state **cli,
                netlogon_pipe = cli_rpc_pipe_open_schannel(*cli, PI_NETLOGON,
                                        PIPE_AUTH_LEVEL_PRIVACY, domain, &result);
        } else {
-               netlogon_pipe = cli_rpc_pipe_open_noauth(*cli, PI_NETLOGON, &result);
+               result = cli_rpc_pipe_open_noauth(
+                       *cli, &ndr_table_netlogon.syntax_id, &netlogon_pipe);
        }
 
-       if(!netlogon_pipe) {
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(0,("connect_to_domain_password_server: unable to open the domain client session to \
 machine %s. Error was : %s.\n", dc_name, nt_errstr(result)));
                cli_shutdown(*cli);
index 149b5303694429be85cc83a7bf391bfca4fffe1a..18b286324b62bb1d503207589bc0c9fc42f0d2c2 100644 (file)
@@ -3634,9 +3634,10 @@ static bool browse_host_rpc(bool sort)
        uint32_t total_entries = 0;
        int i;
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id,
+                                         &pipe_hnd);
 
-       if (pipe_hnd == NULL) {
+       if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("Could not connect to srvsvc pipe: %s\n",
                           nt_errstr(status)));
                TALLOC_FREE(frame);
index ab923830bc3d6abfc51d30ccbd5ce507a0208b10..1395ec524b0f2988ed0ebb64893c4d8fa777d734 100644 (file)
@@ -7101,7 +7101,9 @@ NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
 NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
                               const struct ndr_syntax_id *abstract_syntax,
                               struct rpc_pipe_client **presult);
-struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe_idx, NTSTATUS *perr);
+NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
+                                 const struct ndr_syntax_id *interface,
+                                 struct rpc_pipe_client **presult);
 struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp(struct cli_state *cli,
                                                int pipe_idx,
                                                enum pipe_auth_level auth_level,
@@ -7910,6 +7912,7 @@ bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
 
 const char *cli_get_pipe_name(int pipe_idx);
 int cli_get_pipe_idx(const RPC_IFACE *syntax);
+const struct ndr_syntax_id *cli_get_iface(int pipe_idx);
 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 580b14f1d810ad9a50e21b658d7b119b1474a15e..b63f0eac5e39059e579c61ecd8cfde629fe417be 100644 (file)
@@ -159,6 +159,8 @@ enum schannel_direction {
 /* RPC_IFACE */
 typedef struct ndr_syntax_id RPC_IFACE;
 
+extern const struct ndr_syntax_id syntax_spoolss;
+
 #define RPC_IFACE_LEN (UUID_SIZE + 4)
 
 /* RPC_HDR - dce rpc header */
index ae1091c5044d1e454db65569dd13db6de89657cb..fe5490c73b4ce139034bf84bf113e24e1b74c01b 100644 (file)
@@ -132,8 +132,9 @@ static struct rpc_pipe_client *pipe_cm_connect(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       p->pipe = cli_rpc_pipe_open_noauth(cli, pipe_idx, status);
-       if (!p->pipe) {
+       *status = cli_rpc_pipe_open_noauth(cli, cli_get_iface(pipe_idx),
+                                          &p->pipe);
+       if (!NT_STATUS_IS_OK(*status)) {
                TALLOC_FREE(p);
                return NULL;
        }
index bb21bc49893edb3fabb91c3487fb6975a06431b4..40637afabdf18b11afb92a6f6c92c6adb96b077e 100644 (file)
@@ -668,8 +668,9 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(*cli, PI_LSARPC, &status);
-       if (!pipe_hnd) {
+       status = cli_rpc_pipe_open_noauth(*cli, &ndr_table_lsarpc.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Error connecting to LSA pipe. Error was %s\n",
                        nt_errstr(status)));
                goto done;
@@ -750,8 +751,9 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
 
        /* Open the domain */
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &status);
-       if (!pipe_hnd) {
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Error connecting to SAM pipe. Error was %s\n",
                        nt_errstr(status)));
                goto done;
@@ -1136,8 +1138,9 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
 
        /* Open the domain */
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &status);
-       if (!pipe_hnd) {
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Error connecting to SAM pipe. Error was %s\n",
                        nt_errstr(status)));
                goto done;
index c8bca8d3eb72b20bce946b5e18403b0bca937734..58d676a9d92e74d71a9f799acfd68a65836a9f28 100644 (file)
@@ -131,7 +131,6 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, struct dcerpc_pipe
        struct dcerpc_pipe *p = talloc(parent_ctx, struct dcerpc_pipe);
        struct dcerpc_binding *binding;
        NTSTATUS nt_status;
-       int idx;
 
        nt_status = dcerpc_parse_binding(p, binding_string, &binding);
 
@@ -165,16 +164,10 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, struct dcerpc_pipe
                return nt_status;
        }
 
-       idx = cli_get_pipe_idx(&table->syntax_id);
-       if (idx < 0) {
-               DEBUG(0, ("Unable to find interface index"));
-               talloc_free(p);
-               return NT_STATUS_OBJECT_PATH_INVALID;
-       }
-
-       p->rpc_cli = cli_rpc_pipe_open_noauth(p->cli, idx, &nt_status);
+       nt_status = cli_rpc_pipe_open_noauth(p->cli, &table->syntax_id,
+                                            &p->rpc_cli);
 
-       if (p->rpc_cli == NULL) {
+       if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(p);
                return nt_status;
        }
index aea4f103b6f314c2aa8375c4e8aef1de3c7f1778..aa313f2c05b84479386a493bc8ca8ac6562dcb3a 100644 (file)
@@ -273,8 +273,9 @@ net_share_enum_rpc(struct cli_state *cli,
        uint32_t total_entries = 0;
 
         /* Open the server service pipe */
-        pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status);
-        if (!pipe_hnd) {
+        nt_status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id,
+                                            &pipe_hnd);
+        if (!NT_STATUS_IS_OK(nt_status)) {
                 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n"));
                 return -1;
         }
index 7af5ca3a2457e4053ae6772a02b9917975910327..0a3287bc8229489c5544f56536484240b0887897 100644 (file)
@@ -646,10 +646,9 @@ SMBC_attr_server(TALLOC_CTX *ctx,
                 ZERO_STRUCTP(ipc_srv);
                 ipc_srv->cli = ipc_cli;
                 
-                pipe_hnd = cli_rpc_pipe_open_noauth(ipc_srv->cli,
-                                                    PI_LSARPC,
-                                                    &nt_status);
-                if (!pipe_hnd) {
+                nt_status = cli_rpc_pipe_open_noauth(
+                       ipc_srv->cli, &ndr_table_lsarpc.syntax_id, &pipe_hnd);
+                if (!NT_STATUS_IS_OK(nt_status)) {
                         DEBUG(1, ("cli_nt_session_open fail!\n"));
                         errno = ENOTSUP;
                         cli_shutdown(ipc_srv->cli);
index 3b82e5767f02a3d582ccbe71efd3450a47fa8981..86c7b521604c740fb121d7f5fea3bbe01b303b9e 100644 (file)
@@ -152,10 +152,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
                 * will just fail. So we do it anonymously, there's no other
                 * way.
                 */
-               pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
+               result = cli_rpc_pipe_open_noauth(
+                       cli, &ndr_table_samr.syntax_id, &pipe_hnd);
        }
 
-       if (!pipe_hnd) {
+       if (!NT_STATUS_IS_OK(result)) {
                if (lp_client_lanman_auth()) {
                        /* Use the old RAP method. */
                        if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) {
@@ -204,9 +205,10 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
        result = NT_STATUS_UNSUCCESSFUL;
        
        /* OK, this is ugly, but... try an anonymous pipe. */
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
+                                         &pipe_hnd);
 
-       if ( pipe_hnd &&
+       if ( NT_STATUS_IS_OK(result) &&
                (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user2(
                                         pipe_hnd, talloc_tos(), user_name,
                                         new_passwd, old_passwd)))) {
index 6b3bbaf1d82991543a78ced654f0c581bdd0e937..f4fdf9eb6fe898db3123587895d20f2809fc7695 100644 (file)
@@ -201,8 +201,9 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
 
        /* open the LSARPC_PIPE */
 
-       lsa_pipe = cli_rpc_pipe_open_noauth( cli, PI_LSARPC, &result );
-       if ( !lsa_pipe) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &lsa_pipe);
+       if (!NT_STATUS_IS_OK(result)) {
                goto done;
        }
 
index 1a55bc20dae9cc3812c909051ee29ef9592226e8..6fe3a0831a6846beb42d6024a871cd7472478780 100644 (file)
 interface/version dce/rpc pipe identification
 ********************************************************************/
 
-static const struct ndr_syntax_id syntax_spoolss = {
-       {
-               0x12345678, 0x1234, 0xabcd,
-               { 0xef, 0x00 },
-               { 0x01, 0x23,
-                 0x45, 0x67, 0x89, 0xab }
-       }, 0x01
-};
-
 #define PIPE_SRVSVC   "\\PIPE\\srvsvc"
 #define PIPE_SAMR     "\\PIPE\\samr"
 #define PIPE_WINREG   "\\PIPE\\winreg"
@@ -130,6 +121,15 @@ int cli_get_pipe_idx(const RPC_IFACE *syntax)
        return -1;
 }
 
+/********************************************************************
+ LEGACY function to ease transition from pipe_idx to interface
+ ********************************************************************/
+const struct ndr_syntax_id *cli_get_iface(int pipe_idx)
+{
+       SMB_ASSERT((pipe_idx >= 0) && (pipe_idx < PI_MAX_PIPES));
+       return pipe_names[pipe_idx].abstr_syntax;
+}
+
 /********************************************************************
  Map internal value to wire value.
  ********************************************************************/
@@ -2985,23 +2985,25 @@ static NTSTATUS cli_rpc_pipe_open(struct cli_state *cli,
  Open a named pipe to an SMB server and bind anonymously.
  ****************************************************************************/
 
-struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe_idx, NTSTATUS *perr)
+NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
+                                 const struct ndr_syntax_id *interface,
+                                 struct rpc_pipe_client **presult)
 {
        struct rpc_pipe_client *result;
        struct cli_pipe_auth_data *auth;
+       NTSTATUS status;
 
-       *perr = cli_rpc_pipe_open(cli, pipe_names[pipe_idx].abstr_syntax,
-                                 &result);
-       if (!NT_STATUS_IS_OK(*perr)) {
-               return NULL;
+       status = cli_rpc_pipe_open(cli, interface, &result);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
-       *perr = rpccli_anon_bind_data(result, &auth);
-       if (!NT_STATUS_IS_OK(*perr)) {
+       status = rpccli_anon_bind_data(result, &auth);
+       if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("rpccli_anon_bind_data returned %s\n",
-                         nt_errstr(*perr)));
+                         nt_errstr(status)));
                TALLOC_FREE(result);
-               return NULL;
+               return status;
        }
 
        /*
@@ -3017,30 +3019,34 @@ struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe
        auth->domain = talloc_strdup(auth, cli->domain);
 
        if ((auth->user_name == NULL) || (auth->domain == NULL)) {
-               *perr = NT_STATUS_NO_MEMORY;
                TALLOC_FREE(result);
-               return NULL;
+               return NT_STATUS_NO_MEMORY;
        }
 
-       *perr = rpc_pipe_bind(result, auth);
-       if (!NT_STATUS_IS_OK(*perr)) {
+       status = rpc_pipe_bind(result, auth);
+       if (!NT_STATUS_IS_OK(status)) {
                int lvl = 0;
-               if (rpccli_is_pipe_idx(result, PI_DSSETUP)) {
+               if (ndr_syntax_id_equal(interface,
+                                       &ndr_table_dssetup.syntax_id)) {
                        /* non AD domains just don't have this pipe, avoid
                         * level 0 statement in that case - gd */
                        lvl = 3;
                }
-               DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe %s failed with error %s\n",
-                       cli_get_pipe_name(pipe_idx), nt_errstr(*perr) ));
+               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(), cli,
+                                                        interface),
+                           nt_errstr(status) ));
                TALLOC_FREE(result);
-               return NULL;
+               return status;
        }
 
        DEBUG(10,("cli_rpc_pipe_open_noauth: opened pipe %s to machine "
                  "%s and bound anonymously.\n", result->trans.np.pipe_name,
                  cli->desthost ));
 
-       return result;
+       *presult = result;
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -3204,8 +3210,9 @@ struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
 {
        struct rpc_pipe_client *netlogon_pipe = NULL;
 
-       netlogon_pipe = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, perr);
-       if (!netlogon_pipe) {
+       *perr = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
+                                        &netlogon_pipe);
+       if (!NT_STATUS_IS_OK(*perr)) {
                return NULL;
        }
 
index 14a4effbf036c2856c82ed7ca680093b967bde0f..1477a4c81e611f7412462dfaed9d2b21b65a8214 100644 (file)
@@ -639,3 +639,13 @@ bool smb_io_rpc_auth_schannel_chk(const char *desc, int auth_len,
 
        return True;
 }
+
+const struct ndr_syntax_id syntax_spoolss = {
+       {
+               0x12345678, 0x1234, 0xabcd,
+               { 0xef, 0x00 },
+               { 0x01, 0x23,
+                 0x45, 0x67, 0x89, 0xab }
+       }, 0x01
+};
+
index ec6d44293d2f1181eee3d83596ebbb228c5f9111..f2d3b53772c0b41ab8a8cf274e7898d0d589444e 100644 (file)
@@ -7724,4 +7724,3 @@ bool convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf )
 
        return True;
 }
-
index 4744b902633a2a8f80686f50c3f71499a338522e..22b3a7607eab5a7c2b2eadc1e0e25f02b3dbb258 100644 (file)
@@ -1630,15 +1630,6 @@ void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns )
        *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
 }
 
-static const struct ndr_syntax_id syntax_spoolss = {
-       {
-               0x12345678, 0x1234, 0xabcd,
-               { 0xef, 0x00 },
-               { 0x01, 0x23,
-                 0x45, 0x67, 0x89, 0xab }
-       }, 0x01
-};
-
 NTSTATUS rpc_spoolss_init(void)
 {
   return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
index ca2574f984d417f2064e3b9bbbcfd2a80c046604..f80240042c67721195cc372001a59b0276c7cb96 100644 (file)
@@ -2617,7 +2617,8 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
         * Now start the NT Domain stuff :-).
         */
 
-       if ( !(*pp_pipe = cli_rpc_pipe_open_noauth(the_cli, PI_SPOOLSS, &ret)) ) {
+       ret = cli_rpc_pipe_open_noauth(the_cli, &syntax_spoolss, pp_pipe);
+       if (!NT_STATUS_IS_OK(ret)) {
                DEBUG(2,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n",
                        remote_machine, nt_errstr(ret)));
                cli_shutdown(the_cli);
index 0876d8287887d9119e64ea062c99e75d7e21a9d1..d9cc3c67f5ddda752ce316485e3a6447723bc009 100644 (file)
@@ -2680,8 +2680,9 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
        if ( !NT_STATUS_IS_OK(nt_status) )
                return WERR_GENERAL_FAILURE;
 
-       cli2 = cli_rpc_pipe_open_noauth(cli_server2, PI_SPOOLSS, &nt_status);
-       if (!cli2) {
+       nt_status = cli_rpc_pipe_open_noauth(cli_server2, &syntax_spoolss,
+                                            &cli2);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                printf("failed to open spoolss pipe on server %s (%s)\n",
                        servername2, nt_errstr(nt_status));
                return WERR_GENERAL_FAILURE;
index dd956604cc579c960aff50df8368f1c74ec94548..599e4c255d891145d54de8cb5b70e50c04ada283 100644 (file)
@@ -30,13 +30,19 @@ static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
 
        d_printf("testme\n");
 
-       lsa_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(cli),
-                                           PI_LSARPC, &status);
-       if (lsa_pipe == NULL) goto done;
+       status = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(cli),
+                                         &ndr_table_lsarpc.syntax_id,
+                                         &lsa_pipe);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto done;
+       }
 
-       samr_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(cli),
-                                            PI_SAMR, &status);
-       if (samr_pipe == NULL) goto done;
+       status = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(cli),
+                                         &ndr_table_samr.syntax_id,
+                                         &samr_pipe);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto done;
+       }
 
        status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
                                        SEC_RIGHTS_QUERY_VALUE, &pol);
index 35ff14ef2d6df6337807f01e65ab5e5d9f716f95..ff98a24fbae52e11623687e6cee0ef430a01b26d 100644 (file)
@@ -145,7 +145,9 @@ static void fetch_machine_sid(struct cli_state *cli)
                goto error;
        }
 
-       if ((lsapipe = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &result)) == NULL) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &lsapipe);
+       if (!NT_STATUS_IS_OK(result)) {
                fprintf(stderr, "could not initialise lsa pipe. Error was %s\n", nt_errstr(result) );
                goto error;
        }
@@ -578,9 +580,10 @@ static NTSTATUS do_cmd(struct cli_state *cli,
        if (cmd_entry->pipe_idx != -1 && cmd_entry->rpc_pipe == NULL) {
                switch (pipe_default_auth_type) {
                        case PIPE_AUTH_TYPE_NONE:
-                               cmd_entry->rpc_pipe = cli_rpc_pipe_open_noauth(cli,
-                                                               cmd_entry->pipe_idx,
-                                                               &ntresult);
+                               ntresult = cli_rpc_pipe_open_noauth(
+                                       cli,
+                                       cli_get_iface(cmd_entry->pipe_idx),
+                                       &cmd_entry->rpc_pipe);
                                break;
                        case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
                                cmd_entry->rpc_pipe = cli_rpc_pipe_open_spnego_ntlmssp(cli,
@@ -613,7 +616,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                                        pipe_default_auth_type ));
                                return NT_STATUS_UNSUCCESSFUL;
                }
-               if (!cmd_entry->rpc_pipe) {
+               if (!NT_STATUS_IS_OK(ntresult)) {
                        DEBUG(0, ("Could not initialise %s. Error was %s\n",
                                cli_get_pipe_name(cmd_entry->pipe_idx),
                                nt_errstr(ntresult) ));
index 227b2d689991064411c66f333fb4288f2c6e9f95..72a72a78b5c21137e938ce0402e329f587489bc4 100644 (file)
@@ -73,8 +73,9 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
 
        /* Shouldn't we open this with schannel ? JRA. */
 
-       netlogon_pipe = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, &nt_status);
-       if (!netlogon_pipe) {
+       nt_status = cli_rpc_pipe_open_noauth(
+               cli, &ndr_table_netlogon.syntax_id, &netlogon_pipe);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0,("modify_trust_password: unable to open the domain client session to machine %s. Error was : %s.\n", 
                        dc_name, nt_errstr(nt_status)));
                cli_shutdown(cli);
index 4d37e2bf8d55832e6f512d6d3e8180460c8cdbe7..934ac1da1ed6eb4c5a8f0190783e4a488e501595 100644 (file)
@@ -1633,8 +1633,8 @@ static int net_ads_printer_publish(struct net_context *c, int argc, const char *
        SAFE_FREE(srv_cn_escaped);
        SAFE_FREE(printername_escaped);
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SPOOLSS, &nt_status);
-       if (!pipe_hnd) {
+       nt_status = cli_rpc_pipe_open_noauth(cli, &syntax_spoolss, &pipe_hnd);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                d_fprintf(stderr, "Unable to open a connnection to the spoolss pipe on %s\n",
                         servername);
                SAFE_FREE(prt_dn);
index d777018b5d5e6d47926c9734373b80025ebd26df..783dda199824f01c20cfca293f0dbc122fe9f9c9 100644 (file)
@@ -59,8 +59,9 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx,
        NTSTATUS result = NT_STATUS_OK;
        union lsa_PolicyInformation *info = NULL;
 
-       lsa_pipe = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &result);
-       if (!lsa_pipe) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &lsa_pipe);
+       if (!NT_STATUS_IS_OK(result)) {
                d_fprintf(stderr, "Could not initialise lsa pipe\n");
                return result;
        }
@@ -173,9 +174,11 @@ int run_rpc_command(struct net_context *c,
                                                                     c->opt_password,
                                                                     &nt_status);
                        } else {
-                               pipe_hnd = cli_rpc_pipe_open_noauth(cli, pipe_idx, &nt_status);
+                               nt_status = cli_rpc_pipe_open_noauth(
+                                       cli, cli_get_iface(pipe_idx),
+                                       &pipe_hnd);
                        }
-                       if (!pipe_hnd) {
+                       if (!NT_STATUS_IS_OK(nt_status)) {
                                DEBUG(0, ("Could not initialise pipe %s. Error was %s\n",
                                        cli_get_pipe_name(pipe_idx),
                                        nt_errstr(nt_status) ));
@@ -296,8 +299,9 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
        NTSTATUS result;
        uint32 sec_channel_type;
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, &result);
-       if (!pipe_hnd) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(0,("rpc_oldjoin_internals: netlogon pipe open to machine %s failed. "
                        "error was %s\n",
                        cli->desthost,
@@ -2000,8 +2004,9 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
        POLICY_HND lsa_pol;
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &result);
-       if (!pipe_hnd) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(result)) {
                goto done;
        }
 
@@ -2813,9 +2818,10 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c,
                return NT_STATUS_OK;
        }
 
-       lsa_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(pipe_hnd),
-                                           PI_LSARPC, &result);
-       if (!lsa_pipe) {
+       result = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(pipe_hnd),
+                                         &ndr_table_lsarpc.syntax_id,
+                                         &lsa_pipe);
+       if (!NT_STATUS_IS_OK(result)) {
                d_fprintf(stderr, "Couldn't open LSA pipe. Error was %s\n",
                        nt_errstr(result) );
                return result;
@@ -5962,8 +5968,9 @@ static NTSTATUS rpc_trustdom_get_pdc(struct net_context *c,
 
        /* Try netr_GetDcName */
 
-       netr = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, &status);
-       if (!netr) {
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
+                                         &netr);
+       if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
 
@@ -6091,8 +6098,9 @@ static int rpc_trustdom_establish(struct net_context *c, int argc,
         * Call LsaOpenPolicy and LsaQueryInfo
         */
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &nt_status);
-       if (!pipe_hnd) {
+       nt_status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                            &pipe_hnd);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n", nt_errstr(nt_status) ));
                cli_shutdown(cli);
                talloc_destroy(mem_ctx);
@@ -6345,8 +6353,9 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
                return -1;
        };
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &nt_status);
-       if (!pipe_hnd) {
+       nt_status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                            &pipe_hnd);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n",
                        nt_errstr(nt_status) ));
                cli_shutdown(cli);
@@ -6501,8 +6510,9 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
                return -1;
        };
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &nt_status);
-       if (!pipe_hnd) {
+       nt_status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                            &pipe_hnd);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n",
                        nt_errstr(nt_status) ));
                cli_shutdown(cli);
@@ -6591,8 +6601,9 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
        /*
         * Open \PIPE\samr and get needed policy handles
         */
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &nt_status);
-       if (!pipe_hnd) {
+       nt_status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
+                                            &pipe_hnd);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Could not initialise samr pipe. Error was %s\n", nt_errstr(nt_status)));
                cli_shutdown(cli);
                talloc_destroy(mem_ctx);
index 5b31e6e1004782f3d91f85571176ce4c8eeac5e0..609068e3d02d2cea602c94876704a1ca730c452c 100644 (file)
@@ -199,8 +199,9 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
 
        /* Fetch domain sid */
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &result);
-       if (!pipe_hnd) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(0, ("Error connecting to LSA pipe. Error was %s\n",
                        nt_errstr(result) ));
                goto done;
@@ -231,8 +232,9 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
        }
 
        /* Create domain user */
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
-       if (!pipe_hnd) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(0, ("Error connecting to SAM pipe. Error was %s\n",
                        nt_errstr(result) ));
                goto done;
@@ -373,8 +375,9 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
 
        /* Now check the whole process from top-to-bottom */
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, &result);
-       if (!pipe_hnd) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(0,("Error connecting to NETLOGON pipe. Error was %s\n",
                        nt_errstr(result) ));
                goto done;
index dee7a9f9c7ed5e0a61e793f074c0e065b936dd45..6abdb03c48d02ac882bcd21bdedccd78542c5de0 100644 (file)
@@ -78,8 +78,10 @@ static NTSTATUS net_sh_run(struct net_context *c,
                return NT_STATUS_NO_MEMORY;
        }
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(ctx->cli, cmd->pipe_idx, &status);
-       if (pipe_hnd == NULL) {
+       status = cli_rpc_pipe_open_noauth(ctx->cli,
+                                         cli_get_iface(cmd->pipe_idx),
+                                         &pipe_hnd);
+       if (!NT_STATUS_IS_OK(status)) {
                d_fprintf(stderr, "Could not open pipe: %s\n",
                          nt_errstr(status));
                return status;
index ae1d4ea2b6968549f7e15997b77f267df0941bf7..b976c6597012963da784279c53e5b5c557e45152 100644 (file)
@@ -36,8 +36,9 @@ NTSTATUS net_rpc_lookup_name(struct net_context *c,
 
        ZERO_STRUCT(pol);
 
-       lsa_pipe = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &result);
-       if (lsa_pipe == NULL) {
+       result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &lsa_pipe);
+       if (!NT_STATUS_IS_OK(result)) {
                d_fprintf(stderr, "Could not initialise lsa pipe\n");
                return result;
        }
@@ -303,8 +304,9 @@ NTSTATUS connect_dst_pipe(struct net_context *c, struct cli_state **cli_dst,
                return nt_status;
        }
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli_tmp, pipe_num, &nt_status);
-       if (!pipe_hnd) {
+       nt_status = cli_rpc_pipe_open_noauth(cli_tmp, cli_get_iface(pipe_num),
+                                            &pipe_hnd);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("couldn't not initialize pipe\n"));
                cli_shutdown(cli_tmp);
                SAFE_FREE(server_name);
index 844db51fc068f0ef17427d067765f2a7e1ecf97b..14f2dddebcf9b9504c1550c9e72128a094440eca 100644 (file)
@@ -118,11 +118,11 @@ static struct con_struct *create_cs(struct net_context *c,
                return NULL;
        }
 
-       cs->lsapipe = cli_rpc_pipe_open_noauth(cs->cli,
-                                       PI_LSARPC,
-                                       &nt_status);
+       nt_status = cli_rpc_pipe_open_noauth(cs->cli,
+                                       &ndr_table_lsarpc.syntax_id,
+                                       &cs->lsapipe);
 
-       if (cs->lsapipe == NULL) {
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(2,("create_cs: open LSA pipe failed. Error was %s\n", nt_errstr(nt_status)));
                cs->failed_connect = true;
                cs->err = nt_status;
index 4d38793a23f10f0f82a027bbafe04b610e891702..d488ce2187ab2283dfd1a20a3f88586d7c1283c6 100644 (file)
@@ -80,8 +80,9 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli,
                return cli_nt_error(cli);
        }
 
-       p = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &status);
-       if (p == NULL) {
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &p);
+       if (!NT_STATUS_IS_OK(status)) {
                goto fail;
        }
 
@@ -127,8 +128,9 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli,
                return cli_nt_error(cli);
        }
 
-       p = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &status);
-       if (p == NULL) {
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+                                         &p);
+       if (!NT_STATUS_IS_OK(status)) {
                goto fail;
        }
 
index a73c3b49df1f27970486cbb0037c761c1bc359d3..11f8776a0e6263014839a429032e1dfb218c79e1 100644 (file)
@@ -49,8 +49,10 @@ static bool cli_open_policy_hnd(void)
        if (!cli_ipc) {
                NTSTATUS ret;
                cli_ipc = connect_one("IPC$");
-               global_pipe_hnd = cli_rpc_pipe_open_noauth(cli_ipc, PI_LSARPC, &ret);
-               if (!global_pipe_hnd) {
+               ret = cli_rpc_pipe_open_noauth(cli_ipc,
+                                              &ndr_table_lsarpc.syntax_id,
+                                              &global_pipe_hnd);
+               if (!NT_STATUS_IS_OK(ret)) {
                                return False;
                }
        }
index e975a1c8a27b63160323f2c3b77d504c268af65e..ce2de4d7fe30c2379d52f03fcc0d5d5cd007aac7 100644 (file)
@@ -163,9 +163,10 @@ static bool get_rpc_shares(struct cli_state *cli,
                return False;
        }
 
-       pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id,
+                                         &pipe_hnd);
 
-       if (pipe_hnd == NULL) {
+       if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("Could not connect to srvsvc pipe: %s\n",
                           nt_errstr(status)));
                TALLOC_FREE(mem_ctx);
index 51ef14b708bb448b65e4718c2c3e533d17dd9534..b7e2f086fc737a6662909194d1502b301b27917e 100644 (file)
@@ -1712,10 +1712,11 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
 
        DEBUG(5, ("set_dc_type_and_flags_connect: domain %s\n", domain->name ));
 
-       cli = cli_rpc_pipe_open_noauth(domain->conn.cli, PI_DSSETUP,
-                                      &result);
+       result = cli_rpc_pipe_open_noauth(domain->conn.cli,
+                                         &ndr_table_dssetup.syntax_id,
+                                         &cli);
 
-       if (cli == NULL) {
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(5, ("set_dc_type_and_flags_connect: Could not bind to "
                          "PI_DSSETUP on domain %s: (%s)\n",
                          domain->name, nt_errstr(result)));
@@ -1759,9 +1760,10 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
        }
 
 no_dssetup:
-       cli = cli_rpc_pipe_open_noauth(domain->conn.cli, PI_LSARPC, &result);
+       result = cli_rpc_pipe_open_noauth(domain->conn.cli,
+                                         &ndr_table_lsarpc.syntax_id, &cli);
 
-       if (cli == NULL) {
+       if (!NT_STATUS_IS_OK(result)) {
                DEBUG(5, ("set_dc_type_and_flags_connect: Could not bind to "
                          "PI_LSARPC on domain %s: (%s)\n",
                          domain->name, nt_errstr(result)));
@@ -2031,11 +2033,10 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
  anonymous:
 
        /* Finally fall back to anonymous. */
-       conn->samr_pipe = cli_rpc_pipe_open_noauth(conn->cli, PI_SAMR,
-                                                  &result);
+       result = cli_rpc_pipe_open_noauth(conn->cli, &ndr_table_samr.syntax_id,
+                                         &conn->samr_pipe);
 
-       if (conn->samr_pipe == NULL) {
-               result = NT_STATUS_PIPE_NOT_AVAILABLE;
+       if (!NT_STATUS_IS_OK(result)) {
                goto done;
        }
 
@@ -2167,9 +2168,10 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
 
  anonymous:
 
-       conn->lsa_pipe = cli_rpc_pipe_open_noauth(conn->cli, PI_LSARPC,
-                                                 &result);
-       if (conn->lsa_pipe == NULL) {
+       result = cli_rpc_pipe_open_noauth(conn->cli,
+                                         &ndr_table_lsarpc.syntax_id,
+                                         &conn->lsa_pipe);
+       if (!NT_STATUS_IS_OK(result)) {
                result = NT_STATUS_PIPE_NOT_AVAILABLE;
                goto done;
        }
@@ -2219,9 +2221,10 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
                return NT_STATUS_OK;
        }
 
-       netlogon_pipe = cli_rpc_pipe_open_noauth(conn->cli, PI_NETLOGON,
-                                                &result);
-       if (netlogon_pipe == NULL) {
+       result = cli_rpc_pipe_open_noauth(conn->cli,
+                                         &ndr_table_netlogon.syntax_id,
+                                         &netlogon_pipe);
+       if (!NT_STATUS_IS_OK(result)) {
                return result;
        }