Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/key.c

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

revision 5848 by yutakapon, Mon May 4 17:46:30 2015 UTC revision 5849 by yutakapon, Tue May 5 18:08:23 2015 UTC
# Line 1912  error: Line 1912  error:
1912          return (ret);          return (ret);
1913  }  }
1914    
1915    static void update_known_hosts(PTInstVar pvar, struct hostkeys_update_ctx *ctx)
1916    {
1917            size_t i;
1918            char msg[128];
1919            int dlgresult;
1920    
1921            // "/nosecuritywarning"が指定されている場合、更新は一切行わない。
1922            if (pvar->nocheck_known_hosts) {
1923                    _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Hostkey was not updated because `/nosecuritywarning' option was specified.");
1924                    notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);
1925                    goto error;
1926            }
1927    
1928            // known_hostsファイルの更新を行うため、ユーザに問い合わせを行う。
1929            if (pvar->settings.UpdateHostkeys == SSH_UPDATE_HOSTKEYS_ASK) {
1930                    _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Accept updated hostkeys? (yes/no)");
1931                    dlgresult = MessageBox(NULL, msg, "TTSSH: confirm", MB_YESNO | MB_ICONWARNING);
1932                    if (dlgresult != IDYES) {
1933                            _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Hostkey was not updated because a user cancelled.");
1934                            notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);
1935                            goto error;
1936                    }
1937            }
1938    
1939            // 古いキーをすべて削除する。
1940            HOSTS_delete_all_hostkeys(pvar);
1941    
1942            // 新しいキーをすべて登録する。
1943            for (i = 0; i < ctx->nkeys; i++) {
1944                    HOSTS_add_host_key(pvar, ctx->keys[i]);
1945            }
1946            _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Hostkey was successfully updated to known_hosts file.");
1947            notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);
1948    
1949    error:
1950            return;
1951    }
1952    
1953  //  //
1954  // SSHサーバホスト鍵(known_hosts)の自動更新(OpenSSH 6.8 or later: host key rotation support)  // SSHサーバホスト鍵(known_hosts)の自動更新(OpenSSH 6.8 or later: host key rotation support)
1955  //  //
# Line 1932  int update_client_input_hostkeys(PTInstV Line 1970  int update_client_input_hostkeys(PTInstV
1970          Key *key = NULL, **tmp;          Key *key = NULL, **tmp;
1971    
1972          // Tera Termの設定で、当該機能のオンオフを制御できるようにする。          // Tera Termの設定で、当該機能のオンオフを制御できるようにする。
1973          if (pvar->settings.UpdateHostkeys == 0) {          if (pvar->settings.UpdateHostkeys == SSH_UPDATE_HOSTKEYS_NO) {
1974                  _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Hostkey was not updated because ts.UpdateHostkeys is disabled.");                  _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Hostkey was not updated because ts.UpdateHostkeys is disabled.");
1975                  notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);                  notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);
1976                  return 1;                  return 1;
# Line 2008  int update_client_input_hostkeys(PTInstV Line 2046  int update_client_input_hostkeys(PTInstV
2046                  goto error;                  goto error;
2047          }          }
2048    
2049          if ((ctx->keys_seen = calloc(ctx->nkeys, sizeof(*ctx->keys_seen))) == NULL) {          if ((ctx->keys_seen = calloc(ctx->nkeys, sizeof(*ctx->keys_seen))) == NULL) {
2050                  _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Not memory: calloc ctx->keys %d",                  _snprintf_s(msg, sizeof(msg), _TRUNCATE, "Not memory: calloc ctx->keys %d",
2051                          ctx->nkeys);                          ctx->nkeys);
2052                  notify_verbose_message(pvar, msg, LOG_LEVEL_FATAL);                  notify_verbose_message(pvar, msg, LOG_LEVEL_FATAL);
2053                  goto error;                  goto error;
2054          }          }
2055    
2056          HOSTS_hostkey_foreach(pvar, hostkeys_find, ctx);          HOSTS_hostkey_foreach(pvar, hostkeys_find, ctx);
2057    
2058          // サーバが送ってきた鍵候補群から、いくつの鍵を新規追加するのかを数える。          // サーバが送ってきた鍵候補群から、いくつの鍵を新規追加するのかを数える。
2059          ctx->nnew = 0;          ctx->nnew = 0;
2060          for (i = 0; i < ctx->nkeys; i++) {          for (i = 0; i < ctx->nkeys; i++) {
2061                  if (!ctx->keys_seen[i])                  if (!ctx->keys_seen[i])
2062                          ctx->nnew++;                          ctx->nnew++;
2063          }          }
2064          _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%u keys from server: %u new, %u retained. %u to remove",          _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%u keys from server: %u new, %u retained. %u to remove",
2065                  ctx->nkeys, ctx->nnew, ctx->nkeys - ctx->nnew, ctx->nold);                  ctx->nkeys, ctx->nnew, ctx->nkeys - ctx->nnew, ctx->nold);
2066          notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);          notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE);
2067    
2068          // 新規追加する鍵はゼロだが、deprecatedな鍵が存在する。          // 新規追加する鍵はゼロだが、deprecatedな鍵が存在する。
2069          if (ctx->nnew == 0 && ctx->nold != 0) {          if (ctx->nnew == 0 && ctx->nold != 0) {
2070                  // TODO:                  update_known_hosts(pvar, ctx);
2071    
2072          }          }
2073          else if (ctx->nnew != 0) { // 新規追加するべき鍵が存在する。          else if (ctx->nnew != 0) { // 新規追加するべき鍵が存在する。
2074                  // TODO:                  // TODO:
2075                    update_known_hosts(pvar, ctx);
2076    
2077          }          }
2078    

Legend:
Removed from v.5848  
changed lines
  Added in v.5849

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