| 481 |
} |
} |
| 482 |
|
|
| 483 |
static void write_ssh_options(PTInstVar pvar, PCHAR fileName, |
static void write_ssh_options(PTInstVar pvar, PCHAR fileName, |
| 484 |
TS_SSH FAR * settings, BOOL copy_forward) |
TS_SSH FAR * settings, BOOL copy_forward) |
| 485 |
{ |
{ |
| 486 |
char buf[1024]; |
char buf[1024]; |
| 487 |
|
|
| 1004 |
// サブクラス化するためのウインドウプロシージャ |
// サブクラス化するためのウインドウプロシージャ |
| 1005 |
WNDPROC OrigHostnameEditProc; // Original window procedure |
WNDPROC OrigHostnameEditProc; // Original window procedure |
| 1006 |
LRESULT CALLBACK HostnameEditProc(HWND dlg, UINT msg, |
LRESULT CALLBACK HostnameEditProc(HWND dlg, UINT msg, |
| 1007 |
WPARAM wParam, LPARAM lParam) |
WPARAM wParam, LPARAM lParam) |
| 1008 |
{ |
{ |
| 1009 |
HWND parent; |
HWND parent; |
| 1010 |
int max, select, len; |
int max, select, len; |
| 1594 |
FWDUI_load_settings(pvar); |
FWDUI_load_settings(pvar); |
| 1595 |
} |
} |
| 1596 |
|
|
|
#ifdef USE_ATCMDLINE |
|
|
// @をブランクに置換する。 (2005.1.26 yutaka) |
|
|
static void replace_to_blank(char *src, char *dst, int dst_len) |
|
|
{ |
|
|
int len, i; |
|
|
|
|
|
len = strlen(src); |
|
|
if (dst_len < len) // buffer overflow check |
|
|
return; |
|
|
|
|
|
for (i = 0 ; i < len ; i++) { |
|
|
if (src[i] == '@') { // @ が登場したら |
|
|
if (i < len - 1 && src[i + 1] == '@') { // その次も @ ならアットマークと認識する |
|
|
*dst++ = '@'; |
|
|
i++; |
|
|
} else { |
|
|
*dst++ = ' '; // 空白に置き換える |
|
|
} |
|
|
} else { |
|
|
*dst++ = src[i]; |
|
|
} |
|
|
} |
|
|
*dst = '\0'; |
|
|
} |
|
|
#endif |
|
|
|
|
| 1597 |
// Percent-encodeされた文字列srcをデコードしてdstにコピーする。 |
// Percent-encodeされた文字列srcをデコードしてdstにコピーする。 |
| 1598 |
// dstlenはdstのサイズ。これより結果が長い場合、その分は切り捨てられる。 |
// dstlenはdstのサイズ。これより結果が長い場合、その分は切り捨てられる。 |
| 1599 |
static void percent_decode(char *dst, int dstlen, char *src) { |
static void percent_decode(char *dst, int dstlen, char *src) { |
| 1791 |
} |
} |
| 1792 |
|
|
| 1793 |
} else if (MATCH_STR(option + 1, "user=") == 0) { |
} else if (MATCH_STR(option + 1, "user=") == 0) { |
|
#ifdef USE_ATCMDLINE |
|
|
replace_to_blank(option + 6, pvar->ssh2_username, sizeof(pvar->ssh2_username)); |
|
|
//_snprintf(pvar->ssh2_username, sizeof(pvar->ssh2_username), "%s", option + 6); |
|
|
|
|
|
#else |
|
| 1794 |
_snprintf_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), _TRUNCATE, "%s", option + 6); |
_snprintf_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), _TRUNCATE, "%s", option + 6); |
|
#endif |
|
| 1795 |
|
|
| 1796 |
} else if (MATCH_STR(option + 1, "passwd=") == 0) { |
} else if (MATCH_STR(option + 1, "passwd=") == 0) { |
|
#ifdef USE_ATCMDLINE |
|
|
replace_to_blank(option + 8, pvar->ssh2_password, sizeof(pvar->ssh2_password)); |
|
|
//_snprintf(pvar->ssh2_password, sizeof(pvar->ssh2_password), "%s", option + 8); |
|
|
#else |
|
| 1797 |
_snprintf_s(pvar->ssh2_password, sizeof(pvar->ssh2_password), _TRUNCATE, "%s", option + 8); |
_snprintf_s(pvar->ssh2_password, sizeof(pvar->ssh2_password), _TRUNCATE, "%s", option + 8); |
|
#endif |
|
| 1798 |
|
|
| 1799 |
} else if (MATCH_STR(option + 1, "keyfile=") == 0) { |
} else if (MATCH_STR(option + 1, "keyfile=") == 0) { |
|
#ifdef USE_ATCMDLINE |
|
|
replace_to_blank(option + 9, pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile)); |
|
|
#else |
|
| 1800 |
_snprintf_s(pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile), _TRUNCATE, "%s", option + 9); |
_snprintf_s(pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile), _TRUNCATE, "%s", option + 9); |
|
#endif |
|
| 1801 |
|
|
| 1802 |
} else if (MATCH_STR(option + 1, "ask4passwd") == 0) { |
} else if (MATCH_STR(option + 1, "ask4passwd") == 0) { |
| 1803 |
// パスワードを聞く (2006.9.18 maya) |
// パスワードを聞く (2006.9.18 maya) |
| 1925 |
static void FAR PASCAL TTXParseParam(PCHAR param, PTTSet ts, |
static void FAR PASCAL TTXParseParam(PCHAR param, PTTSet ts, |
| 1926 |
PCHAR DDETopic) |
PCHAR DDETopic) |
| 1927 |
{ |
{ |
|
#ifndef USE_ATCMDLINE |
|
| 1928 |
int i; |
int i; |
| 1929 |
BOOL inParam = FALSE; |
BOOL inParam = FALSE; |
| 1930 |
BOOL inQuotes = FALSE; |
BOOL inQuotes = FALSE; |
| 2040 |
} |
} |
| 2041 |
} |
} |
| 2042 |
free(buf); |
free(buf); |
|
#else |
|
|
// スペースを含むファイル名を認識するように修正 (2006.10.7 maya) |
|
|
int i, buflen; |
|
|
BOOL inParam = FALSE; |
|
|
BOOL inQuotes = FALSE; |
|
|
BOOL inFileParam = FALSE; |
|
|
PCHAR option = NULL; |
|
|
|
|
|
if (pvar->hostdlg_activated) { |
|
|
pvar->settings.Enabled = pvar->hostdlg_Enabled; |
|
|
} |
|
|
|
|
|
for (i = 0; param[i] != 0; i++) { |
|
|
if (inQuotes ? param[i] == '"' |
|
|
: (param[i] == ' ' || param[i] == '\t')) { |
|
|
if (option != NULL) { |
|
|
char ch = param[i]; |
|
|
PCHAR Equal; |
|
|
|
|
|
param[i] = 0; |
|
|
Equal = strchr(option, '='); |
|
|
if (inFileParam && Equal != NULL && *(Equal + 1) == '"') { |
|
|
int buf_len = strlen(option) * sizeof(char); |
|
|
char *buf = (char *)calloc(strlen(option), sizeof(char)); |
|
|
char c = option[Equal - option + 1]; |
|
|
option[Equal - option + 1] = 0; |
|
|
strncat_s(buf, buf_len, option, _TRUNCATE); |
|
|
option[Equal - option + 1] = c; |
|
|
strncat_s(buf, buf_len, Equal + 2, _TRUNCATE); |
|
|
switch (parse_option(pvar, *buf == '"' ? buf + 1 : buf)) { |
|
|
case OPTION_CLEAR: |
|
|
memset(option, ' ', i + 1 - (option - param)); |
|
|
break; |
|
|
case OPTION_REPLACE: |
|
|
buflen = strlen(buf); |
|
|
memcpy(option, buf, buflen); |
|
|
memset(option + buflen, ' ', i + 1 - buflen - (option - param)); |
|
|
break; |
|
|
default: |
|
|
param[i] = ch; |
|
|
} |
|
|
free(buf); |
|
|
} |
|
|
else { |
|
|
switch (parse_option(pvar, *option == '"' ? option + 1 : option)) { |
|
|
case OPTION_CLEAR: |
|
|
memset(option, ' ', i + 1 - (option - param)); |
|
|
break; |
|
|
default: |
|
|
param[i] = ch; |
|
|
} |
|
|
} |
|
|
option = NULL; |
|
|
} |
|
|
inParam = FALSE; |
|
|
inQuotes = FALSE; |
|
|
inFileParam = FALSE; |
|
|
} else if (!inParam) { |
|
|
if (param[i] == '"') { |
|
|
inQuotes = TRUE; |
|
|
inParam = TRUE; |
|
|
option = param + i; |
|
|
} else if (param[i] != ' ' && param[i] != '\t') { |
|
|
inParam = TRUE; |
|
|
option = param + i; |
|
|
} |
|
|
} else { |
|
|
if (option == NULL) { |
|
|
continue; |
|
|
} |
|
|
if ((option[0] == '-' || option[0] == '/') && |
|
|
(MATCH_STR(option + 1, "ssh-f=") == 0 || // ttssh option |
|
|
MATCH_STR(option + 1, "ssh-consume=") == 0 || // ttssh option |
|
|
MATCH_STR_I(option + 1, "f=") == 0 || // Tera Term option |
|
|
MATCH_STR_I(option + 1, "fd=") == 0 || // Tera Term option |
|
|
MATCH_STR_I(option + 1, "k=") == 0 || // Tera Term option |
|
|
MATCH_STR_I(option + 1, "l=") == 0 || // Tera Term option |
|
|
MATCH_STR_I(option + 1, "m=") == 0 || // Tera Term option |
|
|
MATCH_STR_I(option + 1, "r=") == 0 || // Tera Term option |
|
|
MATCH_STR_I(option + 1, "w=") == 0 || // Tera Term option |
|
|
MATCH_STR(option + 1, "keyfile=") == 0)) { // ttssh option |
|
|
if (param[i] == '"') { |
|
|
inQuotes = TRUE; |
|
|
} |
|
|
inFileParam = TRUE; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (option != NULL) { |
|
|
PCHAR Equal = strchr(option, '='); |
|
|
if (inFileParam && Equal != NULL && *(Equal + 1) == '"') { |
|
|
int buf_len = strlen(option) * sizeof(char); |
|
|
char *buf = (char *)calloc(strlen(option), sizeof(char)); |
|
|
char c = option[Equal - option + 1]; |
|
|
option[Equal - option + 1] = 0; |
|
|
strncat_s(buf, buf_len, option, _TRUNCATE); |
|
|
option[Equal - option + 1] = c; |
|
|
strncat_s(buf, buf_len, Equal + 2, _TRUNCATE); |
|
|
switch (parse_option(pvar, *buf == '"' ? buf + 1 : buf)) { |
|
|
case OPTION_CLEAR: |
|
|
memset(option, ' ', i + 1 - (option - param)); |
|
|
break; |
|
|
case OPTION_REPLACE: |
|
|
strcpy_s(option, i - (param - option), buf); |
|
|
break; |
|
|
} |
|
|
free(buf); |
|
|
} |
|
|
else { |
|
|
switch (parse_option(pvar, option)) { |
|
|
case OPTION_CLEAR: |
|
|
memset(option, ' ', i - (option - param)); |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
#endif |
|
| 2043 |
|
|
| 2044 |
FWDUI_load_settings(pvar); |
FWDUI_load_settings(pvar); |
| 2045 |
|
|
| 5225 |
strncpy_s(dst, dst_len, str, _TRUNCATE); |
strncpy_s(dst, dst_len, str, _TRUNCATE); |
| 5226 |
} |
} |
| 5227 |
|
|
|
#ifdef USE_ATCMDLINE |
|
|
// 以下はTeraTerm Menuのコード(ttpmenu.cpp)と同一。 |
|
|
// 空白を @ に置き換える。@自身は@@にする。(2005.1.28 yutaka) |
|
|
static void replace_blank_to_mark(char *str, char *dst, int dst_len) |
|
|
{ |
|
|
int i, len, n; |
|
|
|
|
|
len = strlen(str); |
|
|
n = 0; |
|
|
for (i = 0 ; i < len ; i++) { |
|
|
if (str[i] == '@') |
|
|
n++; |
|
|
} |
|
|
if (dst_len < (len + 2*n)) |
|
|
return; |
|
|
|
|
|
for (i = 0 ; i < len ; i++) { |
|
|
if (str[i] == '@') { |
|
|
*dst++ = '@'; |
|
|
*dst++ = '@'; |
|
|
|
|
|
} else if (str[i] == ' ') { |
|
|
*dst++ = '@'; |
|
|
|
|
|
} else { |
|
|
*dst++ = str[i]; |
|
|
|
|
|
} |
|
|
} |
|
|
*dst = '\0'; |
|
|
|
|
|
} |
|
|
#endif |
|
|
|
|
| 5228 |
static void PASCAL FAR TTXSetCommandLine(PCHAR cmd, int cmdlen, |
static void PASCAL FAR TTXSetCommandLine(PCHAR cmd, int cmdlen, |
| 5229 |
PGetHNRec rec) |
PGetHNRec rec) |
| 5230 |
{ |
{ |
| 5231 |
char tmpFile[MAX_PATH]; |
char tmpFile[MAX_PATH]; |
| 5232 |
char tmpPath[1024]; |
char tmpPath[1024]; |
| 5300 |
// パスワードを覚えている場合のみ、コマンドラインに渡す。(2006.8.3 yutaka) |
// パスワードを覚えている場合のみ、コマンドラインに渡す。(2006.8.3 yutaka) |
| 5301 |
if (pvar->settings.remember_password && |
if (pvar->settings.remember_password && |
| 5302 |
pvar->auth_state.cur_cred.method == SSH_AUTH_PASSWORD) { |
pvar->auth_state.cur_cred.method == SSH_AUTH_PASSWORD) { |
|
#ifdef USE_ATCMDLINE |
|
|
replace_blank_to_mark(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
|
|
#else |
|
| 5303 |
dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
|
#endif |
|
| 5304 |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
| 5305 |
" /auth=password /user=%s /passwd=%s", pvar->auth_state.user, mark); |
" /auth=password /user=%s /passwd=%s", pvar->auth_state.user, mark); |
| 5306 |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
| 5307 |
|
|
| 5308 |
} else if (pvar->settings.remember_password && |
} else if (pvar->settings.remember_password && |
| 5309 |
pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) { |
pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) { |
|
#ifdef USE_ATCMDLINE |
|
|
replace_blank_to_mark(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
|
|
#else |
|
| 5310 |
dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
|
#endif |
|
| 5311 |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
| 5312 |
" /auth=publickey /user=%s /passwd=%s", pvar->auth_state.user, mark); |
" /auth=publickey /user=%s /passwd=%s", pvar->auth_state.user, mark); |
| 5313 |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
| 5314 |
|
|
|
#ifdef USE_ATCMDLINE |
|
|
replace_blank_to_mark(pvar->session_settings.DefaultRSAPrivateKeyFile, mark, sizeof(mark)); |
|
|
#else |
|
| 5315 |
dquote_string(pvar->session_settings.DefaultRSAPrivateKeyFile, mark, sizeof(mark)); |
dquote_string(pvar->session_settings.DefaultRSAPrivateKeyFile, mark, sizeof(mark)); |
|
#endif |
|
| 5316 |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, " /keyfile=%s", mark); |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, " /keyfile=%s", mark); |
| 5317 |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
| 5318 |
|
|
| 5319 |
} else if (pvar->settings.remember_password && |
} else if (pvar->settings.remember_password && |
| 5320 |
pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) { |
pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) { |
|
#ifdef USE_ATCMDLINE |
|
|
replace_blank_to_mark(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
|
|
#else |
|
| 5321 |
dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); |
|
#endif |
|
| 5322 |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
| 5323 |
" /auth=challenge /user=%s /passwd=%s", pvar->auth_state.user, mark); |
" /auth=challenge /user=%s /passwd=%s", pvar->auth_state.user, mark); |
| 5324 |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |
strncat_s(cmd, cmdlen, tmp, _TRUNCATE); |