From e302cb2b189f679bcf7efe60d5ae9fb4218c1411 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 29 Nov 1999 19:46:57 +0000 Subject: first attempt at getting \PIPE\NETLOGON working. it's pretty horrible. (This used to be commit 44dd3efa6380544e9a515e91960f9271498cefaf) --- source3/rpcclient/cmd_netlogon.c | 63 ++++++++++++++++++++++------------------ source3/rpcclient/rpcclient.c | 15 +++------- 2 files changed, 39 insertions(+), 39 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 67585ffff4..3010ed5297 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -33,11 +33,9 @@ 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; /**************************************************************************** @@ -45,7 +43,6 @@ experimental nt login. ****************************************************************************/ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) { - uint16 nt_pipe_fnum; #if 0 extern BOOL global_machine_password_needs_changing; #endif @@ -55,6 +52,12 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) BOOL res = True; char *nt_password; unsigned char trust_passwd[16]; + fstring trust_acct; + + fstring srv_name; + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); #if 0 /* machine account passwords */ @@ -93,7 +96,11 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) nt_password = getpass("Enter NT Login password:"); } - DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); + DEBUG(5,("do_nt_login_test: username %s from: %s\n", + nt_user_name, info->myhostname)); + + fstrcpy(trust_acct, info->myhostname); + fstrcat(trust_acct, "$"); res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname) : False; @@ -103,11 +110,9 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) info->myhostname, usr_creds->domain, info->mach_acct, new_mach_pwd) : False; #endif - /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; - res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, - smb_cli->mach_acct, global_myname, + res = res ? cli_nt_setup_creds(srv_name, info->myhostname, + trust_acct, trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; #if 0 @@ -116,7 +121,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) { unsigned char new_trust_passwd[16]; generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(smb_cli, nt_pipe_fnum, new_trust_passwd, SEC_CHAN_WKSTA) : False; + res = res ? cli_nt_srv_pwset(srv_name, info->myhostname, new_trust_passwd, SEC_CHAN_WKSTA) : False; if (res) { @@ -130,7 +135,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) memset(trust_passwd, 0, 16); /* do an NT login */ - res = res ? cli_nt_login_interactive(smb_cli, nt_pipe_fnum, + res = res ? cli_nt_login_interactive(srv_name, info->myhostname, usr_creds->domain, nt_user_name, getuid(), nt_password, &info->dom.ctr, &info->dom.user_info3) : False; @@ -141,10 +146,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) /* ok! you're logged in! do anything you like, then... */ /* do an NT logout */ - res = res ? cli_nt_logoff(smb_cli, nt_pipe_fnum, &info->dom.ctr) : False; - - /* close the session */ - cli_nt_session_close(smb_cli, nt_pipe_fnum); + res = res ? cli_nt_logoff(srv_name, info->myhostname, &info->dom.ctr) : False; report(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", nt_user_name, BOOLSTR(res)); @@ -155,13 +157,16 @@ experimental nt login. ****************************************************************************/ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) { - uint16 nt_pipe_fnum; - char *nt_trust_dom; BOOL res = True; unsigned char trust_passwd[16]; fstring inter_dom_acct; + fstring srv_name; + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + if (argc < 2) { report(out_hnd,"domtest: must specify domain name\n"); @@ -177,18 +182,12 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) 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; - - res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct, - global_myname, trust_passwd, + res = res ? cli_nt_setup_creds(srv_name, info->myhostname, inter_dom_acct, + trust_passwd, SEC_CHAN_DOMAIN) == 0x0 : False; memset(trust_passwd, 0, 16); - /* close the session */ - cli_nt_session_close(smb_cli, nt_pipe_fnum); - report(out_hnd,"cmd_nt_login: credentials (%s) test succeeded: %s\n", nt_trust_dom, BOOLSTR(res)); } @@ -202,16 +201,24 @@ void cmd_sam_sync(struct client_info *info, int argc, char *argv[]) SAM_DELTA_CTR deltas[MAX_SAM_DELTAS]; uint32 num; uchar trust_passwd[16]; - extern pstring global_myname; + fstring srv_name; + fstring trust_acct; + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + + fstrcpy(trust_acct, info->myhostname); + fstrcat(trust_acct, "$"); - if (!trust_get_passwd(trust_passwd, usr_creds->domain, global_myname)) + if (!trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname)) { report(out_hnd, "cmd_sam_sync: no trust account password\n"); return; } - if (do_sam_sync(smb_cli, trust_passwd, - smb_cli->mach_acct, global_myname, + if (net_sam_sync(srv_name, info->myhostname, + trust_acct, trust_passwd, hdr_deltas, deltas, &num)) { display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index aaf872683a..3951b8e564 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -49,9 +49,6 @@ static void cmd_set (struct client_info *info, int argc, char *argv[]); static struct user_credentials usr; -static struct cli_state smbcli; -struct cli_state *smb_cli = &smbcli; - static struct client_info cli_info; static char **cmd_argv = NULL; @@ -788,14 +785,14 @@ static BOOL process( struct client_info *info, char *cmd_str) fflush(out_hnd); #ifdef CLIX - line[0] = wait_keyboard(smb_cli); + line[0] = wait_keyboard(NULL); /* this might not be such a good idea... */ if ( line[0] == EOF) { break; } #else - wait_keyboard(smb_cli); + wait_keyboard(NULL); #endif /* and get a response */ @@ -1185,7 +1182,7 @@ static char *complete_printersenum(char *text, int state) { fstring srv_name; fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, smb_cli->desthost); + fstrcat(srv_name, cli_info.dest_host); strupper(srv_name); free_print1_array(num, ctr); @@ -1193,7 +1190,7 @@ static char *complete_printersenum(char *text, int state) num = 0; /* Iterate all users */ - if (!msrpc_spoolss_enum_printers(smb_cli, srv_name, + if (!msrpc_spoolss_enum_printers(srv_name, 1, &num, (void***)&ctr, NULL)) { @@ -1609,10 +1606,6 @@ static void cmd_set(struct client_info *info, int argc, char *argv[]) load_interfaces(); } - fstrcpy(cli_info.mach_acct, cli_info.myhostname); - strupper(cli_info.mach_acct); - fstrcat(cli_info.mach_acct, "$"); - if (cmd_str != NULL) { process(&cli_info, cmd_str); -- cgit