Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/ttssh2/ttxssh/hosts.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2995 by maya, Wed Aug 15 04:03:26 2007 UTC revision 3003 by maya, Mon Aug 20 14:21:57 2007 UTC
# Line 142  void HOSTS_open(PTInstVar pvar) Line 142  void HOSTS_open(PTInstVar pvar)
142  // known_hostsファイルの内容をすべて pvar->hosts_state.file_data へ読み込む  // known_hostsファイルの内容をすべて pvar->hosts_state.file_data へ読み込む
143  //  //
144  static int begin_read_file(PTInstVar pvar, char FAR * name,  static int begin_read_file(PTInstVar pvar, char FAR * name,
145                                                     int suppress_errors)                             int suppress_errors)
146  {  {
147          int fd;          int fd;
148          int length;          int length;
# Line 155  static int begin_read_file(PTInstVar pva Line 155  static int begin_read_file(PTInstVar pva
155                  if (!suppress_errors) {                  if (!suppress_errors) {
156                          if (errno == ENOENT) {                          if (errno == ENOENT) {
157                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ENOENT_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ENOENT_ERROR", pvar,
158                                                                    "An error occurred while trying to read a known_hosts file.\n"                                                    "An error occurred while trying to read a known_hosts file.\n"
159                                                                    "The specified filename does not exist.");                                                    "The specified filename does not exist.");
160                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
161                          } else {                          } else {
162                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar,
163                                                                    "An error occurred while trying to read a known_hosts file.");                                                    "An error occurred while trying to read a known_hosts file.");
164                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
165                          }                          }
166                  }                  }
# Line 175  static int begin_read_file(PTInstVar pva Line 175  static int begin_read_file(PTInstVar pva
175                  if (pvar->hosts_state.file_data == NULL) {                  if (pvar->hosts_state.file_data == NULL) {
176                          if (!suppress_errors) {                          if (!suppress_errors) {
177                                  UTIL_get_lang_msg("MSG_HOSTS_ALLOC_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_ALLOC_ERROR", pvar,
178                                                                    "Memory ran out while trying to allocate space to read a known_hosts file.");                                                    "Memory ran out while trying to allocate space to read a known_hosts file.");
179                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
180                          }                          }
181                          _close(fd);                          _close(fd);
# Line 184  static int begin_read_file(PTInstVar pva Line 184  static int begin_read_file(PTInstVar pva
184          } else {          } else {
185                  if (!suppress_errors) {                  if (!suppress_errors) {
186                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar,                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar,
187                                                            "An error occurred while trying to read a known_hosts file.");                                            "An error occurred while trying to read a known_hosts file.");
188                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
189                  }                  }
190                  _close(fd);                  _close(fd);
# Line 199  static int begin_read_file(PTInstVar pva Line 199  static int begin_read_file(PTInstVar pva
199          if (amount_read != length) {          if (amount_read != length) {
200                  if (!suppress_errors) {                  if (!suppress_errors) {
201                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar,                          UTIL_get_lang_msg("MSG_HOSTS_READ_ERROR", pvar,
202                                                            "An error occurred while trying to read a known_hosts file.");                                            "An error occurred while trying to read a known_hosts file.");
203                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
204                  }                  }
205                  free(pvar->hosts_state.file_data);                  free(pvar->hosts_state.file_data);
# Line 500  static char FAR *parse_bignum(char FAR * Line 500  static char FAR *parse_bignum(char FAR *
500  // known_hostsファイルの内容を解析し、指定したホストの公開鍵を探す。  // known_hostsファイルの内容を解析し、指定したホストの公開鍵を探す。
501  //  //
502  static int check_host_key(PTInstVar pvar, char FAR * hostname,  static int check_host_key(PTInstVar pvar, char FAR * hostname,
503                                                    char FAR * data)                            char FAR * data)
504  {  {
505          int index = eat_spaces(data);          int index = eat_spaces(data);
506          int matched = 0;          int matched = 0;
# Line 621  static int check_host_key(PTInstVar pvar Line 621  static int check_host_key(PTInstVar pvar
621  // known_hostsファイルからホスト名に合致する行を読む  // known_hostsファイルからホスト名に合致する行を読む
622  //  //
623  static int read_host_key(PTInstVar pvar, char FAR * hostname,  static int read_host_key(PTInstVar pvar, char FAR * hostname,
624                                                   int suppress_errors, int return_always)                           int suppress_errors, int return_always)
625  {  {
626          int i;          int i;
627          int while_flg;          int while_flg;
# Line 632  static int read_host_key(PTInstVar pvar, Line 632  static int read_host_key(PTInstVar pvar,
632                  if (!is_pattern_char(ch) || ch == '*' || ch == '?') {                  if (!is_pattern_char(ch) || ch == '*' || ch == '?') {
633                          if (!suppress_errors) {                          if (!suppress_errors) {
634                                  UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_INVALID_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_INVALID_ERROR", pvar,
635                                                                    "The host name contains an invalid character.\n"                                                    "The host name contains an invalid character.\n"
636                                                                    "This session will be terminated.");                                                    "This session will be terminated.");
637                                  notify_fatal_error(pvar, pvar->ts->UIMsg);                                  notify_fatal_error(pvar, pvar->ts->UIMsg);
638                          }                          }
639                          return 0;                          return 0;
# Line 643  static int read_host_key(PTInstVar pvar, Line 643  static int read_host_key(PTInstVar pvar,
643          if (i == 0) {          if (i == 0) {
644                  if (!suppress_errors) {                  if (!suppress_errors) {
645                          UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_EMPTY_ERROR", pvar,                          UTIL_get_lang_msg("MSG_HOSTS_HOSTNAME_EMPTY_ERROR", pvar,
646                                                            "The host name should not be empty.\n"                                            "The host name should not be empty.\n"
647                                                            "This session will be terminated.");                                            "This session will be terminated.");
648                          notify_fatal_error(pvar, pvar->ts->UIMsg);                          notify_fatal_error(pvar, pvar->ts->UIMsg);
649                  }                  }
650                  return 0;                  return 0;
# Line 663  static int read_host_key(PTInstVar pvar, Line 663  static int read_host_key(PTInstVar pvar,
663    
664          do {          do {
665                  if (pvar->hosts_state.file_data == NULL                  if (pvar->hosts_state.file_data == NULL
666                          || pvar->hosts_state.file_data[pvar->hosts_state.                   || pvar->hosts_state.file_data[pvar->hosts_state.file_data_index] == 0) {
                                                                                    file_data_index] == 0) {  
667                          char FAR *filename;                          char FAR *filename;
668                          int keep_going = 1;                          int keep_going = 1;
669    
# Line 674  static int read_host_key(PTInstVar pvar, Line 673  static int read_host_key(PTInstVar pvar,
673    
674                          do {                          do {
675                                  filename =                                  filename =
676                                          pvar->hosts_state.file_names[pvar->hosts_state.                                          pvar->hosts_state.file_names[pvar->hosts_state.file_num];
                                                                                                  file_num];  
677    
678                                  if (filename == NULL) {                                  if (filename == NULL) {
679                                          return 1;                                          return 1;
# Line 683  static int read_host_key(PTInstVar pvar, Line 681  static int read_host_key(PTInstVar pvar,
681                                          pvar->hosts_state.file_num++;                                          pvar->hosts_state.file_num++;
682    
683                                          if (filename[0] != 0) {                                          if (filename[0] != 0) {
684                                                  if (begin_read_file                                                  if (begin_read_file(pvar, filename, suppress_errors)) {
                                                         (pvar, filename, suppress_errors)) {  
685                                                          pvar->hosts_state.file_data_index = 0;                                                          pvar->hosts_state.file_data_index = 0;
686                                                          keep_going = 0;                                                          keep_going = 0;
687                                                  }                                                  }
# Line 695  static int read_host_key(PTInstVar pvar, Line 692  static int read_host_key(PTInstVar pvar,
692    
693                  pvar->hosts_state.file_data_index +=                  pvar->hosts_state.file_data_index +=
694                          check_host_key(pvar, hostname,                          check_host_key(pvar, hostname,
695                                                     pvar->hosts_state.file_data +                                         pvar->hosts_state.file_data +
696                                                     pvar->hosts_state.file_data_index);                                         pvar->hosts_state.file_data_index);
697    
698                  if (!return_always) {                  if (!return_always) {
699                          // 有効なキーが見つかるまで                          // 有効なキーが見つかるまで
# Line 735  void HOSTS_prefetch_host_key(PTInstVar p Line 732  void HOSTS_prefetch_host_key(PTInstVar p
732  }  }
733    
734  static BOOL equal_mp_ints(unsigned char FAR * num1,  static BOOL equal_mp_ints(unsigned char FAR * num1,
735                                                    unsigned char FAR * num2)                            unsigned char FAR * num2)
736  {  {
737          if (num1 == NULL || num2 == NULL) {          if (num1 == NULL || num2 == NULL) {
738                  return FALSE;                  return FALSE;
# Line 764  static BOOL match_key(PTInstVar pvar, Ke Line 761  static BOOL match_key(PTInstVar pvar, Ke
761    
762                  /* just check for equal exponent and modulus */                  /* just check for equal exponent and modulus */
763                  return equal_mp_ints(exp, pvar->hosts_state.hostkey.exp)                  return equal_mp_ints(exp, pvar->hosts_state.hostkey.exp)
764                          && equal_mp_ints(mod, pvar->hosts_state.hostkey.mod);                      && equal_mp_ints(mod, pvar->hosts_state.hostkey.mod);
765                  /*                  /*
766                  return equal_mp_ints(exp, pvar->hosts_state.key_exp)                  return equal_mp_ints(exp, pvar->hosts_state.key_exp)
767                          && equal_mp_ints(mod, pvar->hosts_state.key_mod);                          && equal_mp_ints(mod, pvar->hosts_state.key_mod);
# Line 773  static BOOL match_key(PTInstVar pvar, Ke Line 770  static BOOL match_key(PTInstVar pvar, Ke
770          } else if (key->type == KEY_RSA) {  // SSH2 RSA host public key          } else if (key->type == KEY_RSA) {  // SSH2 RSA host public key
771    
772                  return key->rsa != NULL && pvar->hosts_state.hostkey.rsa != NULL &&                  return key->rsa != NULL && pvar->hosts_state.hostkey.rsa != NULL &&
773                             BN_cmp(key->rsa->e, pvar->hosts_state.hostkey.rsa->e) == 0 &&                         BN_cmp(key->rsa->e, pvar->hosts_state.hostkey.rsa->e) == 0 &&
774                             BN_cmp(key->rsa->n, pvar->hosts_state.hostkey.rsa->n) == 0;                         BN_cmp(key->rsa->n, pvar->hosts_state.hostkey.rsa->n) == 0;
775    
776          } else { // // SSH2 DSA host public key          } else { // // SSH2 DSA host public key
777    
778                  return key->dsa != NULL && pvar->hosts_state.hostkey.dsa &&                  return key->dsa != NULL && pvar->hosts_state.hostkey.dsa &&
779                             BN_cmp(key->dsa->p, pvar->hosts_state.hostkey.dsa->p) == 0 &&                         BN_cmp(key->dsa->p, pvar->hosts_state.hostkey.dsa->p) == 0 &&
780                             BN_cmp(key->dsa->q, pvar->hosts_state.hostkey.dsa->q) == 0 &&                         BN_cmp(key->dsa->q, pvar->hosts_state.hostkey.dsa->q) == 0 &&
781                             BN_cmp(key->dsa->g, pvar->hosts_state.hostkey.dsa->g) == 0 &&                         BN_cmp(key->dsa->g, pvar->hosts_state.hostkey.dsa->g) == 0 &&
782                             BN_cmp(key->dsa->pub_key, pvar->hosts_state.hostkey.dsa->pub_key) == 0;                         BN_cmp(key->dsa->pub_key, pvar->hosts_state.hostkey.dsa->pub_key) == 0;
783    
784          }          }
785    
# Line 802  static void init_hosts_dlg(PTInstVar pva Line 799  static void init_hosts_dlg(PTInstVar pva
799                  buf2[i] = ch;                  buf2[i] = ch;
800          }          }
801          strncpy_s(buf2 + i, sizeof(buf2) - i,          strncpy_s(buf2 + i, sizeof(buf2) - i,
802                            pvar->hosts_state.prefetched_hostname, _TRUNCATE);                    pvar->hosts_state.prefetched_hostname, _TRUNCATE);
803          j = i + strlen(buf2 + i);          j = i + strlen(buf2 + i);
804          for (; buf[i] == '#'; i++) {          for (; buf[i] == '#'; i++) {
805          }          }
# Line 851  static char FAR *format_host_key(PTInstV Line 848  static char FAR *format_host_key(PTInstV
848    
849          if (type == KEY_RSA1) {          if (type == KEY_RSA1) {
850                  int result_len = host_len + 50 +                  int result_len = host_len + 50 +
851                                                   get_ushort16_MSBfirst(pvar->hosts_state.hostkey.exp) / 3 +                                   get_ushort16_MSBfirst(pvar->hosts_state.hostkey.exp) / 3 +
852                                                   get_ushort16_MSBfirst(pvar->hosts_state.hostkey.mod) / 3;                                   get_ushort16_MSBfirst(pvar->hosts_state.hostkey.mod) / 3;
853                  result = (char FAR *) malloc(result_len);                  result = (char FAR *) malloc(result_len);
854    
855                  strncpy_s(result, result_len, pvar->hosts_state.prefetched_hostname, _TRUNCATE);                  strncpy_s(result, result_len, pvar->hosts_state.prefetched_hostname, _TRUNCATE);
856                  index = host_len;                  index = host_len;
857    
858                  _snprintf_s(result + index, result_len - host_len, _TRUNCATE,                  _snprintf_s(result + index, result_len - host_len, _TRUNCATE,
859                          " %d ", pvar->hosts_state.hostkey.bits);                              " %d ", pvar->hosts_state.hostkey.bits);
860                  index += strlen(result + index);                  index += strlen(result + index);
861                  index += print_mp_int(result + index, pvar->hosts_state.hostkey.exp);                  index += print_mp_int(result + index, pvar->hosts_state.hostkey.exp);
862                  result[index] = ' ';                  result[index] = ' ';
# Line 890  static char FAR *format_host_key(PTInstV Line 887  static char FAR *format_host_key(PTInstV
887    
888                          // setup                          // setup
889                          _snprintf_s(result, msize, _TRUNCATE, "%s %s %s\r\n",                          _snprintf_s(result, msize, _TRUNCATE, "%s %s %s\r\n",
890                                  pvar->hosts_state.prefetched_hostname,                                      pvar->hosts_state.prefetched_hostname,
891                                  get_sshname_from_key(key),                                      get_sshname_from_key(key),
892                                  uu);                                      uu);
893                  }                  }
894  error:  error:
895                  if (blob != NULL)                  if (blob != NULL)
# Line 914  static void add_host_key(PTInstVar pvar) Line 911  static void add_host_key(PTInstVar pvar)
911    
912          if (name == NULL || name[0] == 0) {          if (name == NULL || name[0] == 0) {
913                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar,                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar,
914                                                    "The host and its key cannot be added, because no known-hosts file has been specified.\n"                                    "The host and its key cannot be added, because no known-hosts file has been specified.\n"
915                                                    "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.");                                    "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.");
916                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
917          } else {          } else {
918                  char FAR *keydata = format_host_key(pvar);                  char FAR *keydata = format_host_key(pvar);
# Line 927  static void add_host_key(PTInstVar pvar) Line 924  static void add_host_key(PTInstVar pvar)
924    
925                  get_teraterm_dir_relative_name(buf, sizeof(buf), name);                  get_teraterm_dir_relative_name(buf, sizeof(buf), name);
926                  fd = _open(buf,                  fd = _open(buf,
927                            _O_APPEND | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL |                            _O_APPEND | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY,
928                            _O_BINARY,                            _S_IREAD | _S_IWRITE);
                           _S_IREAD | _S_IWRITE);  
929                  if (fd == -1) {                  if (fd == -1) {
930                          if (errno == EACCES) {                          if (errno == EACCES) {
931                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar,
932                                                                    "An error occurred while trying to write the host key.\n"                                                    "An error occurred while trying to write the host key.\n"
933                                                                    "You do not have permission to write to the known-hosts file.");                                                    "You do not have permission to write to the known-hosts file.");
934                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
935                          } else {                          } else {
936                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,
937                                                                    "An error occurred while trying to write the host key.\n"                                                    "An error occurred while trying to write the host key.\n"
938                                                                    "The host key could not be written.");                                                    "The host key could not be written.");
939                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
940                          }                          }
941                          return;                          return;
# Line 951  static void add_host_key(PTInstVar pvar) Line 947  static void add_host_key(PTInstVar pvar)
947    
948                  if (amount_written != length || close_result == -1) {                  if (amount_written != length || close_result == -1) {
949                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,
950                                                            "An error occurred while trying to write the host key.\n"                                            "An error occurred while trying to write the host key.\n"
951                                                            "The host key could not be written.");                                            "The host key could not be written.");
952                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
953                  }                  }
954          }          }
# Line 980  static void delete_different_key(PTInstV Line 976  static void delete_different_key(PTInstV
976    
977          if (name == NULL || name[0] == 0) {          if (name == NULL || name[0] == 0) {
978                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar,                  UTIL_get_lang_msg("MSG_HOSTS_FILE_UNSPECIFY_ERROR", pvar,
979                                                    "The host and its key cannot be added, because no known-hosts file has been specified.\n"                                    "The host and its key cannot be added, because no known-hosts file has been specified.\n"
980                                                    "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.");                                    "Restart Teraterm and specify a read/write known-hosts file in the TTSSH Setup dialog box.");
981                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
982          }          }
983          else {          else {
# Line 996  static void delete_different_key(PTInstV Line 992  static void delete_different_key(PTInstV
992    
993                  // 書き込み一時ファイルを開く                  // 書き込み一時ファイルを開く
994                  tmpnam(filename);                  tmpnam(filename);
995                  fd =                  fd = _open(filename,
996                          _open(filename,                            _O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY | _O_TRUNC,
997                                    _O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY |                            _S_IREAD | _S_IWRITE);
                                   _O_TRUNC,  
                                   _S_IREAD | _S_IWRITE);  
998    
999                  if (fd == -1) {                  if (fd == -1) {
1000                          if (errno == EACCES) {                          if (errno == EACCES) {
1001                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_EACCES_ERROR", pvar,
1002                                                                    "An error occurred while trying to write the host key.\n"                                                    "An error occurred while trying to write the host key.\n"
1003                                                                    "You do not have permission to write to the known-hosts file.");                                                    "You do not have permission to write to the known-hosts file.");
1004                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1005                          } else {                          } else {
1006                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,                                  UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,
1007                                                                    "An error occurred while trying to write the host key.\n"                                                    "An error occurred while trying to write the host key.\n"
1008                                                                    "The host key could not be written.");                                                    "The host key could not be written.");
1009                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);                                  notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1010                          }                          }
1011                          free(filename);                          free(filename);
# Line 1069  static void delete_different_key(PTInstV Line 1063  static void delete_different_key(PTInstV
1063                                          if (negated) {                                          if (negated) {
1064                                                  host_index++;                                                  host_index++;
1065                                                  if (match_pattern(data + host_index,                                                  if (match_pattern(data + host_index,
1066                                                                                    pvar->ssh_state.hostname)) {                                                                    pvar->ssh_state.hostname)) {
1067                                                          matched = 0;                                                          matched = 0;
1068                                                          // 接続バージョンチェックのために host_index を進めてから抜ける                                                          // 接続バージョンチェックのために host_index を進めてから抜ける
1069                                                          host_index--;                                                          host_index--;
# Line 1081  static void delete_different_key(PTInstV Line 1075  static void delete_different_key(PTInstV
1075                                                  }                                                  }
1076                                          }                                          }
1077                                          else if (match_pattern(data + host_index,                                          else if (match_pattern(data + host_index,
1078                                                                            pvar->ssh_state.hostname)) {                                                                 pvar->ssh_state.hostname)) {
1079                                                  matched = 1;                                                  matched = 1;
1080                                          }                                          }
1081                                          host_index += eat_to_end_of_pattern(data + host_index);                                          host_index += eat_to_end_of_pattern(data + host_index);
# Line 1118  static void delete_different_key(PTInstV Line 1112  static void delete_different_key(PTInstV
1112                                  length = pvar->hosts_state.file_data_index - data_index;                                  length = pvar->hosts_state.file_data_index - data_index;
1113                                  amount_written =                                  amount_written =
1114                                          _write(fd, pvar->hosts_state.file_data + data_index,                                          _write(fd, pvar->hosts_state.file_data + data_index,
1115                                                     length);                                                 length);
1116    
1117                                  if (amount_written != length) {                                  if (amount_written != length) {
1118                                          goto error1;                                          goto error1;
# Line 1131  error1: Line 1125  error1:
1125                  close_result = _close(fd);                  close_result = _close(fd);
1126                  if (amount_written != length || close_result == -1) {                  if (amount_written != length || close_result == -1) {
1127                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,                          UTIL_get_lang_msg("MSG_HOSTS_WRITE_ERROR", pvar,
1128                                                            "An error occurred while trying to write the host key.\n"                                            "An error occurred while trying to write the host key.\n"
1129                                                            "The host key could not be written.");                                            "The host key could not be written.");
1130                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);                          notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1131                          goto error2;                          goto error2;
1132                  }                  }
# Line 1156  error2: Line 1150  error2:
1150  // (2006.3.25 yutaka)  // (2006.3.25 yutaka)
1151  //  //
1152  static BOOL CALLBACK hosts_add_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,  static BOOL CALLBACK hosts_add_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,
1153                                                                                  LPARAM lParam)                                          LPARAM lParam)
1154  {  {
1155          PTInstVar pvar;          PTInstVar pvar;
1156          LOGFONT logfont;          LOGFONT logfont;
# Line 1263  static BOOL CALLBACK hosts_add_dlg_proc( Line 1257  static BOOL CALLBACK hosts_add_dlg_proc(
1257  // 置き換え時の確認ダイアログを分離  // 置き換え時の確認ダイアログを分離
1258  //  //
1259  static BOOL CALLBACK hosts_replace_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,  static BOOL CALLBACK hosts_replace_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,
1260                                                                                          LPARAM lParam)                                              LPARAM lParam)
1261  {  {
1262          PTInstVar pvar;          PTInstVar pvar;
1263          LOGFONT logfont;          LOGFONT logfont;
# Line 1370  void HOSTS_do_unknown_host_dialog(HWND w Line 1364  void HOSTS_do_unknown_host_dialog(HWND w
1364                  HWND cur_active = GetActiveWindow();                  HWND cur_active = GetActiveWindow();
1365    
1366                  DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHUNKNOWNHOST),                  DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHUNKNOWNHOST),
1367                                             cur_active != NULL ? cur_active : wnd,                                 cur_active != NULL ? cur_active : wnd,
1368                                             hosts_add_dlg_proc, (LPARAM) pvar);                                 hosts_add_dlg_proc, (LPARAM) pvar);
1369          }          }
1370  }  }
1371    
# Line 1381  void HOSTS_do_different_host_dialog(HWND Line 1375  void HOSTS_do_different_host_dialog(HWND
1375                  HWND cur_active = GetActiveWindow();                  HWND cur_active = GetActiveWindow();
1376    
1377                  DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHDIFFERENTHOST),                  DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHDIFFERENTHOST),
1378                                             cur_active != NULL ? cur_active : wnd,                                 cur_active != NULL ? cur_active : wnd,
1379                                             hosts_replace_dlg_proc, (LPARAM) pvar);                                 hosts_replace_dlg_proc, (LPARAM) pvar);
1380          }          }
1381  }  }
1382    
# Line 1397  BOOL HOSTS_check_host_key(PTInstVar pvar Line 1391  BOOL HOSTS_check_host_key(PTInstVar pvar
1391    
1392          // すでに known_hosts ファイルからホスト公開鍵を読み込んでいるなら、それと比較する。          // すでに known_hosts ファイルからホスト公開鍵を読み込んでいるなら、それと比較する。
1393          if (pvar->hosts_state.prefetched_hostname != NULL          if (pvar->hosts_state.prefetched_hostname != NULL
1394                  && _stricmp(pvar->hosts_state.prefetched_hostname, hostname) == 0           && _stricmp(pvar->hosts_state.prefetched_hostname, hostname) == 0
1395                  && match_key(pvar, key)) {           && match_key(pvar, key)) {
1396    
1397                  if (SSHv1(pvar)) {                  if (SSHv1(pvar)) {
1398                          SSH_notify_host_OK(pvar);                          SSH_notify_host_OK(pvar);
# Line 1456  BOOL HOSTS_check_host_key(PTInstVar pvar Line 1450  BOOL HOSTS_check_host_key(PTInstVar pvar
1450    
1451          if (found_different_key) {          if (found_different_key) {
1452                  PostMessage(pvar->NotificationWindow, WM_COMMAND,                  PostMessage(pvar->NotificationWindow, WM_COMMAND,
1453                                          ID_SSHDIFFERENTHOST, 0);                              ID_SSHDIFFERENTHOST, 0);
1454          } else {          } else {
1455                  PostMessage(pvar->NotificationWindow, WM_COMMAND,                  PostMessage(pvar->NotificationWindow, WM_COMMAND,
1456                                          ID_SSHUNKNOWNHOST, 0);                              ID_SSHUNKNOWNHOST, 0);
1457          }          }
1458    
1459          return TRUE;          return TRUE;
# Line 1469  void HOSTS_notify_disconnecting(PTInstVa Line 1463  void HOSTS_notify_disconnecting(PTInstVa
1463  {  {
1464          if (pvar->hosts_state.hosts_dialog != NULL) {          if (pvar->hosts_state.hosts_dialog != NULL) {
1465                  PostMessage(pvar->hosts_state.hosts_dialog, WM_COMMAND, IDCANCEL,                  PostMessage(pvar->hosts_state.hosts_dialog, WM_COMMAND, IDCANCEL,
1466                                          0);                              0);
1467                  /* the main window might not go away if it's not enabled. (see vtwin.cpp) */                  /* the main window might not go away if it's not enabled. (see vtwin.cpp) */
1468                  EnableWindow(pvar->NotificationWindow, TRUE);                  EnableWindow(pvar->NotificationWindow, TRUE);
1469          }          }

Legend:
Removed from v.2995  
changed lines
  Added in v.3003

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26