diff options
author | Volker Lendecke <vl@samba.org> | 2008-12-14 13:06:19 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-12-14 14:00:43 +0100 |
commit | daeb3a190d16a5bc05be63b2b136ebe65d6f6cf7 (patch) | |
tree | 80ed13d20c756a84b645257d7fcc63e905a75b57 /source3/rpcclient | |
parent | 31f157a04b2f26537c9da4aa39bdcdde7b41e64b (diff) | |
download | samba-daeb3a190d16a5bc05be63b2b136ebe65d6f6cf7.tar.gz samba-daeb3a190d16a5bc05be63b2b136ebe65d6f6cf7.tar.bz2 samba-daeb3a190d16a5bc05be63b2b136ebe65d6f6cf7.zip |
Remove the global "cmdline_auth_info" from source3/lib/util.c
This involves changing all our clients, that's why it's so large.
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 10 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 50 |
2 files changed, 37 insertions, 23 deletions
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 26a73203b9..038acfbcdc 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -2641,6 +2641,8 @@ done: /**************************************************************************** ****************************************************************************/ +extern struct user_auth_info *rpcclient_auth_info; + static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -2671,11 +2673,11 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli, nt_status = cli_full_connection(&cli_server2, global_myname(), servername2, NULL, 0, "IPC$", "IPC", - get_cmdline_auth_info_username(), + get_cmdline_auth_info_username(rpcclient_auth_info), lp_workgroup(), - get_cmdline_auth_info_password(), - get_cmdline_auth_info_use_kerberos() ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, - get_cmdline_auth_info_signing_state(), NULL); + get_cmdline_auth_info_password(rpcclient_auth_info), + get_cmdline_auth_info_use_kerberos(rpcclient_auth_info) ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, + get_cmdline_auth_info_signing_state(rpcclient_auth_info), NULL); if ( !NT_STATUS_IS_OK(nt_status) ) return WERR_GENERAL_FAILURE; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index e8ffddb6dc..dc125007e3 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -28,6 +28,8 @@ static enum pipe_auth_type pipe_default_auth_type = PIPE_AUTH_TYPE_NONE; static enum pipe_auth_level pipe_default_auth_level = PIPE_AUTH_LEVEL_NONE; static unsigned int timeout = 0; +struct user_auth_info *rpcclient_auth_info; + /* List to hold groups of commands. * * Commands are defined in a list of arrays: arrays are easy to @@ -560,6 +562,7 @@ static void add_command_set(struct cmd_set *cmd_set) * @param cmd Command to run, as a single string. **/ static NTSTATUS do_cmd(struct cli_state *cli, + struct user_auth_info *auth_info, struct cmd_set *cmd_entry, int argc, char **argv) { @@ -589,8 +592,8 @@ static NTSTATUS do_cmd(struct cli_state *cli, cli, cmd_entry->interface, pipe_default_auth_level, lp_workgroup(), - get_cmdline_auth_info_username(), - get_cmdline_auth_info_password(), + get_cmdline_auth_info_username(auth_info), + get_cmdline_auth_info_password(auth_info), &cmd_entry->rpc_pipe); break; case PIPE_AUTH_TYPE_NTLMSSP: @@ -598,8 +601,8 @@ static NTSTATUS do_cmd(struct cli_state *cli, cli, cmd_entry->interface, pipe_default_auth_level, lp_workgroup(), - get_cmdline_auth_info_username(), - get_cmdline_auth_info_password(), + get_cmdline_auth_info_username(auth_info), + get_cmdline_auth_info_password(auth_info), &cmd_entry->rpc_pipe); break; case PIPE_AUTH_TYPE_SCHANNEL: @@ -687,7 +690,8 @@ static NTSTATUS do_cmd(struct cli_state *cli, * * @returns The NTSTATUS from running the command. **/ -static NTSTATUS process_cmd(struct cli_state *cli, char *cmd) +static NTSTATUS process_cmd(struct user_auth_info *auth_info, + struct cli_state *cli, char *cmd) { struct cmd_list *temp_list; NTSTATUS result = NT_STATUS_OK; @@ -713,7 +717,8 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd) goto out_free; } - result = do_cmd(cli, temp_set, argc, argv); + result = do_cmd(cli, auth_info, temp_set, + argc, argv); goto out_free; } @@ -784,6 +789,12 @@ out_free: facilities. See lib/debug.c */ setup_logging("rpcclient", True); + rpcclient_auth_info = user_auth_info_init(frame); + if (rpcclient_auth_info == NULL) { + exit(1); + } + popt_common_set_auth_info(rpcclient_auth_info); + /* Parse options */ pc = poptGetContext("rpcclient", argc, (const char **) argv, @@ -850,16 +861,16 @@ out_free: * from stdin if necessary */ - if (get_cmdline_auth_info_use_machine_account() && - !set_cmdline_auth_info_machine_account_creds()) { + if (get_cmdline_auth_info_use_machine_account(rpcclient_auth_info) && + !set_cmdline_auth_info_machine_account_creds(rpcclient_auth_info)) { result = 1; goto done; } - if (!get_cmdline_auth_info_got_pass()) { + if (!get_cmdline_auth_info_got_pass(rpcclient_auth_info)) { char *pass = getpass("Password:"); if (pass) { - set_cmdline_auth_info_password(pass); + set_cmdline_auth_info_password(rpcclient_auth_info, pass); } } @@ -868,7 +879,7 @@ out_free: server += 2; } - if (get_cmdline_auth_info_use_kerberos()) { + if (get_cmdline_auth_info_use_kerberos(rpcclient_auth_info)) { flags |= CLI_FULL_CONNECTION_USE_KERBEROS | CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS; } @@ -877,11 +888,12 @@ out_free: nt_status = cli_full_connection(&cli, global_myname(), server, opt_ipaddr ? &server_ss : NULL, opt_port, "IPC$", "IPC", - get_cmdline_auth_info_username(), + get_cmdline_auth_info_username(rpcclient_auth_info), lp_workgroup(), - get_cmdline_auth_info_password(), + get_cmdline_auth_info_password(rpcclient_auth_info), flags, - get_cmdline_auth_info_signing_state(),NULL); + get_cmdline_auth_info_signing_state(rpcclient_auth_info), + NULL); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0,("Cannot connect to server. Error was %s\n", nt_errstr(nt_status))); @@ -889,10 +901,10 @@ out_free: goto done; } - if (get_cmdline_auth_info_smb_encrypt()) { + if (get_cmdline_auth_info_smb_encrypt(rpcclient_auth_info)) { nt_status = cli_cm_force_encryption(cli, - get_cmdline_auth_info_username(), - get_cmdline_auth_info_password(), + get_cmdline_auth_info_username(rpcclient_auth_info), + get_cmdline_auth_info_password(rpcclient_auth_info), lp_workgroup(), "IPC$"); if (!NT_STATUS_IS_OK(nt_status)) { @@ -927,7 +939,7 @@ out_free: result = 0; while((cmd=next_command(&p)) != NULL) { - NTSTATUS cmd_result = process_cmd(cli, cmd); + NTSTATUS cmd_result = process_cmd(rpcclient_auth_info, cli, cmd); SAFE_FREE(cmd); result = NT_STATUS_IS_ERR(cmd_result); } @@ -946,7 +958,7 @@ out_free: break; if (line[0] != '\n') - process_cmd(cli, line); + process_cmd(rpcclient_auth_info, cli, line); SAFE_FREE(line); } |