summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in1
-rw-r--r--source3/include/proto.h52
-rw-r--r--source3/lib/domain_namemap.c17
-rw-r--r--source3/lib/util_hnd.c24
-rw-r--r--source3/libsmb/clientgen.c7
-rw-r--r--source3/rpc_client/cli_lsarpc.c155
-rw-r--r--source3/rpc_client/cli_pipe.c13
-rw-r--r--source3/rpc_client/msrpc_lsarpc.c30
-rw-r--r--source3/rpc_client/msrpc_samr.c14
-rw-r--r--source3/rpc_server/srv_lsa_hnd.c24
-rw-r--r--source3/rpcclient/cmd_lsarpc.c76
-rw-r--r--source3/rpcclient/cmd_samr.c14
-rw-r--r--source3/rpcclient/rpcclient.c3
-rw-r--r--source3/utils/rpctorture.c14
14 files changed, 230 insertions, 214 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 1f481f6599..ce0f7471e2 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -159,6 +159,7 @@ RPC_CLIENT_OBJ = \
rpc_client/cli_netlogon_sync.o \
rpc_client/cli_reg.o \
rpc_client/cli_pipe.o \
+ rpc_client/cli_connect.o \
rpc_client/cli_spoolss.o \
rpc_client/cli_lsarpc.o \
rpc_client/cli_wkssvc.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index be4183b4fc..580ab22f96 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -529,8 +529,9 @@ void *open_file_if_modified(const char *filename, char *mode, time_t *lastmodifi
/*The following definitions come from lib/util_hnd.c */
BOOL init_policy_hnd(int num_pol_hnds);
+BOOL register_policy_hnd(POLICY_HND *hnd);
BOOL open_policy_hnd(POLICY_HND *hnd);
-int find_policy_by_hnd(POLICY_HND *hnd);
+int find_policy_by_hnd(const POLICY_HND *hnd);
BOOL set_policy_samr_rid(POLICY_HND *hnd, uint32 rid);
BOOL set_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status);
BOOL set_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid);
@@ -540,7 +541,8 @@ BOOL set_policy_reg_name(POLICY_HND *hnd, fstring name);
BOOL get_policy_reg_name(POLICY_HND *hnd, fstring name);
BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum,
void (*free_fn)(struct cli_state *, uint16));
-BOOL get_policy_cli_state(POLICY_HND *hnd, struct cli_state **cli, uint16 *fnum);
+BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli,
+ uint16 *fnum);
BOOL close_policy_hnd(POLICY_HND *hnd);
/*The following definitions come from lib/util_pwdb.c */
@@ -710,8 +712,9 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
BOOL cli_unlink(struct cli_state *cli, char *fname);
BOOL cli_mkdir(struct cli_state *cli, char *dname);
BOOL cli_rmdir(struct cli_state *cli, char *dname);
-int cli_nt_create(struct cli_state *cli, char *fname);
-int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode);
+int cli_nt_create(struct cli_state *cli, const char *fname);
+int cli_open(struct cli_state *cli, const char *fname,
+ int flags, int share_mode);
BOOL cli_close(struct cli_state *cli, int fnum);
BOOL cli_lock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
@@ -1779,6 +1782,16 @@ BOOL do_brs_query_info(struct cli_state *cli, uint16 fnum,
const char *server_name, uint32 switch_value,
void *id);
+/*The following definitions come from rpc_client/cli_connect.c */
+
+void cli_state_free(struct cli_state *cli, uint16 fnum);
+BOOL cli_state_init(const char* server_name, const char* pipe_name,
+ struct cli_state **cli,
+ uint16 *fnum);
+BOOL cli_state_get(const POLICY_HND *pol,
+ struct cli_state **cli,
+ uint16 *fnum);
+
/*The following definitions come from rpc_client/cli_eventlog.c */
BOOL do_event_open(struct cli_state *cli, uint16 fnum, char *log, POLICY_HND *hnd);
@@ -1813,42 +1826,34 @@ BOOL get_domain_sids(const char *myname,
BOOL get_trust_sid_and_domain(const char* myname, char *server,
DOM_SID *sid,
char *domain, size_t len);
-BOOL lsa_open_policy(struct cli_state *cli, uint16 fnum,
- const char *server_name, POLICY_HND *hnd,
+BOOL lsa_open_policy(const char *server_name, POLICY_HND *hnd,
BOOL sec_qos);
-BOOL lsa_open_policy2(struct cli_state *cli, uint16 fnum,
- const char *server_name, POLICY_HND *hnd,
+BOOL lsa_open_policy2( const char *server_name, POLICY_HND *hnd,
BOOL sec_qos);
-BOOL lsa_open_secret(struct cli_state *cli, uint16 fnum,
- const POLICY_HND *hnd_pol,
+BOOL lsa_open_secret( const POLICY_HND *hnd,
const char *secret_name,
uint32 des_access,
POLICY_HND *hnd_secret);
-BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, STRING2 *enc_secret,
+BOOL lsa_query_secret(POLICY_HND *hnd, STRING2 *secret,
NTTIME *last_update);
-BOOL lsa_lookup_names(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd,
+BOOL lsa_lookup_names( POLICY_HND *hnd,
int num_names,
char **names,
DOM_SID **sids,
uint8 **types,
int *num_sids);
-BOOL lsa_lookup_sids(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd,
+BOOL lsa_lookup_sids(POLICY_HND *hnd,
int num_sids,
DOM_SID **sids,
char ***names,
uint8 **types,
int *num_names);
-BOOL lsa_query_info_pol(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd, uint16 info_class,
+BOOL lsa_query_info_pol(POLICY_HND *hnd, uint16 info_class,
fstring domain_name, DOM_SID *domain_sid);
-BOOL lsa_enum_trust_dom(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd, uint32 *enum_ctx,
+BOOL lsa_enum_trust_dom(POLICY_HND *hnd, uint32 *enum_ctx,
uint32 *num_doms, char ***names,
DOM_SID ***sids);
-BOOL lsa_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd);
+BOOL lsa_close(POLICY_HND *hnd);
/*The following definitions come from rpc_client/cli_netlogon.c */
@@ -1894,7 +1899,8 @@ BOOL create_rpc_bind_resp(struct pwd_info *pwd,
BOOL rpc_api_pipe_req(struct cli_state *cli, uint16 fnum, uint8 op_num,
prs_struct *data, prs_struct *rdata);
void cli_nt_set_ntlmssp_flgs(struct cli_state *cli, uint32 ntlmssp_flgs);
-BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, uint16* fnum);
+BOOL cli_nt_session_open(struct cli_state *cli, const char *pipe_name,
+ uint16* fnum);
void cli_nt_session_close(struct cli_state *cli, uint16 fnum);
/*The following definitions come from rpc_client/cli_reg.c */
@@ -2174,7 +2180,7 @@ BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
/*The following definitions come from rpc_client/msrpc_lsarpc.c */
-BOOL msrpc_lsa_query_secret(struct cli_state *cli,
+BOOL msrpc_lsa_query_secret(const char* srv_name,
const char* secret_name,
STRING2 *secret,
NTTIME *last_update);
diff --git a/source3/lib/domain_namemap.c b/source3/lib/domain_namemap.c
index 05b67632a2..51fcd2467a 100644
--- a/source3/lib/domain_namemap.c
+++ b/source3/lib/domain_namemap.c
@@ -881,8 +881,8 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
{
struct cli_state cli;
POLICY_HND lsa_pol;
- uint16 fnum_lsa;
fstring srv_name;
+ extern struct cli_state *rpc_smb_cli;
BOOL res3 = True;
BOOL res4 = True;
@@ -891,6 +891,8 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
uint8 *types;
char *names[1];
+ rpc_smb_cli = &cli;
+
DEBUG(5,("lookup_remote_ntname: %s\n", ntname));
if (!cli_connect_serverlist(&cli, lp_passwordserver()))
@@ -904,23 +906,16 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
fstrcat(srv_name, cli.desthost);
strupper(srv_name);
- /* open LSARPC session. */
- res3 = res3 ? cli_nt_session_open(&cli, PIPE_LSARPC, &fnum_lsa) : False;
-
/* lookup domain controller; receive a policy handle */
- res3 = res3 ? lsa_open_policy(&cli, fnum_lsa,
- srv_name,
+ res3 = res3 ? lsa_open_policy( srv_name,
&lsa_pol, True) : False;
/* send lsa lookup sids call */
- res4 = res3 ? lsa_lookup_names(&cli, fnum_lsa,
- &lsa_pol,
+ res4 = res3 ? lsa_lookup_names( &lsa_pol,
1, names,
&sids, &types, &num_sids) : False;
- res3 = res3 ? lsa_close(&cli, fnum_lsa, &lsa_pol) : False;
-
- cli_nt_session_close(&cli, fnum_lsa);
+ res3 = res3 ? lsa_close(&lsa_pol) : False;
if (res4 && res3 && sids != NULL && types != NULL)
{
diff --git a/source3/lib/util_hnd.c b/source3/lib/util_hnd.c
index 36bacad59b..8e4620f8dc 100644
--- a/source3/lib/util_hnd.c
+++ b/source3/lib/util_hnd.c
@@ -111,7 +111,7 @@ BOOL init_policy_hnd(int num_pol_hnds)
/****************************************************************************
find first available policy slot. creates a policy handle for you.
****************************************************************************/
-BOOL open_policy_hnd(POLICY_HND *hnd)
+BOOL register_policy_hnd(POLICY_HND *hnd)
{
int i;
struct policy *p;
@@ -135,7 +135,6 @@ BOOL open_policy_hnd(POLICY_HND *hnd)
p->pnum = i;
p->type = POL_NO_INFO;
- create_pol_hnd(hnd);
memcpy(&p->pol_hnd, hnd, sizeof(*hnd));
bitmap_set(bmap, i);
@@ -149,22 +148,32 @@ BOOL open_policy_hnd(POLICY_HND *hnd)
}
/****************************************************************************
+ find first available policy slot. creates a policy handle for you.
+****************************************************************************/
+BOOL open_policy_hnd(POLICY_HND *hnd)
+{
+ create_pol_hnd(hnd);
+ return register_policy_hnd(hnd);
+}
+
+/****************************************************************************
find policy by handle
****************************************************************************/
-static struct policy *find_policy(POLICY_HND *hnd)
+static struct policy *find_policy(const POLICY_HND *hnd)
{
struct policy *p;
for (p=Policy;p;p=p->next) {
if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%x] ", p->pnum));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (const char *)hnd->data,
+ sizeof(hnd->data));
return p;
}
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (const char *)hnd->data, sizeof(hnd->data));
return NULL;
}
@@ -172,7 +181,7 @@ static struct policy *find_policy(POLICY_HND *hnd)
/****************************************************************************
find policy index by handle
****************************************************************************/
-int find_policy_by_hnd(POLICY_HND *hnd)
+int find_policy_by_hnd(const POLICY_HND *hnd)
{
struct policy *p = find_policy(hnd);
@@ -393,7 +402,8 @@ BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum,
/****************************************************************************
get cli state
****************************************************************************/
-BOOL get_policy_cli_state(POLICY_HND *hnd, struct cli_state **cli, uint16 *fnum)
+BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli,
+ uint16 *fnum)
{
struct policy *p = find_policy(hnd);
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 26a5f25c7d..61ce3f9900 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -25,7 +25,6 @@
#include "includes.h"
#include "trans2.h"
-
extern int DEBUGLEVEL;
/*
@@ -1331,7 +1330,7 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname)
/****************************************************************************
open a file
****************************************************************************/
-int cli_nt_create(struct cli_state *cli, char *fname)
+int cli_nt_create(struct cli_state *cli, const char *fname)
{
char *p;
@@ -1375,7 +1374,8 @@ int cli_nt_create(struct cli_state *cli, char *fname)
/****************************************************************************
open a file
****************************************************************************/
-int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode)
+int cli_open(struct cli_state *cli, const char *fname,
+ int flags, int share_mode)
{
char *p;
unsigned openfn=0;
@@ -3684,3 +3684,4 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
return True;
}
+
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index d49ba09e4d..26b17243cd 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -31,6 +31,7 @@
extern int DEBUGLEVEL;
+extern struct cli_state *rpc_smb_cli;
/****************************************************************************
obtain the sid from the PDC. do some verification along the way...
@@ -38,7 +39,6 @@ extern int DEBUGLEVEL;
BOOL get_domain_sids(const char *myname,
DOM_SID *sid3, DOM_SID *sid5, char *servers)
{
- uint16 nt_pipe_fnum;
POLICY_HND pol;
fstring srv_name;
struct cli_state cli;
@@ -46,6 +46,8 @@ BOOL get_domain_sids(const char *myname,
fstring dom3;
fstring dom5;
+ rpc_smb_cli = &cli;
+
if (sid3 == NULL && sid5 == NULL)
{
/* don't waste my time... */
@@ -78,29 +80,25 @@ BOOL get_domain_sids(const char *myname,
fstrcat(srv_name, myname);
strupper(srv_name);
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(&cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
-
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy(&cli, nt_pipe_fnum, srv_name, &pol, False) : False;
+ res = res ? lsa_open_policy(srv_name, &pol, False) : False;
if (sid3 != NULL)
{
/* send client info query, level 3. receive domain name and sid */
- res = res ? lsa_query_info_pol(&cli, nt_pipe_fnum, &pol, 3, dom3, sid3) : False;
+ res = res ? lsa_query_info_pol(&pol, 3, dom3, sid3) : False;
}
if (sid5 != NULL)
{
/* send client info query, level 5. receive domain name and sid */
- res = res ? lsa_query_info_pol(&cli, nt_pipe_fnum, &pol, 5, dom5, sid5) : False;
+ res = res ? lsa_query_info_pol(&pol, 5, dom5, sid5) : False;
}
/* close policy handle */
- res = res ? lsa_close(&cli, nt_pipe_fnum, &pol) : False;
+ res = res ? lsa_close(&pol) : False;
/* close the session */
- cli_nt_session_close(&cli, nt_pipe_fnum);
cli_ulogoff(&cli);
cli_shutdown(&cli);
@@ -134,7 +132,6 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
DOM_SID *sid,
char *domain, size_t len)
{
- uint16 nt_pipe_fnum;
POLICY_HND pol;
fstring srv_name;
struct cli_state cli;
@@ -145,6 +142,8 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
fstring dom3;
fstring dom5;
+ rpc_smb_cli = &cli;
+
if (!cli_connect_serverlist(&cli, server))
{
DEBUG(0,("get_trust_sid: unable to initialise client connection.\n"));
@@ -160,23 +159,19 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
fstrcat(srv_name, myname);
strupper(srv_name);
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(&cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
-
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy(&cli, nt_pipe_fnum, srv_name, &pol, False) : False;
+ res = res ? lsa_open_policy(srv_name, &pol, False) : False;
/* send client info query, level 3. receive domain name and sid */
- res1 = res ? lsa_query_info_pol(&cli, nt_pipe_fnum, &pol, 3, dom3, &sid3) : False;
+ res1 = res ? lsa_query_info_pol(&pol, 3, dom3, &sid3) : False;
/* send client info query, level 5. receive domain name and sid */
- res1 = res1 ? lsa_query_info_pol(&cli, nt_pipe_fnum, &pol, 5, dom5, &sid5) : False;
+ res1 = res1 ? lsa_query_info_pol(&pol, 5, dom5, &sid5) : False;
/* close policy handle */
- res = res ? lsa_close(&cli, nt_pipe_fnum, &pol) : False;
+ res = res ? lsa_close(&pol) : False;
/* close the session */
- cli_nt_session_close(&cli, nt_pipe_fnum);
cli_ulogoff(&cli);
cli_shutdown(&cli);
@@ -214,8 +209,7 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
/****************************************************************************
do a LSA Open Policy
****************************************************************************/
-BOOL lsa_open_policy(struct cli_state *cli, uint16 fnum,
- const char *server_name, POLICY_HND *hnd,
+BOOL lsa_open_policy(const char *server_name, POLICY_HND *hnd,
BOOL sec_qos)
{
prs_struct rbuf;
@@ -223,6 +217,13 @@ BOOL lsa_open_policy(struct cli_state *cli, uint16 fnum,
LSA_Q_OPEN_POL q_o;
LSA_SEC_QOS qos;
BOOL valid_pol = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_init(server_name, PIPE_LSARPC, &cli, &fnum))
+ {
+ return False;
+ }
if (hnd == NULL) return False;
@@ -267,7 +268,10 @@ BOOL lsa_open_policy(struct cli_state *cli, uint16 fnum,
{
/* ok, at last: we're happy. return the policy handle */
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
- valid_pol = True;
+
+ valid_pol = register_policy_hnd(hnd) &&
+ set_policy_cli_state(hnd, cli, fnum,
+ cli_state_free);
}
}
@@ -280,8 +284,7 @@ BOOL lsa_open_policy(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Open Policy2
****************************************************************************/
-BOOL lsa_open_policy2(struct cli_state *cli, uint16 fnum,
- const char *server_name, POLICY_HND *hnd,
+BOOL lsa_open_policy2( const char *server_name, POLICY_HND *hnd,
BOOL sec_qos)
{
prs_struct rbuf;
@@ -290,6 +293,14 @@ BOOL lsa_open_policy2(struct cli_state *cli, uint16 fnum,
LSA_SEC_QOS qos;
BOOL valid_pol = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_init(server_name, PIPE_LSARPC, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -333,7 +344,9 @@ BOOL lsa_open_policy2(struct cli_state *cli, uint16 fnum,
{
/* ok, at last: we're happy. return the policy handle */
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
- valid_pol = True;
+ valid_pol = register_policy_hnd(hnd) &&
+ set_policy_cli_state(hnd, cli, fnum,
+ cli_state_free);
}
}
@@ -346,8 +359,7 @@ BOOL lsa_open_policy2(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Open Secret
****************************************************************************/
-BOOL lsa_open_secret(struct cli_state *cli, uint16 fnum,
- const POLICY_HND *hnd_pol,
+BOOL lsa_open_secret( const POLICY_HND *hnd,
const char *secret_name,
uint32 des_access,
POLICY_HND *hnd_secret)
@@ -357,7 +369,15 @@ BOOL lsa_open_secret(struct cli_state *cli, uint16 fnum,
LSA_Q_OPEN_SECRET q_o;
BOOL valid_pol = False;
- if (hnd_pol == NULL) return False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
+ if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -366,7 +386,7 @@ BOOL lsa_open_secret(struct cli_state *cli, uint16 fnum,
DEBUG(4,("LSA Open Secret\n"));
- make_q_open_secret(&q_o, hnd_pol, secret_name, des_access);
+ make_q_open_secret(&q_o, hnd, secret_name, des_access);
/* turn parameters into data stream */
lsa_io_q_open_secret("", &q_o, &buf, 0);
@@ -404,8 +424,7 @@ BOOL lsa_open_secret(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Query Secret
****************************************************************************/
-BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, STRING2 *enc_secret,
+BOOL lsa_query_secret(POLICY_HND *hnd, STRING2 *secret,
NTTIME *last_update)
{
prs_struct rbuf;
@@ -413,7 +432,15 @@ BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
LSA_Q_QUERY_SECRET q_q;
BOOL valid_info = False;
- if (pol == NULL) return False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
+ if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -422,7 +449,7 @@ BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
DEBUG(4,("LSA Query Secret\n"));
- make_q_query_secret(&q_q, pol);
+ make_q_query_secret(&q_q, hnd);
/* turn parameters into data stream */
lsa_io_q_query_secret("", &q_q, &buf, 0);
@@ -447,9 +474,11 @@ BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
(r_q.info.value.ptr_secret != 0) &&
(r_q.info.ptr_update != 0))
{
- memcpy(enc_secret, &(r_q.info.value.enc_secret), sizeof(STRING2));
+ STRING2 enc_secret;
+ memcpy(&enc_secret, &(r_q.info.value.enc_secret), sizeof(STRING2));
memcpy(last_update, &(r_q.info.last_update), sizeof(NTTIME));
- valid_info = True;
+ valid_info = nt_decrypt_string2(secret, &enc_secret,
+ (char*)(cli->pwd.smb_nt_pwd));
}
}
@@ -463,8 +492,7 @@ BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Lookup Names
****************************************************************************/
-BOOL lsa_lookup_names(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd,
+BOOL lsa_lookup_names( POLICY_HND *hnd,
int num_names,
char **names,
DOM_SID **sids,
@@ -476,6 +504,14 @@ BOOL lsa_lookup_names(struct cli_state *cli, uint16 fnum,
LSA_Q_LOOKUP_NAMES q_l;
BOOL valid_response = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL || num_sids == 0 || sids == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -595,8 +631,7 @@ BOOL lsa_lookup_names(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Lookup SIDs
****************************************************************************/
-BOOL lsa_lookup_sids(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd,
+BOOL lsa_lookup_sids(POLICY_HND *hnd,
int num_sids,
DOM_SID **sids,
char ***names,
@@ -608,6 +643,14 @@ BOOL lsa_lookup_sids(struct cli_state *cli, uint16 fnum,
LSA_Q_LOOKUP_SIDS q_l;
BOOL valid_response = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
ZERO_STRUCT(q_l);
if (hnd == NULL || num_sids == 0 || sids == NULL) return False;
@@ -745,8 +788,7 @@ BOOL lsa_lookup_sids(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Query Info Policy
****************************************************************************/
-BOOL lsa_query_info_pol(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd, uint16 info_class,
+BOOL lsa_query_info_pol(POLICY_HND *hnd, uint16 info_class,
fstring domain_name, DOM_SID *domain_sid)
{
prs_struct rbuf;
@@ -754,6 +796,14 @@ BOOL lsa_query_info_pol(struct cli_state *cli, uint16 fnum,
LSA_Q_QUERY_INFO q_q;
BOOL valid_response = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
ZERO_STRUCTP(domain_sid);
domain_name[0] = 0;
@@ -854,8 +904,7 @@ BOOL lsa_query_info_pol(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Enumerate Trusted Domain
****************************************************************************/
-BOOL lsa_enum_trust_dom(struct cli_state *cli, uint16 fnum,
- POLICY_HND *hnd, uint32 *enum_ctx,
+BOOL lsa_enum_trust_dom(POLICY_HND *hnd, uint32 *enum_ctx,
uint32 *num_doms, char ***names,
DOM_SID ***sids)
{
@@ -864,6 +913,14 @@ BOOL lsa_enum_trust_dom(struct cli_state *cli, uint16 fnum,
LSA_Q_ENUM_TRUST_DOM q_q;
BOOL valid_response = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL || num_doms == NULL || names == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -931,12 +988,20 @@ BOOL lsa_enum_trust_dom(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a LSA Close
****************************************************************************/
-BOOL lsa_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
+BOOL lsa_close(POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
LSA_Q_CLOSE q_c;
- BOOL valid_close = False;
+ BOOL valid_close = False;
+
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
if (hnd == NULL) return False;
@@ -993,6 +1058,8 @@ BOOL lsa_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ close_policy_hnd(hnd);
+
return valid_close;
}
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 71670c0d84..1c8c406bae 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -720,7 +720,7 @@ do an rpc bind
****************************************************************************/
static BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, uint16 fnum,
- char *pipe_name, uint16 device_state)
+ const char *pipe_name, uint16 device_state)
{
BOOL state_set = False;
char param[2];
@@ -763,7 +763,8 @@ static BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, uint16 fnum,
check the rpc bind acknowledge response
****************************************************************************/
-static BOOL valid_pipe_name(char *pipe_name, RPC_IFACE *abstract, RPC_IFACE *transfer)
+static BOOL valid_pipe_name(const char *pipe_name,
+ RPC_IFACE *abstract, RPC_IFACE *transfer)
{
int pipe_idx = 0;
@@ -797,7 +798,8 @@ static BOOL valid_pipe_name(char *pipe_name, RPC_IFACE *abstract, RPC_IFACE *tra
check the rpc bind acknowledge response
****************************************************************************/
-static BOOL check_bind_response(RPC_HDR_BA *hdr_ba, char *pipe_name, RPC_IFACE *transfer)
+static BOOL check_bind_response(RPC_HDR_BA *hdr_ba, const char *pipe_name,
+ RPC_IFACE *transfer)
{
int i = 0;
@@ -859,7 +861,7 @@ do an rpc bind
****************************************************************************/
static BOOL rpc_pipe_bind(struct cli_state *cli, uint16 fnum,
- char *pipe_name,
+ const char *pipe_name,
RPC_IFACE *abstract, RPC_IFACE *transfer,
char *my_name)
{
@@ -1057,7 +1059,8 @@ void cli_nt_set_ntlmssp_flgs(struct cli_state *cli, uint32 ntlmssp_flgs)
open a session
****************************************************************************/
-BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, uint16* fnum)
+BOOL cli_nt_session_open(struct cli_state *cli, const char *pipe_name,
+ uint16* fnum)
{
RPC_IFACE abstract;
RPC_IFACE transfer;
diff --git a/source3/rpc_client/msrpc_lsarpc.c b/source3/rpc_client/msrpc_lsarpc.c
index c361a7146a..83ecc94197 100644
--- a/source3/rpc_client/msrpc_lsarpc.c
+++ b/source3/rpc_client/msrpc_lsarpc.c
@@ -35,49 +35,31 @@ extern int DEBUGLEVEL;
/****************************************************************************
nt lsa query secret
****************************************************************************/
-BOOL msrpc_lsa_query_secret(struct cli_state *cli,
+BOOL msrpc_lsa_query_secret(const char* srv_name,
const char* secret_name,
STRING2 *secret,
NTTIME *last_update)
{
- uint16 nt_pipe_fnum;
- fstring srv_name;
BOOL res = True;
BOOL res1;
BOOL res2;
POLICY_HND pol_sec;
POLICY_HND lsa_pol;
- STRING2 enc_secret;
-
- fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, cli->desthost);
- strupper(srv_name);
-
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy2(cli, nt_pipe_fnum,
- srv_name,
+ res = res ? lsa_open_policy2( srv_name,
&lsa_pol, False) : False;
/* lookup domain controller; receive a policy handle */
- res1 = res ? lsa_open_secret(cli, nt_pipe_fnum,
- &lsa_pol,
+ res1 = res ? lsa_open_secret( &lsa_pol,
secret_name, 0x02000000, &pol_sec) : False;
- res2 = res1 ? lsa_query_secret(cli, nt_pipe_fnum,
- &pol_sec, &enc_secret, last_update) : False;
-
- res1 = res1 ? lsa_close(cli, nt_pipe_fnum, &pol_sec) : False;
-
- res = res ? lsa_close(cli, nt_pipe_fnum, &lsa_pol) : False;
+ res2 = res1 ? lsa_query_secret(&pol_sec, secret, last_update) : False;
- /* close the session */
- cli_nt_session_close(cli, nt_pipe_fnum);
+ res1 = res1 ? lsa_close(&pol_sec) : False;
- res2 = res2 ? nt_decrypt_string2(secret, &enc_secret, (char*)(cli->pwd.smb_nt_pwd)) : False;
+ res = res ? lsa_close(&lsa_pol) : False;
return res2;
}
diff --git a/source3/rpc_client/msrpc_samr.c b/source3/rpc_client/msrpc_samr.c
index 02ffede615..d5a37832f3 100644
--- a/source3/rpc_client/msrpc_samr.c
+++ b/source3/rpc_client/msrpc_samr.c
@@ -462,7 +462,6 @@ BOOL sam_query_aliasmem(struct cli_state *cli, uint16 fnum,
if (res3 && num_aliases != 0)
{
fstring srv_name;
- uint16 fnum_lsa;
POLICY_HND lsa_pol;
uint32 i;
@@ -477,23 +476,16 @@ BOOL sam_query_aliasmem(struct cli_state *cli, uint16 fnum,
add_sid_to_array(&numsids, sids, &sid_mem[i].sid);
}
- /* open LSARPC session. */
- res3 = res3 ? cli_nt_session_open(cli, PIPE_LSARPC, &fnum_lsa) : False;
-
/* lookup domain controller; receive a policy handle */
- res3 = res3 ? lsa_open_policy(cli, fnum_lsa,
- srv_name,
+ res3 = res3 ? lsa_open_policy( srv_name,
&lsa_pol, True) : False;
/* send lsa lookup sids call */
- res4 = res3 ? lsa_lookup_sids(cli, fnum_lsa,
- &lsa_pol,
+ res4 = res3 ? lsa_lookup_sids( &lsa_pol,
num_aliases, *sids,
name, type, num_names) : False;
- res3 = res3 ? lsa_close(cli, fnum_lsa, &lsa_pol) : False;
-
- cli_nt_session_close(cli, fnum_lsa);
+ res3 = res3 ? lsa_close(&lsa_pol) : False;
}
if (!res4)
diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c
index 36bacad59b..8e4620f8dc 100644
--- a/source3/rpc_server/srv_lsa_hnd.c
+++ b/source3/rpc_server/srv_lsa_hnd.c
@@ -111,7 +111,7 @@ BOOL init_policy_hnd(int num_pol_hnds)
/****************************************************************************
find first available policy slot. creates a policy handle for you.
****************************************************************************/
-BOOL open_policy_hnd(POLICY_HND *hnd)
+BOOL register_policy_hnd(POLICY_HND *hnd)
{
int i;
struct policy *p;
@@ -135,7 +135,6 @@ BOOL open_policy_hnd(POLICY_HND *hnd)
p->pnum = i;
p->type = POL_NO_INFO;
- create_pol_hnd(hnd);
memcpy(&p->pol_hnd, hnd, sizeof(*hnd));
bitmap_set(bmap, i);
@@ -149,22 +148,32 @@ BOOL open_policy_hnd(POLICY_HND *hnd)
}
/****************************************************************************
+ find first available policy slot. creates a policy handle for you.
+****************************************************************************/
+BOOL open_policy_hnd(POLICY_HND *hnd)
+{
+ create_pol_hnd(hnd);
+ return register_policy_hnd(hnd);
+}
+
+/****************************************************************************
find policy by handle
****************************************************************************/
-static struct policy *find_policy(POLICY_HND *hnd)
+static struct policy *find_policy(const POLICY_HND *hnd)
{
struct policy *p;
for (p=Policy;p;p=p->next) {
if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%x] ", p->pnum));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (const char *)hnd->data,
+ sizeof(hnd->data));
return p;
}
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (const char *)hnd->data, sizeof(hnd->data));
return NULL;
}
@@ -172,7 +181,7 @@ static struct policy *find_policy(POLICY_HND *hnd)
/****************************************************************************
find policy index by handle
****************************************************************************/
-int find_policy_by_hnd(POLICY_HND *hnd)
+int find_policy_by_hnd(const POLICY_HND *hnd)
{
struct policy *p = find_policy(hnd);
@@ -393,7 +402,8 @@ BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum,
/****************************************************************************
get cli state
****************************************************************************/
-BOOL get_policy_cli_state(POLICY_HND *hnd, struct cli_state **cli, uint16 *fnum)
+BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli,
+ uint16 *fnum)
{
struct policy *p = find_policy(hnd);
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 3f7cee2add..70f725fd87 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -34,15 +34,11 @@ extern int DEBUGLEVEL;
extern FILE* out_hnd;
-extern struct cli_state *smb_cli;
-extern int smb_tidx;
-
/****************************************************************************
nt enumerate trusted domains
****************************************************************************/
void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
fstring srv_name;
uint32 num_doms = 0;
char **domains = NULL;
@@ -57,28 +53,20 @@ void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[])
DEBUG(4,("cmd_lsa_enum_trust_dom: server:%s\n", srv_name));
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
-
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy(smb_cli, nt_pipe_fnum,
- srv_name,
+ res = res ? lsa_open_policy( srv_name,
&info->dom.lsa_info_pol, False) : False;
do
{
/* send enum trusted domains query */
- res = res ? lsa_enum_trust_dom(smb_cli, nt_pipe_fnum,
- &info->dom.lsa_info_pol,
+ res = res ? lsa_enum_trust_dom( &info->dom.lsa_info_pol,
&enum_ctx,
&num_doms, &domains, &sids) : False;
} while (res && enum_ctx != 0);
- res = res ? lsa_close(smb_cli, nt_pipe_fnum, &info->dom.lsa_info_pol) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
+ res = res ? lsa_close(&info->dom.lsa_info_pol) : False;
if (res)
{
@@ -108,7 +96,6 @@ nt lsa query
****************************************************************************/
void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
fstring srv_name;
BOOL res = True;
@@ -124,32 +111,21 @@ void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[])
DEBUG(4,("cmd_lsa_query_info: server:%s\n", srv_name));
- DEBUG(5, ("cmd_lsa_query_info: smb_cli->fd:%d\n", smb_cli->fd));
-
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
-
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy(smb_cli, nt_pipe_fnum,
- srv_name,
+ res = res ? lsa_open_policy( srv_name,
&info->dom.lsa_info_pol, False) : False;
/* send client info query, level 3. receive domain name and sid */
- res = res ? lsa_query_info_pol(smb_cli, nt_pipe_fnum,
- &info->dom.lsa_info_pol, 0x03,
+ res = res ? lsa_query_info_pol( &info->dom.lsa_info_pol, 0x03,
info->dom.level3_dom,
&info->dom.level3_sid) : False;
/* send client info query, level 5. receive domain name and sid */
- res = res ? lsa_query_info_pol(smb_cli, nt_pipe_fnum,
- &info->dom.lsa_info_pol, 0x05,
+ res = res ? lsa_query_info_pol( &info->dom.lsa_info_pol, 0x05,
info->dom.level5_dom,
&info->dom.level5_sid) : False;
- res = res ? lsa_close(smb_cli, nt_pipe_fnum, &info->dom.lsa_info_pol) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
+ res = res ? lsa_close(&info->dom.lsa_info_pol) : False;
if (res)
{
@@ -190,7 +166,6 @@ lookup names
****************************************************************************/
void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
fstring temp;
int i;
fstring srv_name;
@@ -222,24 +197,16 @@ void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[])
return;
}
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
-
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy(smb_cli, nt_pipe_fnum,
- srv_name,
+ res = res ? lsa_open_policy( srv_name,
&info->dom.lsa_info_pol, True) : False;
/* send lsa lookup sids call */
- res = res ? lsa_lookup_names(smb_cli, nt_pipe_fnum,
- &info->dom.lsa_info_pol,
+ res = res ? lsa_lookup_names( &info->dom.lsa_info_pol,
num_names, names,
&sids, NULL, &num_sids) : False;
- res = res ? lsa_close(smb_cli, nt_pipe_fnum, &info->dom.lsa_info_pol) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
+ res = res ? lsa_close(&info->dom.lsa_info_pol) : False;
if (res)
{
@@ -273,7 +240,6 @@ lookup sids
****************************************************************************/
void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
int i;
pstring sid_name;
fstring srv_name;
@@ -327,24 +293,16 @@ void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[])
return;
}
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &nt_pipe_fnum) : False;
-
/* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy(smb_cli, nt_pipe_fnum,
- srv_name,
+ res = res ? lsa_open_policy( srv_name,
&info->dom.lsa_info_pol, True) : False;
/* send lsa lookup sids call */
- res = res ? lsa_lookup_sids(smb_cli, nt_pipe_fnum,
- &info->dom.lsa_info_pol,
+ res = res ? lsa_lookup_sids( &info->dom.lsa_info_pol,
num_sids, sids,
&names, NULL, &num_names) : False;
- res = res ? lsa_close(smb_cli, nt_pipe_fnum, &info->dom.lsa_info_pol) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
+ res = res ? lsa_close(&info->dom.lsa_info_pol) : False;
if (res)
{
@@ -381,6 +339,11 @@ void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[])
char *secret_name;
STRING2 secret;
NTTIME last_update;
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc > 2)
{
@@ -390,7 +353,7 @@ void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[])
secret_name = argv[1];
- if (msrpc_lsa_query_secret(smb_cli, secret_name, &secret, &last_update))
+ if (msrpc_lsa_query_secret(srv_name, secret_name, &secret, &last_update))
{
int i;
report(out_hnd, "\tValue : ");
@@ -408,4 +371,3 @@ void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[])
}
}
-
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 9f9df8ed19..3e83b82008 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -512,7 +512,6 @@ SAM add alias member.
void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
- uint16 fnum_lsa;
fstring srv_name;
fstring domain;
fstring tmp;
@@ -560,23 +559,16 @@ void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
report(out_hnd, "SAM Domain Alias Member\n");
- /* open LSARPC session. */
- res3 = res3 ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &fnum_lsa) : False;
-
/* lookup domain controller; receive a policy handle */
- res3 = res3 ? lsa_open_policy(smb_cli, fnum_lsa,
- srv_name,
+ res3 = res3 ? lsa_open_policy( srv_name,
&lsa_pol, True) : False;
/* send lsa lookup sids call */
- res4 = res3 ? lsa_lookup_names(smb_cli, fnum_lsa,
- &lsa_pol,
+ res4 = res3 ? lsa_lookup_names( &lsa_pol,
num_names, names,
&sids, NULL, &num_sids) : False;
- res3 = res3 ? lsa_close(smb_cli, fnum_lsa, &lsa_pol) : False;
-
- cli_nt_session_close(smb_cli, fnum_lsa);
+ res3 = res3 ? lsa_close(&lsa_pol) : False;
res4 = num_sids < 2 ? False : res4;
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index f242f9c4ea..7e36eeec00 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -48,6 +48,7 @@ static void cmd_quit(struct client_info *info, int argc, char *argv[]);
static struct cli_state smbcli;
struct cli_state *smb_cli = &smbcli;
+extern struct cli_state *rpc_smb_cli;
static struct client_info cli_info;
@@ -62,6 +63,7 @@ initialise smb client structure
void rpcclient_init(void)
{
bzero(smb_cli, sizeof(smb_cli));
+ rpc_smb_cli = smb_cli;
cli_initialise(smb_cli);
smb_cli->capabilities |= CAP_NT_SMBS | CAP_STATUS32;
}
@@ -1379,6 +1381,7 @@ static char *complete_cmd_null(char *text, int state)
out_hnd = stdout;
fstrcpy(debugf, argv[0]);
+ init_policy_hnd(64);
rpcclient_init();
#ifdef KANJI
diff --git a/source3/utils/rpctorture.c b/source3/utils/rpctorture.c
index ff98c0a837..0933cf38c1 100644
--- a/source3/utils/rpctorture.c
+++ b/source3/utils/rpctorture.c
@@ -478,17 +478,12 @@ static void run_lsahandles(int numops, struct client_info *cli_info)
DEBUG(0,("lsahandle test: connection failed\n"));
return;
}
- /* open session. */
- if (!cli_nt_session_open(smb_cli, PIPE_LSARPC, &nt_pipe_fnum))
- {
- DEBUG(0,("lsahandle test: session open failed\n"));
- return;
- }
-
for (i = 1; i <= numops * 100; i++)
{
+ extern struct cli_state *rpc_smb_cli;
+ rpc_smb_cli = smb_cli;
POLICY_HND pol;
- if (!lsa_open_policy(smb_cli, nt_pipe_fnum, srv_name, &pol, False))
+ if (!lsa_open_policy(srv_name, &pol, False))
{
failed++;
}
@@ -499,9 +494,6 @@ static void run_lsahandles(int numops, struct client_info *cli_info)
count++;
}
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
-
/* close the rpc pipe */
rpcclient_stop();