summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2000-07-15 08:37:17 +0000
committerGerald Carter <jerry@samba.org>2000-07-15 08:37:17 +0000
commit333c23c74acf0495fca6d4f4bdfc944ce320398e (patch)
treea14945f657f738935b4efd97edba907109896112 /source3
parent2755ad8814f07906cddd303bed6a5a1971a2c3ff (diff)
downloadsamba-333c23c74acf0495fca6d4f4bdfc944ce320398e.tar.gz
samba-333c23c74acf0495fca6d4f4bdfc944ce320398e.tar.bz2
samba-333c23c74acf0495fca6d4f4bdfc944ce320398e.zip
Lots of changes but no real progress in functionality.
more changes to remove the ncarpc_l_* stuff. Fixed some cut and paste errors from TNG There are very subtle bugs in this code. I'll work on simplifying them in round two or three. --jerry (This used to be commit f8509356178deb7e78836d1f5aceb96677ac738b)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_client/cli_connect.c206
-rw-r--r--source3/rpc_client/cli_use.c1
-rw-r--r--source3/rpc_client/ncacn_np_use.c31
3 files changed, 92 insertions, 146 deletions
diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c
index 1a20e2f75c..e34968987e 100644
--- a/source3/rpc_client/cli_connect.c
+++ b/source3/rpc_client/cli_connect.c
@@ -26,32 +26,18 @@
#include "rpc_parse.h"
#include "rpc_client.h"
-/*
- * 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
{
- uint32 num_connections;
- char *srv_name;
- char *pipe_name;
- struct user_creds usr_creds;
+ uint32 num_connections;
+ char *srv_name;
+ char *pipe_name;
+ struct user_creds usr_creds;
- int type;
+ struct cli_state *pCli_state;
- union
- {
- struct ncacn_np *smb;
- struct msrpc_local *local;
- void *cli;
- } msrpc;
-
- cli_auth_fns *auth;
- void *auth_info;
- void *auth_creds;
+ cli_auth_fns *auth;
+ void *auth_info;
+ void *auth_creds;
};
static struct cli_connection **con_list = NULL;
@@ -118,17 +104,17 @@ static struct cli_connection *cli_con_get(const char *srv_name,
BOOL is_new_connection = False;
CREDS_NT usr;
struct ntuser_creds *ntc = NULL;
- vuser_key key;
+ struct ncacn_np *pNcacn;
+ /*
+ * initialization stuff
+ */
con = (struct cli_connection *)malloc(sizeof(*con));
-
if (con == NULL)
{
return NULL;
}
-
memset(con, 0, sizeof(*con));
- con->type = MSRPC_NONE;
copy_user_creds(&con->usr_creds, NULL);
con->usr_creds.reuse = reuse;
@@ -141,76 +127,65 @@ static struct cli_connection *cli_con_get(const char *srv_name,
{
con->pipe_name = strdup(pipe_name);
}
-
- /* setup a network RPC connection */
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,
+
+ /* fix me XXXX **WHAT** a hack. The cli_state* is malloc'd
+ deep within the call stack, so we can grab that pointer.
+ ncacn_np* is stored in an array which is currently handled
+ by underlying systems. --jerry */
+ pNcacn = ncacn_np_use_add(pipe_name, user_key, srv_name,
ntc, reuse,
&is_new_connection);
+ con->pCli_state = pNcacn->smb;
- if (con->msrpc.smb == NULL)
+ if (con->pCli_state == 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 );
+ con->pCli_state->key.pid = 0;
+ con->pCli_state->key.vuid = UID_FIELD_INVALID;
+ create_ntc_from_cli_state ( &usr, con->pCli_state );
copy_nt_creds(&con->usr_creds.ntc, &usr);
- if (con->msrpc.cli != NULL)
+ if (is_new_connection)
{
- if (is_new_connection)
- {
- con->auth_info = NULL;
- con->auth_creds = auth_creds;
-
- if (auth != NULL)
- {
- con->auth = auth;
- }
- else
- {
- con->auth = &cli_noauth_fns;
- }
+ con->auth_info = NULL;
+ con->auth_creds = auth_creds;
- if (!rpc_pipe_bind(con->msrpc.smb->smb, pipe_name, global_myname))
- {
- DEBUG(0, ("rpc_pipe_bind failed\n"));
- cli_connection_free(con);
- return NULL;
- }
+ if (auth != NULL)
+ {
+ con->auth = auth;
}
else
{
- con->auth_info = cli_conn_get_auth_creds(con);
- con->auth = cli_conn_get_authfns(con);
- if (con->auth_info != NULL)
- {
- DEBUG(1,("cli_con_get: TODO: auth reuse\n"));
- cli_connection_free(con);
- return NULL;
- }
- else
- {
- con->auth = &cli_noauth_fns;
- }
+ con->auth = &cli_noauth_fns;
}
- }
- if (con->msrpc.cli == NULL)
+ if (!rpc_pipe_bind(con->pCli_state, pipe_name, global_myname))
+ {
+ DEBUG(0, ("rpc_pipe_bind failed\n"));
+ cli_connection_free(con);
+ return NULL;
+ }
+ }
+ else
{
- cli_connection_free(con);
- return NULL;
+ con->auth_info = cli_conn_get_auth_creds(con);
+ con->auth = cli_conn_get_authfns(con);
+ if (con->auth_info != NULL)
+ {
+ DEBUG(1,("cli_con_get: TODO: auth reuse\n"));
+ cli_connection_free(con);
+ return NULL;
+ }
+ else
+ {
+ con->auth = &cli_noauth_fns;
+ }
}
- if (con->type == MSRPC_SMB)
- {
- con->msrpc.smb->smb->key = key;
- }
add_con_to_array(&num_cons, &con_list, con);
return con;
}
@@ -222,29 +197,18 @@ terminate client connection
void cli_connection_free(struct cli_connection *con)
{
BOOL closed = False;
- void *oldcli = NULL;
+ struct cli_state *oldcli = NULL;
int i;
DEBUG(10, ("cli_connection_free: %d\n", __LINE__));
- if (con->msrpc.cli != NULL)
+ if (con->pCli_state != NULL)
{
- /* only currently support type == MSRPC_SMB so this is a little
- redundant --jerry */
- switch (con->type)
- {
- case MSRPC_SMB:
- {
- DEBUG(10, ("msrpc smb connection\n"));
- ncacn_np_use_del(con->srv_name,
- con->pipe_name,
- &con->msrpc.smb->smb->key,
- False, &closed);
- oldcli = con->msrpc.local;
- con->msrpc.smb = NULL;
- break;
- }
- }
+ DEBUG(10, ("msrpc smb connection\n"));
+ ncacn_np_use_del(con->srv_name, con->pipe_name,
+ &con->pCli_state->key, False, &closed);
+ oldcli = con->pCli_state;
+ con->pCli_state = NULL;
}
DEBUG(10, ("cli_connection_free: closed: %s\n", BOOLSTR(closed)));
@@ -254,35 +218,26 @@ void cli_connection_free(struct cli_connection *con)
for (i = 0; i < num_cons; i++)
{
struct cli_connection *c = con_list[i];
- if (c != NULL && con != c && c->msrpc.cli == oldcli)
+ if (c != NULL && con != c && c->pCli_state == oldcli)
{
/* WHOOPS! fnum already open: too bad!!!
get rid of all other connections that
were using that connection
*/
- switch (c->type)
- {
- case MSRPC_LOCAL:
- {
- c->msrpc.local = NULL;
- break;
- }
- case MSRPC_SMB:
- {
- c->msrpc.smb = NULL;
- break;
- }
- }
+ c->pCli_state = NULL;
}
}
}
- if (con->msrpc.cli != NULL)
- {
- free(con->msrpc.cli);
- }
- con->msrpc.cli = NULL;
-
+ /* don't free the cli_state since it is being handled
+ by the *clis list in rpc_client/cli_use.c.
+ This code needs to be fixed badly. It is **way**
+ to complicated. --jerry */
+ /* if (oldcli != NULL)
+ {
+ free(oldcli);
+ } */
+
if (con->srv_name != NULL)
{
free(con->srv_name);
@@ -408,7 +363,7 @@ BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
/* 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);
+ ret = rpc_api_pipe_req(con->pCli_state, op_num, data, rdata);
prs_dump("out_rpcclient", (int)op_num, rdata);
return ret;
}
@@ -419,23 +374,14 @@ BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
*****************************************************************************/
BOOL rpc_con_ok(struct cli_connection *con)
{
- if (!con) return False;
+ 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;
+ if (!con->pCli_state)
+ return False;
+ if (con->pCli_state->fd == -1)
+ return False;
- case MSRPC_LOCAL:
- return True;
- }
- return False;
+ return True;
}
diff --git a/source3/rpc_client/cli_use.c b/source3/rpc_client/cli_use.c
index 43f8ec8717..7cc4477b57 100644
--- a/source3/rpc_client/cli_use.c
+++ b/source3/rpc_client/cli_use.c
@@ -48,6 +48,7 @@ static void cli_use_free(struct cli_use *cli)
{
if (cli->cli->initialised)
{
+ /* only logoff if we have a valid socket */
if (cli->cli->fd != -1)
cli_ulogoff(cli->cli);
cli_shutdown(cli->cli);
diff --git a/source3/rpc_client/ncacn_np_use.c b/source3/rpc_client/ncacn_np_use.c
index 0ab2802cc1..8e5c724046 100644
--- a/source3/rpc_client/ncacn_np_use.c
+++ b/source3/rpc_client/ncacn_np_use.c
@@ -20,14 +20,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/*************************************************************
- Ever wonder where Luke comes up with some of these names?
-
- (N)etwork (C)omputing (A)rchitechture ???
-
- get it? --jerry
-*************************************************************/
-
#define NO_SYSLOG
@@ -53,6 +45,9 @@ terminate client connection
****************************************************************************/
static void ncacn_np_shutdown(struct ncacn_np *cli)
{
+ struct ntuser_creds usr;
+ BOOL closed;
+
if (cli != NULL)
{
if (cli->smb != NULL)
@@ -62,10 +57,8 @@ static void ncacn_np_shutdown(struct ncacn_np *cli)
/* cli_nt_session_close(cli->smb, cli->fnum); JERRY */
cli_nt_session_close(cli->smb);
}
-#if 0 /* commented out by JERRY */
- cli_net_use_del(cli->smb->desthost,
- &cli->smb->usr, False, False);
-#endif
+ create_ntc_from_cli_state(&usr, cli->smb);
+ cli_net_use_del(cli->smb->desthost, &usr, False, &closed);
}
}
}
@@ -121,11 +114,17 @@ static struct ncacn_np_use *add_ncacn_np_to_array(uint32 * len,
***array,
struct ncacn_np_use *cli)
{
+
int i;
+
+ /* traverse the list and try to find a previously
+ allocate spot that is not being used */
for (i = 0; i < num_msrpcs; i++)
{
if (msrpcs[i] == NULL)
{
+ /* found and empty spot to
+ store the cli pointer */
msrpcs[i] = cli;
return cli;
}
@@ -167,7 +166,7 @@ BOOL ncacn_np_use_del(const char *srv_name, const char *pipe_name,
if (strnequal("\\\\", srv_name, 2))
{
- srv_name = &srv_name[6];
+ srv_name = &srv_name[2];
}
for (i = 0; i < num_msrpcs; i++)
@@ -194,15 +193,15 @@ BOOL ncacn_np_use_del(const char *srv_name, const char *pipe_name,
{
ncacn_np_name = &ncacn_np_name[6];
}
- if (!strequal(ncacn_np_srv_name, srv_name))
+ if (!strequal(ncacn_np_name, pipe_name))
{
continue;
}
if (strnequal("\\\\", ncacn_np_srv_name, 2))
{
- ncacn_np_srv_name = &ncacn_np_srv_name[6];
+ ncacn_np_srv_name = &ncacn_np_srv_name[2];
}
- if (!strequal(ncacn_np_name, pipe_name))
+ if (!strequal(ncacn_np_srv_name, srv_name))
{
continue;
}