summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/client.h20
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/lib/domain_namemap.c8
-rw-r--r--source3/lib/util.c21
-rw-r--r--source3/libsmb/clientgen.c77
-rw-r--r--source3/libsmb/clienttrust.c2
-rw-r--r--source3/rpc_client/cli_lsarpc.c19
-rw-r--r--source3/rpc_client/cli_netlogon.c4
-rw-r--r--source3/rpc_client/cli_netlogon_sync.c4
-rw-r--r--source3/rpc_client/cli_pipe.c12
-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
15 files changed, 153 insertions, 153 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 7c5854b556..78c7d977c0 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -78,7 +78,17 @@ struct pwd_info
uchar sess_key[16];
};
-struct cli_state {
+struct user_credentials
+{
+ fstring user_name;
+ fstring domain;
+ struct pwd_info pwd;
+
+ uint32 ntlmssp_flags;
+};
+
+struct cli_state
+{
int port;
int fd;
uint16 cnum;
@@ -88,12 +98,12 @@ struct cli_state {
int protocol;
int sec_mode;
int rap_error;
- int privilages;
+ int privileges;
+
+ struct user_credentials usr;
fstring eff_name;
fstring desthost;
- fstring user_name;
- fstring domain;
/*
* The following strings are the
@@ -108,10 +118,8 @@ struct cli_state {
fstring dev;
struct nmb_name called;
struct nmb_name calling;
- fstring full_dest_host_name;
struct in_addr dest_ip;
- struct pwd_info pwd;
unsigned char cryptkey[8];
unsigned char lm_cli_chal[8];
unsigned char nt_cli_chal[128];
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 580ab22f96..475c1a2bac 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -481,6 +481,7 @@ int set_maxfiles(int requested_max);
void reg_get_subkey(char *full_keyname, char *key_name, char *subkey_name);
BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name);
BOOL become_user_permanently(uid_t uid, gid_t gid);
+BOOL resolve_srv_name(const char* srv_name, fstring dest_host, struct in_addr *ip);
/*The following definitions come from lib/util_array.c */
@@ -668,6 +669,7 @@ void unistr2_free(UNISTR2 *name);
/*The following definitions come from libsmb/clientgen.c */
+void copy_user_creds(struct user_credentials *to, const struct user_credentials *from);
int cli_set_port(struct cli_state *cli, int port);
char *cli_errstr(struct cli_state *cli);
void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len);
@@ -747,6 +749,7 @@ BOOL cli_negprot(struct cli_state *cli);
BOOL cli_session_request(struct cli_state *cli,
struct nmb_name *calling, struct nmb_name *called);
BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
+void cli_init_creds(struct cli_state *cli, const struct user_credentials *usr);
struct cli_state *cli_initialise(struct cli_state *cli);
void cli_close_socket(struct cli_state *cli);
void cli_shutdown(struct cli_state *cli);
diff --git a/source3/lib/domain_namemap.c b/source3/lib/domain_namemap.c
index 51fcd2467a..551c7290ea 100644
--- a/source3/lib/domain_namemap.c
+++ b/source3/lib/domain_namemap.c
@@ -882,7 +882,8 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
struct cli_state cli;
POLICY_HND lsa_pol;
fstring srv_name;
- extern struct cli_state *rpc_smb_cli;
+ extern struct user_credentials *usr_creds;
+ struct user_credentials usr;
BOOL res3 = True;
BOOL res4 = True;
@@ -891,7 +892,10 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
uint8 *types;
char *names[1];
- rpc_smb_cli = &cli;
+ usr_creds = &usr;
+
+ ZERO_STRUCT(usr);
+ pwd_set_nullpwd(&usr.pwd);
DEBUG(5,("lookup_remote_ntname: %s\n", ntname));
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 26f0482162..cd6368ee77 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3228,3 +3228,24 @@ BOOL become_user_permanently(uid_t uid, gid_t gid)
return(True);
}
+BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
+ struct in_addr *ip)
+{
+ DEBUG(10,("resolve_srv_name: %s\n", srv_name));
+
+ if (srv_name == NULL || strequal("\\\\.", srv_name))
+ {
+ fstrcpy(dest_host, global_myname);
+ ip = interpret_addr2("127.0.0.1");
+ return True;
+ }
+
+ if (!strnequal("\\\\", srv_name, 2))
+ {
+ return False;
+ }
+
+ fstrcpy(dest_host, &srv_name[2]);
+ return resolve_name(dest_host, ip, 0x20);
+}
+
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 61ce3f9900..94cd89e342 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -31,6 +31,14 @@ extern int DEBUGLEVEL;
* set the port that will be used for connections by the client
*/
+void copy_user_creds(struct user_credentials *to, const struct user_credentials *from)
+{
+ safe_strcpy(to->domain , from->domain , sizeof(from->domain )-1);
+ safe_strcpy(to->user_name, from->user_name, sizeof(from->user_name)-1);
+ memcpy(&to->pwd, &from->pwd, sizeof(from->pwd));
+ to->ntlmssp_flags = from->ntlmssp_flags;
+};
+
int cli_set_port(struct cli_state *cli, int port)
{
@@ -585,7 +593,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
if (cli->rap_error == 0) {
DEBUG(4,("NetWkstaUserLogon success\n"));
- cli->privilages = SVAL(p, 24);
+ cli->privileges = SVAL(p, 24);
fstrcpy(cli->eff_name,p+2);
} else {
DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->rap_error));
@@ -1003,10 +1011,10 @@ static BOOL cli_calc_session_pwds(struct cli_state *cli,
cli->nt_cli_chal,
&cli->nt_cli_chal_len,
cli->calling.name,
- cli->domain);
+ cli->usr.domain);
nt_owf_gen(pword, nt_owf);
- ntv2_owf_gen(nt_owf, cli->user_name, cli->domain, kr);
+ ntv2_owf_gen(nt_owf, cli->usr.user_name, cli->usr.domain, kr);
/* lm # */
memcpy(pword, cli->lm_cli_chal, 8);
@@ -1063,7 +1071,7 @@ BOOL cli_session_setup(struct cli_state *cli,
return False;
}
- fstrcpy(cli->user_name, user);
+ fstrcpy(cli->usr.user_name, user);
return cli_calc_session_pwds(cli, pword, ntpword,
pass, &passlen,
@@ -2698,6 +2706,15 @@ BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
/****************************************************************************
initialise a client structure
****************************************************************************/
+void cli_init_creds(struct cli_state *cli, const struct user_credentials *usr)
+{
+ copy_user_creds(&cli->usr, usr);
+ cli->ntlmssp_cli_flgs = usr->ntlmssp_flags;
+}
+
+/****************************************************************************
+initialise a client structure
+****************************************************************************/
struct cli_state *cli_initialise(struct cli_state *cli)
{
if (!cli) {
@@ -2913,7 +2930,7 @@ BOOL cli_reestablish_connection(struct cli_state *cli)
DEBUG(5,("cli_reestablish_connection: %s connecting to %s (ip %s) - %s [%s]\n",
nmb_namestr(&calling), nmb_namestr(&called),
inet_ntoa(cli->dest_ip),
- cli->user_name, cli->domain));
+ cli->usr.user_name, cli->usr.domain));
cli->fd = -1;
@@ -2951,7 +2968,7 @@ BOOL cli_establish_connection(struct cli_state *cli,
DEBUG(5,("cli_establish_connection: %s connecting to %s (%s) - %s [%s] with NTLM%s\n",
callingstr, calledstr, inet_ntoa(*dest_ip),
- cli->user_name, cli->domain,
+ cli->usr.user_name, cli->usr.domain,
cli->use_ntlmv2 ? "v2" : "v1"));
/* establish connection */
@@ -2991,10 +3008,10 @@ BOOL cli_establish_connection(struct cli_state *cli,
return False;
}
- if (cli->domain[0] == 0)
+ if (cli->usr.domain[0] == 0)
{
- safe_strcpy(cli->domain, cli->server_domain,
- sizeof(cli->domain));
+ safe_strcpy(cli->usr.domain, cli->server_domain,
+ sizeof(cli->usr.domain));
}
if (IS_BITS_SET_ALL(cli->capabilities, CAP_EXTENDED_SECURITY))
@@ -3064,10 +3081,10 @@ BOOL cli_establish_connection(struct cli_state *cli,
buf_len = PTR_DIFF(p, pwd_buf);
/* first session negotiation stage */
- if (!cli_session_setup_x(cli, cli->user_name,
+ if (!cli_session_setup_x(cli, cli->usr.user_name,
pwd_buf, buf_len,
NULL, 0,
- cli->domain))
+ cli->usr.domain))
{
DEBUG(1,("failed session setup\n"));
if (do_shutdown)
@@ -3103,17 +3120,17 @@ BOOL cli_establish_connection(struct cli_state *cli,
if (cli->use_ntlmv2 != False)
{
DEBUG(10,("cli_establish_connection: NTLMv2\n"));
- pwd_make_lm_nt_owf2(&(cli->pwd), cli->cryptkey,
- cli->user_name, calling->name, cli->domain);
+ pwd_make_lm_nt_owf2(&(cli->usr.pwd), cli->cryptkey,
+ cli->usr.user_name, calling->name, cli->usr.domain);
}
else
{
DEBUG(10,("cli_establish_connection: NTLMv1\n"));
- pwd_make_lm_nt_owf(&(cli->pwd), cli->cryptkey);
+ pwd_make_lm_nt_owf(&(cli->usr.pwd), cli->cryptkey);
}
- create_ntlmssp_resp(&cli->pwd, cli->domain,
- cli->user_name, cli->calling.name,
+ create_ntlmssp_resp(&cli->usr.pwd, cli->usr.domain,
+ cli->usr.user_name, cli->calling.name,
cli->ntlmssp_cli_flgs,
&auth_resp);
prs_link(NULL, &auth_resp, NULL);
@@ -3172,10 +3189,10 @@ BOOL cli_establish_connection(struct cli_state *cli,
*p_oem++ = gssapi_len & 0xff;
/* second session negotiation stage */
- if (!cli_session_setup_x(cli, cli->user_name,
+ if (!cli_session_setup_x(cli, cli->usr.user_name,
pwd_buf, buf_len,
NULL, 0,
- cli->domain))
+ cli->usr.domain))
{
DEBUG(1,("failed session setup\n"));
if (do_shutdown)
@@ -3202,12 +3219,12 @@ BOOL cli_establish_connection(struct cli_state *cli,
}
}
}
- else if (cli->pwd.cleartext || cli->pwd.null_pwd)
+ else if (cli->usr.pwd.cleartext || cli->usr.pwd.null_pwd)
{
fstring passwd, ntpasswd;
int pass_len = 0, ntpass_len = 0;
- if (cli->pwd.null_pwd)
+ if (cli->usr.pwd.null_pwd)
{
/* attempt null session */
passwd[0] = ntpasswd[0] = 0;
@@ -3216,15 +3233,15 @@ BOOL cli_establish_connection(struct cli_state *cli,
else
{
/* attempt clear-text session */
- pwd_get_cleartext(&(cli->pwd), passwd);
+ pwd_get_cleartext(&(cli->usr.pwd), passwd);
pass_len = strlen(passwd);
}
/* attempt clear-text session */
- if (!cli_session_setup(cli, cli->user_name,
+ if (!cli_session_setup(cli, cli->usr.user_name,
passwd, pass_len,
ntpasswd, ntpass_len,
- cli->domain))
+ cli->usr.domain))
{
DEBUG(1,("failed session setup\n"));
if (do_shutdown)
@@ -3257,23 +3274,23 @@ BOOL cli_establish_connection(struct cli_state *cli,
if (cli->use_ntlmv2 != False)
{
DEBUG(10,("cli_establish_connection: NTLMv2\n"));
- pwd_make_lm_nt_owf2(&(cli->pwd), cli->cryptkey,
- cli->user_name, calling->name, cli->domain);
+ pwd_make_lm_nt_owf2(&(cli->usr.pwd), cli->cryptkey,
+ cli->usr.user_name, calling->name, cli->usr.domain);
}
else
{
DEBUG(10,("cli_establish_connection: NTLMv1\n"));
- pwd_make_lm_nt_owf(&(cli->pwd), cli->cryptkey);
+ pwd_make_lm_nt_owf(&(cli->usr.pwd), cli->cryptkey);
}
- pwd_get_lm_nt_owf(&(cli->pwd), lm_sess_pwd, nt_sess_pwd,
+ pwd_get_lm_nt_owf(&(cli->usr.pwd), lm_sess_pwd, nt_sess_pwd,
&nt_sess_pwd_len, cli->sess_key);
/* attempt encrypted session */
- if (!cli_session_setup_x(cli, cli->user_name,
+ if (!cli_session_setup_x(cli, cli->usr.user_name,
(char*)lm_sess_pwd, sizeof(lm_sess_pwd),
(char*)nt_sess_pwd, nt_sess_pwd_len,
- cli->domain))
+ cli->usr.domain))
{
DEBUG(1,("failed session setup\n"));
@@ -3384,7 +3401,7 @@ BOOL cli_connect_serverlist(struct cli_state *cli, char *p)
*/
make_nmb_name(&stupid_smbserver_called , "*SMBSERVER", 0x20, scope);
- pwd_set_nullpwd(&cli->pwd);
+ pwd_set_nullpwd(&cli->usr.pwd);
if (!cli_establish_connection(cli, remote_machine, &dest_ip,
&calling, &called,
diff --git a/source3/libsmb/clienttrust.c b/source3/libsmb/clienttrust.c
index 1a2d7a7faa..81855585e6 100644
--- a/source3/libsmb/clienttrust.c
+++ b/source3/libsmb/clienttrust.c
@@ -73,7 +73,7 @@ addresses. Cannot add to ourselves.\n", remote_machine));
cli.protocol = PROTOCOL_NT1;
- pwd_set_nullpwd(&cli.pwd);
+ pwd_set_nullpwd(&cli.usr.pwd);
if (!cli_establish_connection(&cli, remote_machine, &cli.dest_ip,
&calling, &called,
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 26b17243cd..a7c15307a1 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -31,8 +31,6 @@
extern int DEBUGLEVEL;
-extern struct cli_state *rpc_smb_cli;
-
/****************************************************************************
obtain the sid from the PDC. do some verification along the way...
****************************************************************************/
@@ -45,8 +43,12 @@ BOOL get_domain_sids(const char *myname,
BOOL res = True;
fstring dom3;
fstring dom5;
-
- rpc_smb_cli = &cli;
+ extern struct user_credentials *usr_creds;
+ struct user_credentials usr;
+
+ usr_creds = &usr;
+ ZERO_STRUCT(usr);
+ pwd_set_nullpwd(&usr.pwd);
if (sid3 == NULL && sid5 == NULL)
{
@@ -142,7 +144,12 @@ BOOL get_trust_sid_and_domain(const char* myname, char *server,
fstring dom3;
fstring dom5;
- rpc_smb_cli = &cli;
+ extern struct user_credentials *usr_creds;
+ struct user_credentials usr;
+
+ usr_creds = &usr;
+ ZERO_STRUCT(usr);
+ pwd_set_nullpwd(&usr.pwd);
if (!cli_connect_serverlist(&cli, server))
{
@@ -478,7 +485,7 @@ BOOL lsa_query_secret(POLICY_HND *hnd, STRING2 *secret,
memcpy(&enc_secret, &(r_q.info.value.enc_secret), sizeof(STRING2));
memcpy(last_update, &(r_q.info.last_update), sizeof(NTTIME));
valid_info = nt_decrypt_string2(secret, &enc_secret,
- (char*)(cli->pwd.smb_nt_pwd));
+ (char*)(cli->usr.pwd.smb_nt_pwd));
}
}
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index 0a9228a3b2..d6db75f243 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -572,8 +572,8 @@ BOOL do_sam_sync(struct cli_state *cli, uchar trust_passwd[16],
*num_deltas = 0;
- DEBUG(5,("Attempting SAM sync with PDC, domain: %s name: %s\n",
- cli->domain, srv_name));
+ DEBUG(5,("Attempting SAM sync with PDC: %s\n",
+ srv_name));
/* open NETLOGON session. negotiate credentials */
res = res ? cli_nt_session_open(cli, PIPE_NETLOGON, &nt_pipe_fnum) : False;
diff --git a/source3/rpc_client/cli_netlogon_sync.c b/source3/rpc_client/cli_netlogon_sync.c
index 5dd2ab4909..526f366a15 100644
--- a/source3/rpc_client/cli_netlogon_sync.c
+++ b/source3/rpc_client/cli_netlogon_sync.c
@@ -55,9 +55,7 @@ BOOL synchronise_passdb(void)
return False;
}
- pstrcpy(cli.domain, lp_workgroup());
-
- if (!trust_get_passwd(trust_passwd, cli.domain, global_myname))
+ if (!trust_get_passwd(trust_passwd, lp_workgroup(), global_myname))
{
return False;
}
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 1c8c406bae..9aad93246e 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -903,7 +903,7 @@ static BOOL rpc_pipe_bind(struct cli_state *cli, uint16 fnum,
ntlmssp_auth ? &auth_ntlm : NULL,
rpc_call_id,
abstract, transfer,
- global_myname, cli->domain, cli->ntlmssp_cli_flgs);
+ global_myname, cli->usr.domain, cli->usr.ntlmssp_flags);
/* this is a hack due to limitations in rpc_api_pipe */
prs_init(&data, mem_buf_len(hdr.data), 4, 0x0, False);
@@ -967,16 +967,16 @@ static BOOL rpc_pipe_bind(struct cli_state *cli, uint16 fnum,
prs_init(&hdr_autha, 1024, 4, SAFETY_MARGIN, False);
prs_init(&auth_resp, 1024, 4, SAFETY_MARGIN, False);
- pwd_make_lm_nt_owf(&cli->pwd, rhdr_chal.challenge);
+ pwd_make_lm_nt_owf(&cli->usr.pwd, rhdr_chal.challenge);
- create_rpc_bind_resp(&cli->pwd, cli->domain,
- cli->user_name, global_myname,
+ create_rpc_bind_resp(&cli->usr.pwd, cli->usr.domain,
+ cli->usr.user_name, global_myname,
cli->ntlmssp_cli_flgs,
rpc_call_id,
&hdra, &hdr_autha, &auth_resp);
- pwd_get_lm_nt_owf(&cli->pwd, lm_owf, NULL, NULL, NULL);
- pwd_get_lm_nt_16(&cli->pwd, lm_hash, NULL);
+ pwd_get_lm_nt_owf(&cli->usr.pwd, lm_owf, NULL, NULL, NULL);
+ pwd_get_lm_nt_16(&cli->usr.pwd, lm_hash, NULL);
NTLMSSPOWFencrypt(lm_hash, lm_owf, p24);
{
unsigned char j = 0;
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);
}