summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <[email protected]>2024-01-29 21:37:10 +0300
committerMichele Calgaro <[email protected]>2024-03-04 23:34:45 +0900
commitc1a256a31fed9397f7754217c8e2d2149de45054 (patch)
tree7ffc0741c322569653471957b0680d7064ab69b5
parentef56a87ffe8f80db2c06518788873e20f6991624 (diff)
downloadtdebase-c1a256a31fed9397f7754217c8e2d2149de45054.tar.gz
tdebase-c1a256a31fed9397f7754217c8e2d2149de45054.zip
tdeioslave/sftp: better cancelation handling in case of several publickeys
Consider publickey auth canceled only if user canceled it for each of the prompted keys. Signed-off-by: Alexander Golubev <[email protected]> (cherry picked from commit 4b4b72db8f880027a85cb95a1510cefd5522d245)
-rw-r--r--tdeioslave/sftp/tdeio_sftp.cpp18
-rw-r--r--tdeioslave/sftp/tdeio_sftp.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/tdeioslave/sftp/tdeio_sftp.cpp b/tdeioslave/sftp/tdeio_sftp.cpp
index 4896bf586..b71e9c1b5 100644
--- a/tdeioslave/sftp/tdeio_sftp.cpp
+++ b/tdeioslave/sftp/tdeio_sftp.cpp
@@ -226,6 +226,7 @@ int sftpProtocol::auth_callback(const char *prompt, char *buf, size_t len,
kdDebug(TDEIO_SFTP_DB) << "Entering public key authentication callback" << endl;
int rc=0;
+ bool firstTimeCalled = !mPubKeyAuthData.wasCalled;
mPubKeyAuthData.wasCalled = true;
AuthInfo pubKeyInfo = authInfo();
@@ -277,15 +278,20 @@ int sftpProtocol::auth_callback(const char *prompt, char *buf, size_t len,
buf[len-1]=0; // Just to be on the safe side
purgeString(pubKeyInfo.password);
+
+ // take a note that we already tried unlocking this keyfile
+ if(firstTry) {
+ mPubKeyAuthData.attemptedKeys.append(keyFile);
+ }
+
+ // we consider publickey auth canceled only if we cancel all the key dialogs
+ mPubKeyAuthData.wasCanceled = false;
} else {
kdDebug(TDEIO_SFTP_DB) << "User canceled entry of public key passphrase" << endl;
rc = -1;
- mPubKeyAuthData.wasCanceled = true;
- }
-
- // take a note that we already tried unlocking this keyfile
- if(firstTry) {
- mPubKeyAuthData.attemptedKeys.append(keyFile);
+ if (firstTimeCalled) {
+ mPubKeyAuthData.wasCanceled = true;
+ }
}
return rc;
diff --git a/tdeioslave/sftp/tdeio_sftp.h b/tdeioslave/sftp/tdeio_sftp.h
index 84e3e47c3..54d4e8242 100644
--- a/tdeioslave/sftp/tdeio_sftp.h
+++ b/tdeioslave/sftp/tdeio_sftp.h
@@ -164,7 +164,7 @@ private: // Private variables
long current_seqNr;
/** true if callback was called */
bool wasCalled;
- /** true if user canceled password entry dialog */
+ /** true if user canceled all passphrase entry dialogues */
bool wasCanceled;
} mPubKeyAuthData;