Bug 149420 - krdc does not handle password failures
Summary: krdc does not handle password failures
Status: RESOLVED FIXED
Alias: None
Product: krdc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR critical
Target Milestone: ---
Assignee: Urs Wolfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-31 14:38 UTC by Dirk Mueller
Modified: 2007-09-01 14:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Mueller 2007-08-31 14:38:55 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

the new krdc cannot handle the situation correctly that I entered the wrong password. 

a) it does not give user feedback

b) the password stored in the kwallet is not invalidated

c) it doesn`t retry with a new password.
Comment 1 Urs Wolfer 2007-09-01 14:29:10 UTC
SVN commit 707273 by uwolfer:

* add a timeout for stopping the vnc thread
* show VNC error messages not only in the debug output, but also in messageboxes
* do not save the VNC passwort in KWallet if the authentication did not succeeded
* save the mainwindow state (toolbars, size, ...)
* correct the debug area number and change a deprecated debug call

BUG: 149420

 M  +2 -0      mainwindow.cpp  
 M  +29 -8     vnc/vncclientthread.cpp  
 M  +4 -0      vnc/vncclientthread.h  
 M  +13 -5     vnc/vncview.cpp  
 M  +1 -0      vnc/vncview.h  


--- trunk/KDE/kdenetwork/krdc/mainwindow.cpp #707272:707273
@@ -91,6 +91,8 @@
 
     if (Settings::showStartPage())
         createStartPage();
+
+    setAutoSaveSettings(); // e.g toolbar position, mainwindow size, ...
 }
 
 MainWindow::~MainWindow()
--- trunk/KDE/kdenetwork/krdc/vnc/vncclientthread.cpp #707272:707273
@@ -24,9 +24,13 @@
 #include "vncclientthread.h"
 
 #include <KDebug>
+#include <KLocale>
 
 #include <QMutexLocker>
+#include <QTimer>
 
+static QString outputMessageString;
+
 static rfbBool newclient(rfbClient *cl)
 {
     int width = cl->width, height = cl->height, depth = cl->format.bitsPerPixel;
@@ -92,7 +96,7 @@
 
 char *VncClientThread::passwdHandler(rfbClient *cl)
 {
-    kDebug(5011) << "password request" << kdBacktrace() ;
+    kDebug(5011) << "password request" << kBacktrace();
 
     VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
 
@@ -112,27 +116,44 @@
 
     va_end(args);
 
+    message = message.trimmed();
+
     kDebug(5011) << message;
 
-    if (message.contains("Could not open"))
-        kDebug(5011) << "Server not found!";
+    if ((message.contains("Couldn't convert ")) ||
+        (message.contains("Unable to connect to VNC server")))
+        outputMessageString = i18n("Server not found.");
 
-    if (message.contains("VNC authentication succeeded"))
-        kDebug(5011) << "Password OK";
+    if (message.contains("VNC connection failed: Authentication failed, too many tries"))
+        outputMessageString = i18n("VNC authentication faile because of too many tries.");
 }
 
 VncClientThread::VncClientThread()
 {
     QMutexLocker locker(&mutex);
     m_stopped = false;
+
+    QTimer *outputMessagesCheck = new QTimer(this);
+    outputMessagesCheck->setInterval(500);
+    connect(outputMessagesCheck, SIGNAL(timeout()), this, SLOT(checkOutputMessage()));
+    outputMessagesCheck->start();
 }
 
 VncClientThread::~VncClientThread()
 {
     stop();
-    wait();
+    wait(500);
 }
 
+void VncClientThread::checkOutputMessage()
+{
+    if (!outputMessageString.isEmpty()) {
+        kDebug(5011) << outputMessageString;
+        outputMessage(outputMessageString);
+        outputMessageString.clear();
+    }
+}
+
 void VncClientThread::setHost(const QString &host)
 {
     QMutexLocker locker(&mutex);
@@ -207,9 +228,9 @@
             m_port += 5900;
         cl->serverPort = m_port;
 
-        kDebug() << "--------------------- trying init ---------------------";
+        kDebug(5011) << "--------------------- trying init ---------------------";
 
-        if(rfbInitClient(cl, 0, 0))
+        if (rfbInitClient(cl, 0, 0))
             break;
 
         if (m_passwordError)
--- trunk/KDE/kdenetwork/krdc/vnc/vncclientthread.h #707272:707273
@@ -56,6 +56,7 @@
 signals:
     void imageUpdated(int x, int y, int w, int h);
     void passwordRequest();
+    void outputMessage(const QString &message);
 
 public slots:
     void mouseEvent(int x, int y, int buttonMask);
@@ -78,6 +79,9 @@
 
     volatile bool m_stopped;
     volatile bool m_passwordError;
+
+private slots:
+    void checkOutputMessage();
 };
 
 #endif
--- trunk/KDE/kdenetwork/krdc/vnc/vncview.cpp #707272:707273
@@ -24,6 +24,7 @@
 #include "vncview.h"
 
 #include <KLocale>
+#include <KMessageBox>
 #include <KPasswordDialog>
 
 #include <QImage>
@@ -48,6 +49,7 @@
 
     connect(&vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)), Qt::BlockingQueuedConnection);
     connect(&vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()), Qt::BlockingQueuedConnection);
+    connect(&vncThread, SIGNAL(outputMessage(QString)), this, SLOT(outputMessage(QString)));
 }
 
 VncView::~VncView()
@@ -160,14 +162,16 @@
     dialog.setPrompt(i18n("Access to the system requires a password."));
     if (dialog.exec() == KPasswordDialog::Accepted) {
         vncThread.setPassword(dialog.password());
-
-        if (m_hostPreferences->walletSupport()) {
-            //TODO: save it only when the password has also been accepted.
-            saveWalletPassword(dialog.password());
-        }
     }
 }
 
+void VncView::outputMessage(const QString &message)
+{
+    kDebug(5011) << message;
+
+    KMessageBox::error(this, message, i18n("VNC failure"));
+}
+
 void VncView::updateImage(int x, int y, int w, int h)
 {
 //     kDebug(5011) << "got update";
@@ -190,6 +194,10 @@
         emit changeSize(vncThread.image().width(), vncThread.image().height());
         emit connected();
         m_initDone = true;
+
+        if (m_hostPreferences->walletSupport()) {
+            saveWalletPassword(vncThread.password());
+        }
     }
 
     m_repaint = true;
--- trunk/KDE/kdenetwork/krdc/vnc/vncview.h #707272:707273
@@ -76,6 +76,7 @@
 private slots:
     void updateImage(int x, int y, int w, int h);
     void requestPassword();
+    void outputMessage(const QString &message);
     void mouseEvent(QMouseEvent *event);
 };