mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:53:34 +03:00
sftp: add the option CURLKHSTAT_FINE_REPLACE
Replace the old fingerprint of the host with a new. Closes #5685
This commit is contained in:
parent
ddf47bbc0a
commit
ebc6c54c74
4 changed files with 20 additions and 4 deletions
|
|
@ -442,6 +442,7 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
|
|||
if(data->set.str[STRING_SSH_KNOWNHOSTS]) {
|
||||
/* we're asked to verify the host against a file */
|
||||
struct ssh_conn *sshc = &conn->proto.sshc;
|
||||
struct libssh2_knownhost *host = NULL;
|
||||
int rc;
|
||||
int keytype;
|
||||
size_t keylen;
|
||||
|
|
@ -456,7 +457,6 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
|
|||
* What host name does OpenSSH store in its file if an IDN name is
|
||||
* used?
|
||||
*/
|
||||
struct libssh2_knownhost *host;
|
||||
enum curl_khmatch keymatch;
|
||||
curl_sshkeycallback func =
|
||||
data->set.ssh_keyfunc?data->set.ssh_keyfunc:sshkeycallback;
|
||||
|
|
@ -568,7 +568,13 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
|
|||
/* DEFER means bail out but keep the SSH_HOSTKEY state */
|
||||
result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION;
|
||||
break;
|
||||
case CURLKHSTAT_FINE_REPLACE:
|
||||
/* remove old host+key that doesn't match */
|
||||
if(host)
|
||||
libssh2_knownhost_del(sshc->kh, host);
|
||||
/*FALLTHROUGH*/
|
||||
case CURLKHSTAT_FINE:
|
||||
/*FALLTHROUGH*/
|
||||
case CURLKHSTAT_FINE_ADD_TO_FILE:
|
||||
/* proceed */
|
||||
if(keycheck != LIBSSH2_KNOWNHOST_CHECK_MATCH) {
|
||||
|
|
@ -583,7 +589,8 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
|
|||
if(addrc)
|
||||
infof(data, "Warning adding the known host %s failed!\n",
|
||||
conn->host.name);
|
||||
else if(rc == CURLKHSTAT_FINE_ADD_TO_FILE) {
|
||||
else if(rc == CURLKHSTAT_FINE_ADD_TO_FILE ||
|
||||
rc == CURLKHSTAT_FINE_REPLACE) {
|
||||
/* now we write the entire in-memory list of known hosts to the
|
||||
known_hosts file */
|
||||
int wrc =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue