X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/04c52f109b8c4849d75c21898bdc63fdceea2a00..4e95a413c2909c807226e5efc09da4c8ba24740e:/settings.c diff --git a/settings.c b/settings.c index c4804864..c2fd1b4e 100644 --- a/settings.c +++ b/settings.c @@ -18,6 +18,7 @@ static const struct keyval ciphernames[] = { { "blowfish", CIPHER_BLOWFISH }, { "3des", CIPHER_3DES }, { "WARN", CIPHER_WARN }, + { "arcfour", CIPHER_ARCFOUR }, { "des", CIPHER_DES } }; @@ -28,6 +29,27 @@ static const struct keyval kexnames[] = { { "WARN", KEX_WARN } }; +/* + * All the terminal modes that we know about for the "TerminalModes" + * setting. (Also used by config.c for the drop-down list.) + * This is currently precisely the same as the set in ssh.c, but could + * in principle differ if other backends started to support tty modes + * (e.g., the pty backend). + */ +const char *const ttymodes[] = { + "INTR", "QUIT", "ERASE", "KILL", "EOF", + "EOL", "EOL2", "START", "STOP", "SUSP", + "DSUSP", "REPRINT", "WERASE", "LNEXT", "FLUSH", + "SWTCH", "STATUS", "DISCARD", "IGNPAR", "PARMRK", + "INPCK", "ISTRIP", "INLCR", "IGNCR", "ICRNL", + "IUCLC", "IXON", "IXANY", "IXOFF", "IMAXBEL", + "ISIG", "ICANON", "XCASE", "ECHO", "ECHOE", + "ECHOK", "ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", + "ECHOCTL", "ECHOKE", "PENDIN", "OPOST", "OLCUC", + "ONLCR", "OCRNL", "ONOCR", "ONLRET", "CS7", + "CS8", "PARENB", "PARODD", NULL +}; + static void gpps(void *handle, const char *name, const char *def, char *val, int len) { @@ -68,6 +90,61 @@ static void gppi(void *handle, char *name, int def, int *i) *i = read_setting_i(handle, name, def); } +/* + * Read a set of name-value pairs in the format we occasionally use: + * NAME\tVALUE\0NAME\tVALUE\0\0 in memory + * NAME=VALUE,NAME=VALUE, in storage + * `def' is in the storage format. + */ +static void gppmap(void *handle, char *name, char *def, char *val, int len) +{ + char *buf = snewn(2*len, char), *p, *q; + gpps(handle, name, def, buf, 2*len); + p = buf; + q = val; + while (*p) { + while (*p && *p != ',') { + int c = *p++; + if (c == '=') + c = '\t'; + if (c == '\\') + c = *p++; + *q++ = c; + } + if (*p == ',') + p++; + *q++ = '\0'; + } + *q = '\0'; + sfree(buf); +} + +/* + * Write a set of name/value pairs in the above format. + */ +static void wmap(void *handle, char const *key, char const *value, int len) +{ + char *buf = snewn(2*len, char), *p; + const char *q; + p = buf; + q = value; + while (*q) { + while (*q) { + int c = *q++; + if (c == '=' || c == ',' || c == '\\') + *p++ = '\\'; + if (c == '\t') + c = '='; + *p++ = c; + } + *p++ = ','; + q++; + } + *p = '\0'; + write_setting_s(handle, key, buf); + sfree(buf); +} + static int key2val(const struct keyval *mapping, int nmaps, char *key) { int i; @@ -196,6 +273,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg) write_setting_i(sesskey, "TCPKeepalives", cfg->tcp_keepalives); write_setting_s(sesskey, "TerminalType", cfg->termtype); write_setting_s(sesskey, "TerminalSpeed", cfg->termspeed); + wmap(sesskey, "TerminalModes", cfg->ttymodes, lenof(cfg->ttymodes)); /* Address family selection */ write_setting_i(sesskey, "AddressFamily", cfg->addressfamily); @@ -210,26 +288,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg) write_setting_s(sesskey, "ProxyUsername", cfg->proxy_username); write_setting_s(sesskey, "ProxyPassword", cfg->proxy_password); write_setting_s(sesskey, "ProxyTelnetCommand", cfg->proxy_telnet_command); - - { - char buf[2 * sizeof(cfg->environmt)], *p, *q; - p = buf; - q = cfg->environmt; - while (*q) { - while (*q) { - int c = *q++; - if (c == '=' || c == ',' || c == '\\') - *p++ = '\\'; - if (c == '\t') - c = '='; - *p++ = c; - } - *p++ = ','; - q++; - } - *p = '\0'; - write_setting_s(sesskey, "Environment", buf); - } + wmap(sesskey, "Environment", cfg->environmt, lenof(cfg->environmt)); write_setting_s(sesskey, "UserName", cfg->username); write_setting_s(sesskey, "LocalUserName", cfg->localusername); write_setting_i(sesskey, "NoPTY", cfg->nopty); @@ -241,6 +300,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg) wprefs(sesskey, "KEX", kexnames, KEX_MAX, cfg->ssh_kexlist); write_setting_i(sesskey, "RekeyTime", cfg->ssh_rekey_time); write_setting_s(sesskey, "RekeyBytes", cfg->ssh_rekey_data); + write_setting_i(sesskey, "SshNoAuth", cfg->ssh_no_userauth); write_setting_i(sesskey, "AuthTIS", cfg->try_tis_auth); write_setting_i(sesskey, "AuthKI", cfg->try_ki_auth); write_setting_i(sesskey, "SshNoShell", cfg->ssh_no_shell); @@ -339,6 +399,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg) write_setting_s(sesskey, buf, buf2); } write_setting_s(sesskey, "LineCodePage", cfg->line_codepage); + write_setting_i(sesskey, "CJKAmbigWide", cfg->cjk_ambig_wide); write_setting_i(sesskey, "UTF8Override", cfg->utf8_override); write_setting_s(sesskey, "Printer", cfg->printer); write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr); @@ -355,25 +416,7 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg) write_setting_i(sesskey, "X11AuthType", cfg->x11_auth); write_setting_i(sesskey, "LocalPortAcceptAll", cfg->lport_acceptall); write_setting_i(sesskey, "RemotePortAcceptAll", cfg->rport_acceptall); - { - char buf[2 * sizeof(cfg->portfwd)], *p, *q; - p = buf; - q = cfg->portfwd; - while (*q) { - while (*q) { - int c = *q++; - if (c == '=' || c == ',' || c == '\\') - *p++ = '\\'; - if (c == '\t') - c = '='; - *p++ = c; - } - *p++ = ','; - q++; - } - *p = '\0'; - write_setting_s(sesskey, "PortForwardings", buf); - } + wmap(sesskey, "PortForwardings", cfg->portfwd, lenof(cfg->portfwd)); write_setting_i(sesskey, "BugIgnore1", 2-cfg->sshbug_ignore1); write_setting_i(sesskey, "BugPlainPW1", 2-cfg->sshbug_plainpw1); write_setting_i(sesskey, "BugRSA1", 2-cfg->sshbug_rsa1); @@ -451,6 +494,21 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) sizeof(cfg->termtype)); gpps(sesskey, "TerminalSpeed", "38400,38400", cfg->termspeed, sizeof(cfg->termspeed)); + { + /* This hardcodes a big set of defaults in any new saved + * sessions. Let's hope we don't change our mind. */ + int i; + char *def = dupstr(""); + /* Default: all set to "auto" */ + for (i = 0; ttymodes[i]; i++) { + char *def2 = dupprintf("%s%s=A,", def, ttymodes[i]); + sfree(def); + def = def2; + } + gppmap(sesskey, "TerminalModes", def, + cfg->ttymodes, lenof(cfg->ttymodes)); + sfree(def); + } /* proxy settings */ gpps(sesskey, "ProxyExcludeList", "", cfg->proxy_exclude_list, @@ -486,27 +544,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) sizeof(cfg->proxy_password)); gpps(sesskey, "ProxyTelnetCommand", "connect %host %port\\n", cfg->proxy_telnet_command, sizeof(cfg->proxy_telnet_command)); - - { - char buf[2 * sizeof(cfg->environmt)], *p, *q; - gpps(sesskey, "Environment", "", buf, sizeof(buf)); - p = buf; - q = cfg->environmt; - while (*p) { - while (*p && *p != ',') { - int c = *p++; - if (c == '=') - c = '\t'; - if (c == '\\') - c = *p++; - *q++ = c; - } - if (*p == ',') - p++; - *q++ = '\0'; - } - *q = '\0'; - } + gppmap(sesskey, "Environment", "", cfg->environmt, lenof(cfg->environmt)); gpps(sesskey, "UserName", "", cfg->username, sizeof(cfg->username)); gpps(sesskey, "LocalUserName", "", cfg->localusername, sizeof(cfg->localusername)); @@ -535,6 +573,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) sizeof(cfg->ssh_rekey_data)); gppi(sesskey, "SshProt", 2, &cfg->sshprot); gppi(sesskey, "SSH2DES", 0, &cfg->ssh2_des_cbc); + gppi(sesskey, "SshNoAuth", 0, &cfg->ssh_no_userauth); gppi(sesskey, "AuthTIS", 0, &cfg->try_tis_auth); gppi(sesskey, "AuthKI", 1, &cfg->try_ki_auth); gppi(sesskey, "SshNoShell", 0, &cfg->ssh_no_shell); @@ -666,6 +705,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) */ gpps(sesskey, "LineCodePage", "", cfg->line_codepage, sizeof(cfg->line_codepage)); + gppi(sesskey, "CJKAmbigWide", 0, &cfg->cjk_ambig_wide); gppi(sesskey, "UTF8Override", 1, &cfg->utf8_override); gpps(sesskey, "Printer", "", cfg->printer, sizeof(cfg->printer)); gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr); @@ -684,26 +724,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) gppi(sesskey, "LocalPortAcceptAll", 0, &cfg->lport_acceptall); gppi(sesskey, "RemotePortAcceptAll", 0, &cfg->rport_acceptall); - { - char buf[2 * sizeof(cfg->portfwd)], *p, *q; - gpps(sesskey, "PortForwardings", "", buf, sizeof(buf)); - p = buf; - q = cfg->portfwd; - while (*p) { - while (*p && *p != ',') { - int c = *p++; - if (c == '=') - c = '\t'; - if (c == '\\') - c = *p++; - *q++ = c; - } - if (*p == ',') - p++; - *q++ = '\0'; - } - *q = '\0'; - } + gppmap(sesskey, "PortForwardings", "", cfg->portfwd, lenof(cfg->portfwd)); gppi(sesskey, "BugIgnore1", 0, &i); cfg->sshbug_ignore1 = 2-i; gppi(sesskey, "BugPlainPW1", 0, &i); cfg->sshbug_plainpw1 = 2-i; gppi(sesskey, "BugRSA1", 0, &i); cfg->sshbug_rsa1 = 2-i; @@ -816,5 +837,7 @@ void get_sesslist(struct sesslist *list, int allocate) } else { sfree(list->buffer); sfree(list->sessions); + list->buffer = NULL; + list->sessions = NULL; } }