summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-24 20:24:33 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-24 20:24:33 +0000
commitf8b82a7b9507e11595bc924def179dc1d7d79a54 (patch)
tree1dab991fc42fecce86a98d45cb47fcb0dd087c38 /source3/rpcclient
parent2752e372b64337de24edef52575ddc7da0ed8d04 (diff)
downloadsamba-f8b82a7b9507e11595bc924def179dc1d7d79a54.tar.gz
samba-f8b82a7b9507e11595bc924def179dc1d7d79a54.tar.bz2
samba-f8b82a7b9507e11595bc924def179dc1d7d79a54.zip
first stages of removing struct cli_state* and uint16 fnum from all
msrpc client code. the intent is to hide / abstract / associate connection info behind policy handles. this makes the msrpc functions look more and more like their nt equivalents. who-hou! (This used to be commit c01b18e632aede6fce7264ef6971d7ddba945cfb)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_lsarpc.c76
-rw-r--r--source3/rpcclient/cmd_samr.c14
-rw-r--r--source3/rpcclient/rpcclient.c3
3 files changed, 25 insertions, 68 deletions
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