#include "includes.h"
#include "librpc/gen_ndr/cli_epmapper.h"
+#include "smb_krb5.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_CLI
{ PIPE_SRVSVC, &ndr_table_srvsvc.syntax_id },
{ PIPE_WKSSVC, &ndr_table_wkssvc.syntax_id },
{ PIPE_WINREG, &ndr_table_winreg.syntax_id },
- { PIPE_SPOOLSS, &syntax_spoolss },
+ { PIPE_SPOOLSS, &ndr_table_spoolss.syntax_id },
{ PIPE_NETDFS, &ndr_table_netdfs.syntax_id },
{ PIPE_ECHO, &ndr_table_rpcecho.syntax_id },
{ PIPE_SHUTDOWN, &ndr_table_initshutdown.syntax_id },
return NT_STATUS_OK;
}
- if (auth_len != RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) {
+ if (auth_len < RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) {
DEBUG(0,("cli_pipe_verify_schannel: auth_len %u.\n", (unsigned int)auth_len ));
return NT_STATUS_INVALID_PARAMETER;
}
max_recv_frag = cli->max_recv_frag;
-#ifdef DEVELOPER
+#if 0
max_recv_frag = RPC_HEADER_LEN + 10 + (sys_random() % 32);
#endif
{
uint32 data_space, data_len;
-#ifdef DEVELOPER
+#if 0
if ((data_left > 0) && (sys_random() % 2)) {
data_left = MAX(data_left/2, 1);
}
return status;
}
+#define RPCCLI_DEFAULT_TIMEOUT 10000 /* 10 seconds. */
+
unsigned int rpccli_set_timeout(struct rpc_pipe_client *rpc_cli,
unsigned int timeout)
{
- struct cli_state *cli = rpc_pipe_np_smb_conn(rpc_cli);
+ unsigned int old;
- if (cli == NULL) {
- return 0;
+ if (rpc_cli->transport == NULL) {
+ return RPCCLI_DEFAULT_TIMEOUT;
}
- return cli_set_timeout(cli, timeout);
+
+ if (rpc_cli->transport->set_timeout == NULL) {
+ return RPCCLI_DEFAULT_TIMEOUT;
+ }
+
+ old = rpc_cli->transport->set_timeout(rpc_cli->transport->priv, timeout);
+ if (old == 0) {
+ return RPCCLI_DEFAULT_TIMEOUT;
+ }
+
+ return old;
+}
+
+bool rpccli_is_connected(struct rpc_pipe_client *rpc_cli)
+{
+ if (rpc_cli == NULL) {
+ return false;
+ }
+
+ if (rpc_cli->transport == NULL) {
+ return false;
+ }
+
+ return rpc_cli->transport->is_connected(rpc_cli->transport->priv);
}
bool rpccli_get_pwd_hash(struct rpc_pipe_client *rpc_cli, uint8_t nt_hash[16])
goto fail;
}
- status = open_socket_out(&addr, port, 60, &fd);
+ status = open_socket_out(&addr, port, 60*1000, &fd);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
goto fail;
}
+ result->transport->transport = NCACN_IP_TCP;
+
*presult = result;
return NT_STATUS_OK;
goto fail;
}
+ result->transport->transport = NCALRPC;
+
*presult = result;
return NT_STATUS_OK;
return status;
}
-static int rpc_pipe_client_np_destructor(struct rpc_pipe_client *p)
-{
+struct rpc_pipe_client_np_ref {
struct cli_state *cli;
+ struct rpc_pipe_client *pipe;
+};
- cli = rpc_pipe_np_smb_conn(p);
- if (cli != NULL) {
- DLIST_REMOVE(cli->pipe_list, p);
- }
+static int rpc_pipe_client_np_ref_destructor(struct rpc_pipe_client_np_ref *np_ref)
+{
+ DLIST_REMOVE(np_ref->cli->pipe_list, np_ref->pipe);
return 0;
}
{
struct rpc_pipe_client *result;
NTSTATUS status;
+ struct rpc_pipe_client_np_ref *np_ref;
/* sanity check to protect against crashes */
return status;
}
- DLIST_ADD(cli->pipe_list, result);
- talloc_set_destructor(result, rpc_pipe_client_np_destructor);
+ result->transport->transport = NCACN_NP;
+
+ np_ref = talloc(result->transport, struct rpc_pipe_client_np_ref);
+ if (np_ref == NULL) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+ np_ref->cli = cli;
+ np_ref->pipe = result;
+
+ DLIST_ADD(np_ref->cli->pipe_list, np_ref->pipe);
+ talloc_set_destructor(np_ref, rpc_pipe_client_np_ref_destructor);
*presult = result;
return NT_STATUS_OK;
return status;
}
+ result->transport->transport = NCACN_INTERNAL;
+
*presult = result;
return NT_STATUS_OK;
}
****************************************************************************/
static NTSTATUS cli_rpc_pipe_open(struct cli_state *cli,
+ enum dcerpc_transport_t transport,
const struct ndr_syntax_id *interface,
struct rpc_pipe_client **presult)
{
- if (ndr_syntax_id_equal(interface, &ndr_table_drsuapi.syntax_id)) {
- /*
- * We should have a better way to figure out this drsuapi
- * speciality...
- */
+ switch (transport) {
+ case NCACN_IP_TCP:
return rpc_pipe_open_tcp(NULL, cli->desthost, interface,
presult);
+ case NCACN_NP:
+ return rpc_pipe_open_np(cli, interface, presult);
+ default:
+ return NT_STATUS_NOT_IMPLEMENTED;
}
-
- return rpc_pipe_open_np(cli, interface, presult);
}
/****************************************************************************
Open a named pipe to an SMB server and bind anonymously.
****************************************************************************/
-NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
- const struct ndr_syntax_id *interface,
- struct rpc_pipe_client **presult)
+NTSTATUS cli_rpc_pipe_open_noauth_transport(struct cli_state *cli,
+ enum dcerpc_transport_t transport,
+ const struct ndr_syntax_id *interface,
+ struct rpc_pipe_client **presult)
{
struct rpc_pipe_client *result;
struct cli_pipe_auth_data *auth;
NTSTATUS status;
- status = cli_rpc_pipe_open(cli, interface, &result);
+ status = cli_rpc_pipe_open(cli, transport, interface, &result);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
return NT_STATUS_OK;
}
+/****************************************************************************
+ ****************************************************************************/
+
+NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
+ const struct ndr_syntax_id *interface,
+ struct rpc_pipe_client **presult)
+{
+ return cli_rpc_pipe_open_noauth_transport(cli, NCACN_NP,
+ interface, presult);
+}
+
/****************************************************************************
Open a named pipe to an SMB server and bind using NTLMSSP or SPNEGO NTLMSSP
****************************************************************************/
static NTSTATUS cli_rpc_pipe_open_ntlmssp_internal(struct cli_state *cli,
const struct ndr_syntax_id *interface,
+ enum dcerpc_transport_t transport,
enum pipe_auth_type auth_type,
enum pipe_auth_level auth_level,
const char *domain,
struct cli_pipe_auth_data *auth;
NTSTATUS status;
- status = cli_rpc_pipe_open(cli, interface, &result);
+ status = cli_rpc_pipe_open(cli, transport, interface, &result);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
NTSTATUS cli_rpc_pipe_open_ntlmssp(struct cli_state *cli,
const struct ndr_syntax_id *interface,
+ enum dcerpc_transport_t transport,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
{
return cli_rpc_pipe_open_ntlmssp_internal(cli,
interface,
+ transport,
PIPE_AUTH_TYPE_NTLMSSP,
auth_level,
domain,
NTSTATUS cli_rpc_pipe_open_spnego_ntlmssp(struct cli_state *cli,
const struct ndr_syntax_id *interface,
+ enum dcerpc_transport_t transport,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
{
return cli_rpc_pipe_open_ntlmssp_internal(cli,
interface,
+ transport,
PIPE_AUTH_TYPE_SPNEGO_NTLMSSP,
auth_level,
domain,
NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
const struct ndr_syntax_id *interface,
+ enum dcerpc_transport_t transport,
enum pipe_auth_level auth_level,
const char *domain,
const struct dcinfo *pdc,
struct cli_pipe_auth_data *auth;
NTSTATUS status;
- status = cli_rpc_pipe_open(cli, interface, &result);
+ status = cli_rpc_pipe_open(cli, transport, interface, &result);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
NTSTATUS status;
status = cli_rpc_pipe_open_spnego_ntlmssp(
- cli, &ndr_table_netlogon.syntax_id, PIPE_AUTH_LEVEL_PRIVACY,
+ cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
+ PIPE_AUTH_LEVEL_PRIVACY,
domain, username, password, &netlogon_pipe);
if (!NT_STATUS_IS_OK(status)) {
return status;
NTSTATUS cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state *cli,
const struct ndr_syntax_id *interface,
+ enum dcerpc_transport_t transport,
enum pipe_auth_level auth_level,
const char *domain,
const char *username,
}
status = cli_rpc_pipe_open_schannel_with_key(
- cli, interface, auth_level, domain, netlogon_pipe->dc,
+ cli, interface, transport, auth_level, domain, netlogon_pipe->dc,
&result);
/* Now we've bound using the session key we can close the netlog pipe. */
NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
const struct ndr_syntax_id *interface,
+ enum dcerpc_transport_t transport,
enum pipe_auth_level auth_level,
const char *domain,
struct rpc_pipe_client **presult)
struct rpc_pipe_client *result = NULL;
NTSTATUS status;
+ *presult = NULL;
+
status = get_schannel_session_key(cli, domain, &neg_flags,
&netlogon_pipe);
if (!NT_STATUS_IS_OK(status)) {
}
status = cli_rpc_pipe_open_schannel_with_key(
- cli, interface, auth_level, domain, netlogon_pipe->dc,
+ cli, interface, transport, auth_level, domain, netlogon_pipe->dc,
&result);
/* Now we've bound using the session key we can close the netlog pipe. */
*presult = result;
}
- return NT_STATUS_OK;
+ return status;
}
/****************************************************************************
struct cli_pipe_auth_data *auth;
NTSTATUS status;
- status = cli_rpc_pipe_open(cli, interface, &result);
+ status = cli_rpc_pipe_open(cli, NCACN_NP, interface, &result);
if (!NT_STATUS_IS_OK(status)) {
return status;
}