diff options
author | Gerald Carter <jerry@samba.org> | 2000-07-14 16:59:41 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2000-07-14 16:59:41 +0000 |
commit | c27ec4bfa04a8cc12fe50dea432a7cf892c35c07 (patch) | |
tree | 6415ea4ecede0987f9be9657ee097ee9557b10b5 /source3/rpc_client | |
parent | 2c46a26a8bbc4130a6dc195a77b760d26016d5a1 (diff) | |
download | samba-c27ec4bfa04a8cc12fe50dea432a7cf892c35c07.tar.gz samba-c27ec4bfa04a8cc12fe50dea432a7cf892c35c07.tar.xz samba-c27ec4bfa04a8cc12fe50dea432a7cf892c35c07.zip |
removed references to loopback RPC connections.
added a few more kfunctions from TNG for rpcclient
--jerry
(This used to be commit 549d1d262115aeb2cd4d3f0122a5771be17752bb)
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_connect.c | 125 |
1 files changed, 80 insertions, 45 deletions
diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c index 6f098d74ae..1a20e2f75c 100644 --- a/source3/rpc_client/cli_connect.c +++ b/source3/rpc_client/cli_connect.c @@ -26,8 +26,12 @@ #include "rpc_parse.h" #include "rpc_client.h" -enum -{ MSRPC_NONE, MSRPC_LOCAL, MSRPC_SMB }; +/* + * MSRPC_NONE: no connection + * MSRPC_LOCAL: local loopback over a UNIX domain socket (not supported) + * MSRPC_SMB: network rpc connection + */ +enum { MSRPC_NONE, MSRPC_LOCAL, MSRPC_SMB }; struct cli_connection { @@ -113,7 +117,7 @@ static struct cli_connection *cli_con_get(const char *srv_name, struct cli_connection *con = NULL; BOOL is_new_connection = False; CREDS_NT usr; - + struct ntuser_creds *ntc = NULL; vuser_key key; con = (struct cli_connection *)malloc(sizeof(*con)); @@ -138,39 +142,24 @@ static struct cli_connection *cli_con_get(const char *srv_name, con->pipe_name = strdup(pipe_name); } -#if 0 /* commented out by JERRY */ - if (strequal(srv_name, "\\\\.")) - { - con->type = MSRPC_LOCAL; - become_root(False); - con->msrpc.local = ncalrpc_l_use_add(pipe_name, user_key, - reuse, - &is_new_connection); - unbecome_root(False); - } - else -#endif /* commented of by JERRY */ + /* setup a network RPC connection */ + if (usr_creds != NULL) { - struct ntuser_creds *ntc = NULL; - if (usr_creds != NULL) - { - ntc = &usr_creds->ntc; - } - con->type = MSRPC_SMB; - con->msrpc.smb = - ncacn_np_use_add(pipe_name, user_key, srv_name, - ntc, reuse, - &is_new_connection); - - if (con->msrpc.smb == NULL) - return NULL; - - key = con->msrpc.smb->smb->key; - con->msrpc.smb->smb->key.pid = 0; - con->msrpc.smb->smb->key.vuid = UID_FIELD_INVALID; - create_ntc_from_cli_state ( &usr, con->msrpc.smb->smb ); - copy_nt_creds(&con->usr_creds.ntc, &usr); + ntc = &usr_creds->ntc; } + con->type = MSRPC_SMB; + con->msrpc.smb = ncacn_np_use_add(pipe_name, user_key, srv_name, + ntc, reuse, + &is_new_connection); + + if (con->msrpc.smb == NULL) + return NULL; + + key = con->msrpc.smb->smb->key; + con->msrpc.smb->smb->key.pid = 0; + con->msrpc.smb->smb->key.vuid = UID_FIELD_INVALID; + create_ntc_from_cli_state ( &usr, con->msrpc.smb->smb ); + copy_nt_creds(&con->usr_creds.ntc, &usr); if (con->msrpc.cli != NULL) { @@ -240,18 +229,10 @@ void cli_connection_free(struct cli_connection *con) if (con->msrpc.cli != NULL) { + /* only currently support type == MSRPC_SMB so this is a little + redundant --jerry */ switch (con->type) { - case MSRPC_LOCAL: - { - DEBUG(10, ("msrpc local connection\n")); - ncalrpc_l_use_del(con->pipe_name, - &con->msrpc.local->nt.key, - False, &closed); - oldcli = con->msrpc.local; - con->msrpc.local = NULL; - break; - } case MSRPC_SMB: { DEBUG(10, ("msrpc smb connection\n")); @@ -388,6 +369,31 @@ void *cli_conn_get_auth_creds(struct cli_connection *con) return con != NULL ? con->auth_creds : NULL; } + +/**************************************************************************** + send a request on an rpc pipe. + ****************************************************************************/ +BOOL rpc_hnd_pipe_req(const POLICY_HND * hnd, uint8 op_num, + prs_struct * data, prs_struct * rdata) +{ + struct cli_connection *con = NULL; + +#if 0 /* temporary disable by JERRY */ + /* we need this to locate the cli_connection associated + with the POLICY_HND */ + if (!cli_connection_get(hnd, &con)) + { + return False; + } +#endif /* temporary disable by JERRY */ + + /* always will return False until I fix cli_connection_get() + --jerry */ + if (!rpc_con_ok(con)) return False; + + return rpc_con_pipe_req(con, op_num, data, rdata); +} + /**************************************************************************** send a request on an rpc pipe. ****************************************************************************/ @@ -398,9 +404,38 @@ BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num, DEBUG(10, ("rpc_con_pipe_req: op_num %d offset %d used: %d\n", op_num, data->data_offset, data->buffer_size)); prs_dump("in_rpcclient", (int)op_num, data); - prs_realloc_data(data, data->data_offset); + + /* Why does this use prs->data_offset? --jerry */ + /* prs_realloc_data(data, data->data_offset); */ + ret = rpc_api_pipe_req(con->msrpc.smb->smb, op_num, data, rdata); prs_dump("out_rpcclient", (int)op_num, rdata); return ret; } +/**************************************************************************** + this allows us to detect dead servers. The cli->fd is set to -1 when + we get an error +*****************************************************************************/ +BOOL rpc_con_ok(struct cli_connection *con) +{ + if (!con) return False; + + switch (con->type) + { + case MSRPC_SMB: + { + struct cli_state *cli; + if (!con->msrpc.smb) return False; + cli = con->msrpc.smb->smb; + if (cli->fd == -1) return False; + return True; + } + break; + + case MSRPC_LOCAL: + return True; + } + return False; +} + |