diff options
author | Alexander Golubev <[email protected]> | 2024-01-27 22:09:30 +0300 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2024-03-04 23:34:44 +0900 |
commit | dbd135cce4bd4583897232a454e8f18a1db6a773 (patch) | |
tree | 164ecec6b654d0c744f0107e987721c06038d424 | |
parent | 15815002b21d6eac129f3f12a0a9f4c294768422 (diff) | |
download | tdebase-dbd135cce4bd4583897232a454e8f18a1db6a773.tar.gz tdebase-dbd135cce4bd4583897232a454e8f18a1db6a773.zip |
tdeioslave/sftp: enable changing user during kb-interactive auth
Signed-off-by: Alexander Golubev <[email protected]>
(cherry picked from commit 009382772da4cb5a56749ea67ed29c09658a4f69)
-rw-r--r-- | tdeioslave/sftp/tdeio_sftp.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tdeioslave/sftp/tdeio_sftp.cpp b/tdeioslave/sftp/tdeio_sftp.cpp index 1664725a5..dcefc45f1 100644 --- a/tdeioslave/sftp/tdeio_sftp.cpp +++ b/tdeioslave/sftp/tdeio_sftp.cpp @@ -365,6 +365,7 @@ int sftpProtocol::authenticateKeyboardInteractive(bool noPaswordQuery) { for (i = 0; i < n; ++i) { char echo; + bool isPassword=false; TQString answer; TQString errMsg; @@ -390,6 +391,7 @@ int sftpProtocol::authenticateKeyboardInteractive(bool noPaswordQuery) { if (prompt.lower().startsWith("password")) { // We can assume that the ssh server asks for a password and we will handle that case // with more care since it's what most users will see + isPassword = true; if (noPaswordQuery) { // if we have a cached password we might use it kdDebug(TDEIO_SFTP_DB) << "Using cached password" << endl; answer = mPassword; @@ -412,15 +414,25 @@ int sftpProtocol::authenticateKeyboardInteractive(bool noPaswordQuery) { infoKbdInt.prompt.append("\n\n").append(instruction); } infoKbdInt.prompt.append("\n\n").append(prompt); + infoKbdInt.readOnly = true; // set username readonly (enable changing it only with password) } - infoKbdInt.readOnly = true; // set username readonly - /* FIXME: We can query a new user name but we will have to reinitialize the connection if - * it changes <2024-01-10 Fat-Zer> */ if (answer.isNull()) { if (openPassDlg(infoKbdInt, errMsg)) { answer = infoKbdInt.password; kdDebug(TDEIO_SFTP_DB) << "Got the answer from the password dialog" << endl; + + if (isPassword) { + TQString sshUser=sshUsername(); + if (infoKbdInt.username != sshUser) { + kdDebug(TDEIO_SFTP_DB) << "Username changed from " << sshUser + << " to " << infoKbdInt.username << endl; + mCachedUsername = infoKbdInt.username; + mPassword = infoKbdInt.password; + + return sftpProtocol::SSH_AUTH_NEED_RECONNECT; + } + } } else { return sftpProtocol::SSH_AUTH_CANCELED; } |