|
|
|
@ -984,8 +984,6 @@ int sftpProtocol::initializeConnection() {
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExitGuard connectionCloser([this](){ closeConnection(); });
|
|
|
|
|
|
|
|
|
|
kdDebug(TDEIO_SFTP_DB) << "Getting the SSH server hash" << endl;
|
|
|
|
|
|
|
|
|
|
/* get the hash */
|
|
|
|
@ -1079,8 +1077,6 @@ int sftpProtocol::initializeConnection() {
|
|
|
|
|
|
|
|
|
|
kdDebug(TDEIO_SFTP_DB) << "Trying to authenticate with the server" << endl;
|
|
|
|
|
|
|
|
|
|
connectionCloser.abort();
|
|
|
|
|
|
|
|
|
|
return SSH_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1121,13 +1117,13 @@ void sftpProtocol::openConnection() {
|
|
|
|
|
PasswordPurger pwPurger{mPassword};
|
|
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
|
ExitGuard connectionCloser([this](){ closeConnection(); });
|
|
|
|
|
|
|
|
|
|
connection_restart:
|
|
|
|
|
do { // A loop to restart connection when needed
|
|
|
|
|
// Start the ssh connection.
|
|
|
|
|
if (initializeConnection() < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ExitGuard connectionCloser([this](){ closeConnection(); });
|
|
|
|
|
|
|
|
|
|
// Try to authenticate (this required before calling ssh_auth_list())
|
|
|
|
|
rc = ssh_userauth_none(mSession, NULL);
|
|
|
|
@ -1222,7 +1218,7 @@ connection_restart:
|
|
|
|
|
wasCanceled = true;
|
|
|
|
|
} else if (rc == SSH_AUTH_NEED_RECONNECT) {
|
|
|
|
|
kdDebug(TDEIO_SFTP_DB) << "method=" << method->name() << " requested reconnection" << endl;
|
|
|
|
|
goto connection_restart;
|
|
|
|
|
break;
|
|
|
|
|
} else if (rc == SSH_AUTH_DENIED) {
|
|
|
|
|
kdDebug(TDEIO_SFTP_DB) << "Auth for method=" << method->name() << " was denied" << endl;
|
|
|
|
|
// do nothing, just proceed with next auth method
|
|
|
|
@ -1234,8 +1230,11 @@ connection_restart:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// At this point rc values should be one of:
|
|
|
|
|
// SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED or SSH_AUTH_CANCELED
|
|
|
|
|
if (wasCanceled && (rc == SSH_AUTH_CANCELED || rc == SSH_AUTH_DENIED)) {
|
|
|
|
|
// SSH_AUTH_SUCCESS, SSH_AUTH_PARTIAL, SSH_AUTH_DENIED, SSH_AUTH_CANCELED or SSH_AUTH_NEED_RECONNECT
|
|
|
|
|
if(rc == SSH_AUTH_NEED_RECONNECT) {
|
|
|
|
|
closeConnection(); //< have to do it manually
|
|
|
|
|
break;
|
|
|
|
|
} else if (wasCanceled && (rc == SSH_AUTH_CANCELED || rc == SSH_AUTH_DENIED)) {
|
|
|
|
|
error(TDEIO::ERR_USER_CANCELED, TQString::null);
|
|
|
|
|
return;
|
|
|
|
|
} else if (rc != SSH_AUTH_SUCCESS && rc != SSH_AUTH_PARTIAL) {
|
|
|
|
@ -1250,6 +1249,8 @@ connection_restart:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} // while (rc != SSH_AUTH_SUCCESS)
|
|
|
|
|
} while(rc == SSH_AUTH_NEED_RECONNECT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// start sftp session
|
|
|
|
|
kdDebug(TDEIO_SFTP_DB) << "Trying to request the sftp session" << endl;
|
|
|
|
|