summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-24 22:45:09 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-24 22:45:09 +0000
commit2803a72751cf511aa0b5e6745e1b169faa66f68a (patch)
treee93ae3fb9694c457c004600b2a0e58ec051d4bad /source3/rpcclient
parentf8b82a7b9507e11595bc924def179dc1d7d79a54 (diff)
downloadsamba-2803a72751cf511aa0b5e6745e1b169faa66f68a.tar.gz
samba-2803a72751cf511aa0b5e6745e1b169faa66f68a.tar.bz2
samba-2803a72751cf511aa0b5e6745e1b169faa66f68a.zip
ok. *whew*. this is the first completed part of the restructure.
verified that lsaquery, lsalookupsids work, and found some bugs in the parameters of these commands :-) soo... we now have an lsa_* api that has the same arguments as the nt Lsa* api! cool! the only significant coding difference is the introduction of a user_credentials structure, containing user, domain, pass and ntlmssp flags. (This used to be commit 57bff6fe82d777e599d535f076efb2328ba1188b)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_lsarpc.c8
-rw-r--r--source3/rpcclient/cmd_netlogon.c13
-rw-r--r--source3/rpcclient/cmd_samr.c5
-rw-r--r--source3/rpcclient/cmd_spoolss.c9
-rw-r--r--source3/rpcclient/rpcclient.c101
5 files changed, 39 insertions, 97 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 70f725fd87..26f08b099f 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -48,7 +48,7 @@ void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[])
BOOL res = True;
fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, info->myhostname);
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
DEBUG(4,("cmd_lsa_enum_trust_dom: server:%s\n", srv_name));
@@ -106,7 +106,7 @@ void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[])
ZERO_STRUCT(info->dom.level5_sid);
fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, info->myhostname);
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
DEBUG(4,("cmd_lsa_query_info: server:%s\n", srv_name));
@@ -180,7 +180,7 @@ void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[])
BOOL res = True;
fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, info->myhostname);
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
DEBUG(4,("cmd_lsa_lookup_names: server: %s\n", srv_name));
@@ -251,7 +251,7 @@ void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[])
BOOL res = True;
fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, info->myhostname);
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
DEBUG(4,("cmd_lsa_lookup_sids: server: %s\n", srv_name));
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index c255ff5370..67585ffff4 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -34,6 +34,7 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
extern struct cli_state *smb_cli;
+extern struct user_credentials *usr_creds;
extern FILE* out_hnd;
extern pstring global_myname;
@@ -68,7 +69,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[])
if (argc < 1)
{
- fstrcpy(nt_user_name, smb_cli->user_name);
+ fstrcpy(nt_user_name, usr_creds->user_name);
if (nt_user_name[0] == 0)
{
report(out_hnd,"ntlogin: must specify username with anonymous connection\n");
@@ -94,12 +95,12 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[])
DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name));
- res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False;
+ res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname) : False;
#if 0
/* check whether the user wants to change their machine password */
res = res ? trust_account_check(info->dest_ip, info->dest_host,
- info->myhostname, smb_cli->domain,
+ info->myhostname, usr_creds->domain,
info->mach_acct, new_mach_pwd) : False;
#endif
/* open NETLOGON session. negotiate credentials */
@@ -130,7 +131,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[])
/* do an NT login */
res = res ? cli_nt_login_interactive(smb_cli, nt_pipe_fnum,
- smb_cli->domain, nt_user_name,
+ usr_creds->domain, nt_user_name,
getuid(), nt_password,
&info->dom.ctr, &info->dom.user_info3) : False;
@@ -174,7 +175,7 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[])
fstrcpy(inter_dom_acct, nt_trust_dom);
fstrcat(inter_dom_acct, "$");
- res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, nt_trust_dom) : False;
+ res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, nt_trust_dom) : False;
/* open NETLOGON session. negotiate credentials */
res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False;
@@ -203,7 +204,7 @@ void cmd_sam_sync(struct client_info *info, int argc, char *argv[])
uchar trust_passwd[16];
extern pstring global_myname;
- if (!trust_get_passwd(trust_passwd, smb_cli->domain, global_myname))
+ if (!trust_get_passwd(trust_passwd, usr_creds->domain, global_myname))
{
report(out_hnd, "cmd_sam_sync: no trust account password\n");
return;
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 3e83b82008..17b251f1e1 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -34,6 +34,7 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
extern struct cli_state *smb_cli;
+extern struct user_credentials *usr_creds;
extern FILE* out_hnd;
@@ -151,7 +152,7 @@ void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[])
new_passwd = (char*)getpass("New Password (ONCE ONLY - get it right :-)");
nt_lm_owf_gen(new_passwd, lm_newhash, nt_newhash);
- pwd_get_lm_nt_16(&(smb_cli->pwd), lm_oldhash, nt_oldhash );
+ pwd_get_lm_nt_16(&(usr_creds->pwd), lm_oldhash, nt_oldhash );
make_oem_passwd_hash(nt_newpass, new_passwd, nt_oldhash, True);
make_oem_passwd_hash(lm_newpass, new_passwd, lm_oldhash, True);
E_old_pw_hash(lm_newhash, lm_oldhash, lm_hshhash);
@@ -176,7 +177,7 @@ void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[])
/* establish a connection. */
res = res ? samr_chgpasswd_user(smb_cli, fnum,
- srv_name, smb_cli->user_name,
+ srv_name, usr_creds->user_name,
nt_newpass, nt_hshhash,
lm_newpass, lm_hshhash) : False;
/* close the session */
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index f9be3be429..4c1bcc2b62 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -35,6 +35,7 @@ extern int DEBUGLEVEL;
extern FILE* out_hnd;
extern struct cli_state *smb_cli;
+extern struct user_credentials *usr_creds;
extern int smb_tidx;
/****************************************************************************
@@ -127,7 +128,7 @@ void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[
strupper(srv_name);
DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n",
- printer_name, srv_name, smb_cli->user_name));
+ printer_name, srv_name, usr_creds->user_name));
DEBUG(5, ("cmd_spoolss_open_printer_ex: smb_cli->fd:%d\n", smb_cli->fd));
@@ -137,7 +138,7 @@ void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[
res = res ? spoolss_open_printer_ex(smb_cli, nt_pipe_fnum,
printer_name,
0, 0, 0,
- srv_name, smb_cli->user_name,
+ srv_name, usr_creds->user_name,
&hnd) : False;
res = res ? spoolss_closeprinter(smb_cli, nt_pipe_fnum, &hnd) : False;
@@ -255,10 +256,10 @@ void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[])
strupper(srv_name);
DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n",
- printer_name, srv_name, smb_cli->user_name));
+ printer_name, srv_name, usr_creds->user_name));
if (msrpc_spoolss_enum_jobs(smb_cli,
- srv_name, smb_cli->user_name, printer_name,
+ srv_name, usr_creds->user_name, printer_name,
level, &num, &ctr,
spool_job_info_ctr))
{
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 7e36eeec00..5fa103a57f 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -46,9 +46,10 @@ static int process_tok(fstring tok);
static void cmd_help(struct client_info *info, int argc, char *argv[]);
static void cmd_quit(struct client_info *info, int argc, char *argv[]);
+static struct user_credentials usr;
+
static struct cli_state smbcli;
struct cli_state *smb_cli = &smbcli;
-extern struct cli_state *rpc_smb_cli;
static struct client_info cli_info;
@@ -57,52 +58,6 @@ static uint32 cmd_argc = 0;
FILE *out_hnd;
-/****************************************************************************
-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;
-}
-
-/****************************************************************************
-make smb client connection
-****************************************************************************/
-static BOOL rpcclient_connect(struct client_info *info)
-{
- struct nmb_name calling;
- struct nmb_name called;
-
- make_nmb_name(&called , dns_to_netbios_name(info->dest_host ), info->name_type, scope);
- make_nmb_name(&calling, dns_to_netbios_name(info->myhostname), 0x0 , scope);
-
- smb_cli->use_ntlmv2 = lp_client_ntlmv2();
-
- if (!cli_establish_connection(smb_cli,
- info->dest_host, &info->dest_ip,
- &calling, &called,
- info->share, info->svc_type,
- False, True))
- {
- DEBUG(0,("rpcclient_connect: connection failed\n"));
- cli_shutdown(smb_cli);
- return False;
- }
-
- return True;
-}
-
-/****************************************************************************
-stop the smb connection(s?)
-****************************************************************************/
-static void rpcclient_stop(void)
-{
- cli_shutdown(smb_cli);
-}
-
#define COMPL_NONE 0
#define COMPL_REGKEY 1
#define COMPL_SAMUSR 3
@@ -618,7 +573,6 @@ do a (presumably graceful) quit...
****************************************************************************/
static void cmd_quit(struct client_info *info, int argc, char *argv[])
{
- rpcclient_stop();
#ifdef MEM_MAN
{
extern FILE* dbf;
@@ -1375,14 +1329,17 @@ static char *complete_cmd_null(char *text, int state)
char *cmd_str="";
mode_t myumask = 0755;
enum client_action cli_action = CLIENT_NONE;
+ extern struct user_credentials *usr_creds;
pstring password; /* local copy only, if one is entered */
+ usr.ntlmssp_flags = 0x0;
+
+ usr_creds = &usr;
out_hnd = stdout;
fstrcpy(debugf, argv[0]);
init_policy_hnd(64);
- rpcclient_init();
#ifdef KANJI
pstrcpy(term_code, KANJI);
@@ -1414,8 +1371,8 @@ static char *complete_cmd_null(char *text, int state)
pstrcpy(cli_info.cur_dir , "\\");
pstrcpy(cli_info.file_sel, "");
pstrcpy(cli_info.base_dir, "");
- pstrcpy(smb_cli->domain, "");
- pstrcpy(smb_cli->user_name, "");
+ pstrcpy(usr.domain, "");
+ pstrcpy(usr.user_name, "");
pstrcpy(cli_info.myhostname, "");
pstrcpy(cli_info.dest_host, "");
@@ -1455,19 +1412,19 @@ static char *complete_cmd_null(char *text, int state)
if (getenv("USER"))
{
- pstrcpy(smb_cli->user_name,getenv("USER"));
+ pstrcpy(usr.user_name,getenv("USER"));
/* modification to support userid%passwd syntax in the USER var
25.Aug.97, jdblair@uab.edu */
- if ((p=strchr(smb_cli->user_name,'%')))
+ if ((p=strchr(usr.user_name,'%')))
{
*p = 0;
pstrcpy(password,p+1);
got_pass = True;
memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
}
- strupper(smb_cli->user_name);
+ strupper(usr.user_name);
}
password[0] = 0;
@@ -1479,10 +1436,10 @@ static char *complete_cmd_null(char *text, int state)
pstrcpy(password,getenv("PASSWD"));
}
- if (*smb_cli->user_name == 0 && getenv("LOGNAME"))
+ if (*usr.user_name == 0 && getenv("LOGNAME"))
{
- pstrcpy(smb_cli->user_name,getenv("LOGNAME"));
- strupper(smb_cli->user_name);
+ pstrcpy(usr.user_name,getenv("LOGNAME"));
+ strupper(usr.user_name);
}
if (argc < 2)
@@ -1573,8 +1530,8 @@ static char *complete_cmd_null(char *text, int state)
case 'U':
{
char *lp;
- pstrcpy(smb_cli->user_name,optarg);
- if ((lp=strchr(smb_cli->user_name,'%')))
+ pstrcpy(usr.user_name,optarg);
+ if ((lp=strchr(usr.user_name,'%')))
{
*lp = 0;
pstrcpy(password,lp+1);
@@ -1586,7 +1543,7 @@ static char *complete_cmd_null(char *text, int state)
case 'W':
{
- pstrcpy(smb_cli->domain,optarg);
+ pstrcpy(usr.domain,optarg);
break;
}
@@ -1707,38 +1664,22 @@ static char *complete_cmd_null(char *text, int state)
{
if (password[0] == 0)
{
- pwd_set_nullpwd(&(smb_cli->pwd));
+ pwd_set_nullpwd(&(usr.pwd));
}
else
{
/* generate 16 byte hashes */
- pwd_make_lm_nt_16(&(smb_cli->pwd), password);
+ pwd_make_lm_nt_16(&(usr.pwd), password);
}
}
else
{
- pwd_read(&(smb_cli->pwd), "Enter Password:", True);
+ pwd_read(&(usr.pwd), "Enter Password:", True);
}
- mdfour(smb_cli->sess_key, smb_cli->pwd.smb_nt_pwd, 16);
-
/* paranoia: destroy the local copy of the password */
bzero(password, sizeof(password));
- /* establish connections. nothing to stop these being re-established. */
- rpcclient_connect(&cli_info);
-
- smb_cli->ntlmssp_cli_flgs = 0x0;
-
- DEBUG(5,("rpcclient_connect: smb_cli->fd:%d\n", smb_cli->fd));
- if (smb_cli->fd <= 0)
- {
- fprintf(stderr, "warning: connection could not be established to %s<%02x>\n",
- cli_info.dest_host, cli_info.name_type);
- fprintf(stderr, "this version of smbclient may crash if you proceed\n");
- exit(-1);
- }
-
switch (cli_action)
{
case CLIENT_IPC:
@@ -1754,7 +1695,5 @@ static char *complete_cmd_null(char *text, int state)
}
}
- rpcclient_stop();
-
return(0);
}