Package: ksshaskpass
Version: 0.5.1-1
Severity: important
Tags: patch,experimental

Hello,
 There is a nasty bug in ksshaskpass: when a wrong
 passphrase typed into ksshaskpass and if it is directed to save that passphrase
 into Kwallet, the ssh-agent deadlocks. In fact, ksshaskpass returns the
 incorrect passphrase saved over and over causing ssh-agent to loop
 every it is asked for the passphrase after then.
 The attached patch solves this issue by prompting the user for the
 passphrase when the prompt string begins with "Bad passphrase, try
 again for". As this my very first patch written in C++, please review
 it carefully before using it.
 Moreover, this patch removes also spaces at the end of some lines and
 changes "Please enter password" to "Please enter passphrase" which, IMO
 is more suitable in ssh world.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.28-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages ksshaskpass depends on:
ii  kdebase-runtime             4:4.2.2-1    runtime components from the offici
ii  kdelibs5                    4:4.2.2-2    core libraries for all KDE 4 appli
ii  libc6                       2.9-12       GNU C Library: Shared libraries
ii  libgcc1                     1:4.4.0-4    GCC support library
ii  libqt4-dbus                 4.5.1-2      Qt 4 D-Bus module
ii  libqt4-svg                  4.5.1-2      Qt 4 SVG module
ii  libqtcore4                  4.5.1-2      Qt 4 core module
ii  libqtgui4                   4.5.1-2      Qt 4 GUI module
ii  libstdc++6                  4.4.0-4      The GNU Standard C++ Library v3
ii  openssh-client              1:5.1p1-5+b1 secure shell client, an rlogin/rsh

Versions of packages ksshaskpass recommends:
ii  kwalletmanager                4:4.2.2-1  secure password wallet manager for

ksshaskpass suggests no packages.

-- no debconf information
--- main.cpp	2008-11-25 22:46:22.000000000 +0100
+++ main.cpp.patched	2009-05-10 15:49:04.000000000 +0200
@@ -46,7 +46,7 @@
   about.addAuthor(ki18n("Hans van Leeuwen"), ki18n("Original author"), "h...@hanz.nl", 0);
 
   KCmdLineOptions options;
-  options.add("+[prompt]",ki18n("Prompt")); 
+  options.add("+[prompt]",ki18n("Prompt"));
   KCmdLineArgs::init(argc, argv, &about);
   KCmdLineArgs::addCmdLineOptions( options );
   KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
@@ -57,14 +57,19 @@
   app.disableSessionManagement();
 
   QString walletFolder = about.appName();
-  QString dialog = i18n("Please enter password");  // Default dialog text.
+  QString dialog = i18n("Please enter passphrase");  // Default dialog text.
   QString keyFile;
   QString password;
+  bool wrongPassphrase = false;
 
   // Parse commandline arguments
   if ( args->count() > 0 ) {
     dialog = args->arg(0);
     keyFile = dialog.section(" ", -2).remove(":");
+
+		/* If the ssh-agent prompt starts with "Bad passphrase, try again for", then previously typed passphrase *or* retrived passphrase from kwallet *was* *wrong*.
+		TODO: Not sure if it will for all languages. */
+		wrongPassphrase = args->arg(0).startsWith(i18n("Bad passphrase, try again for"));
   }
   args->clear();
 
@@ -76,8 +81,9 @@
     wallet->setFolder(walletFolder);
 
     QString retrievedPass;
-
-    wallet->readPassword(keyFile, retrievedPass);
+		if (! wrongPassphrase) {
+		wallet->readPassword(keyFile, retrievedPass);
+		}
 
     if ( !retrievedPass.isEmpty() ) {
       password = retrievedPass;
@@ -122,5 +128,5 @@
 
   QTextStream out(stdout);
   out << password;
-  return 0; 
+  return 0;
 }

Reply via email to