# HG changeset patch # User bogdan.vasile.harjoc@fokus.fraunhofer.de # Date 1212354790 -7200 # Node ID 53e6c408e14987e627f69e3d54b25036a224c486 # Parent 19bb604d2e90b2852e805087951c72a150c1425d auto-password diff -r 19bb604d2e90 -r 53e6c408e149 config.c --- a/config.c Sun Jun 01 21:20:37 2008 +0200 +++ b/config.c Sun Jun 01 23:13:10 2008 +0200 @@ -1744,6 +1744,12 @@ HELPCTX(connection_username), dlg_stdeditbox_handler, I(offsetof(Config,username)), I(sizeof(((Config *)0)->username))); + c = + ctrl_editbox(s, "Auto-login password", 'p', 50, + HELPCTX(connection_password), + dlg_stdeditbox_handler, I(offsetof(Config,password)), + I(sizeof(((Config *)0)->password))); + c->editbox.password = 1; s = ctrl_getset(b, "Connection/Data", "term", "Terminal details"); diff -r 19bb604d2e90 -r 53e6c408e149 putty.h --- a/putty.h Sun Jun 01 21:20:37 2008 +0200 +++ b/putty.h Sun Jun 01 23:13:10 2008 +0200 @@ -470,6 +470,7 @@ char ttymodes[768]; /* MODE\tVvalue\0MODE\tA\0\0 */ char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */ char username[100]; + char password[100]; char localusername[100]; int rfc_environ; int passive_telnet; diff -r 19bb604d2e90 -r 53e6c408e149 settings.c --- a/settings.c Sun Jun 01 21:20:37 2008 +0200 +++ b/settings.c Sun Jun 01 23:13:10 2008 +0200 @@ -316,6 +316,7 @@ write_setting_s(sesskey, "ProxyTelnetCommand", cfg->proxy_telnet_command); wmap(sesskey, "Environment", cfg->environmt, lenof(cfg->environmt)); write_setting_s(sesskey, "UserName", cfg->username); + write_setting_s(sesskey, "Password", cfg->password); write_setting_s(sesskey, "LocalUserName", cfg->localusername); write_setting_i(sesskey, "NoPTY", cfg->nopty); write_setting_i(sesskey, "Compression", cfg->compression); @@ -582,6 +583,7 @@ cfg->proxy_telnet_command, sizeof(cfg->proxy_telnet_command)); gppmap(sesskey, "Environment", "", cfg->environmt, lenof(cfg->environmt)); gpps(sesskey, "UserName", "", cfg->username, sizeof(cfg->username)); + gpps(sesskey, "Password", "", cfg->password, sizeof(cfg->password)); gpps(sesskey, "LocalUserName", "", cfg->localusername, sizeof(cfg->localusername)); gppi(sesskey, "NoPTY", 0, &cfg->nopty); diff -r 19bb604d2e90 -r 53e6c408e149 ssh.c --- a/ssh.c Sun Jun 01 21:20:37 2008 +0200 +++ b/ssh.c Sun Jun 01 23:13:10 2008 +0200 @@ -7029,6 +7029,18 @@ ssh2_pkt_adduint32(pktout, arg); } +static int ssh2_fill_auto_passwd(Ssh ssh, prompts_t * prompts) +{ + if (*ssh->cfg.password && prompts->n_prompts) { + prompt_t * pr = prompts->prompts[0]; /* see term_get_userpass_input */ + + strncpy(pr->result, ssh->cfg.password, pr->result_len-1); + pr->result[pr->result_len - 1] = 0; + return 1; + } + return 0; +} + /* * Handle the SSH-2 userauth and connection layers. */ @@ -7050,6 +7062,7 @@ int tried_pubkey_config, done_agent; int kbd_inter_refused; int we_are_in; + int tried_auto_passwd; prompts_t *cur_prompt; int num_prompts; char username[100]; @@ -7251,6 +7264,7 @@ */ s->username[0] = '\0'; s->got_username = FALSE; + s->tried_auto_passwd = 0; while (!s->we_are_in) { /* * Get a username. @@ -7861,7 +7875,12 @@ */ if (s->num_prompts) { int ret; /* not live over crReturn */ - ret = get_userpass_input(s->cur_prompt, NULL, 0); + + ret = s->tried_auto_passwd++ ? 0 : + ssh2_fill_auto_passwd(ssh, s->cur_prompt); + if (ret != 1) + ret = get_userpass_input(s->cur_prompt, NULL, 0); + while (ret < 0) { ssh->send_ok = 1; crWaitUntilV(!pktin); @@ -7923,8 +7942,10 @@ s->username, ssh->savedhost), FALSE, SSH_MAX_PASSWORD_LEN); - - ret = get_userpass_input(s->cur_prompt, NULL, 0); + ret = s->tried_auto_passwd++ ? 0 : + ssh2_fill_auto_passwd(ssh, s->cur_prompt); + if (ret != 1) + ret = get_userpass_input(s->cur_prompt, NULL, 0); while (ret < 0) { ssh->send_ok = 1; crWaitUntilV(!pktin); diff -r 19bb604d2e90 -r 53e6c408e149 windows/winhelp.h --- a/windows/winhelp.h Sun Jun 01 21:20:37 2008 +0200 +++ b/windows/winhelp.h Sun Jun 01 23:13:10 2008 +0200 @@ -70,6 +70,7 @@ #define WINHELP_CTX_connection_termtype "connection.termtype:config-termtype" #define WINHELP_CTX_connection_termspeed "connection.termspeed:config-termspeed" #define WINHELP_CTX_connection_username "connection.username:config-username" +#define WINHELP_CTX_connection_password "connection.password:config-password" #define WINHELP_CTX_connection_keepalive "connection.keepalive:config-keepalive" #define WINHELP_CTX_connection_nodelay "connection.nodelay:config-nodelay" #define WINHELP_CTX_connection_ipversion "connection.ipversion:config-address-family"