[Pkg-owncloud-commits] [owncloud-client] 55/211: owncloudcmd: Handle trust ssl switch correctly by overwriting trustssl

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit ab40ba2f75c7ef140f482fad1f0ffb3657203113
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Sat Oct 11 17:16:49 2014 +0200

    owncloudcmd: Handle trust ssl switch correctly by overwriting trustssl
    
    method in a subclass of HTTPCredentials.
---
 src/owncloudcmd/owncloudcmd.cpp | 48 +++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index ebf36bf..94267e4 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -107,13 +107,28 @@ QString queryPassword(const QString &user)
 
 class HttpCredentialsText : public HttpCredentials {
 public:
-    HttpCredentialsText(const QString& user, const QString& password) : HttpCredentials(user, password) {}
+    HttpCredentialsText(const QString& user, const QString& password)
+        : HttpCredentials(user, password),
+          _sslTrusted(false)
+    {}
+
     QString queryPassword(bool *ok) {
         if (ok) {
             *ok = true;
         }
         return ::queryPassword(user());
     }
+
+    void setSSLTrusted( bool isTrusted ) {
+        _sslTrusted = isTrusted;
+    }
+
+    bool sslIsTrusted() {
+        return _sslTrusted;
+    }
+
+private:
+    bool _sslTrusted;
 };
 
 void help()
@@ -214,30 +229,6 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
     }
 }
 
-int getauth_cmd(const char *prompt,
-            char *buf,
-            size_t len,
-            int echo,
-            int verify,
-            void *userdata)
-{
-    int re = 0;
-
-    const QString qPrompt = QString::fromLatin1( prompt ).trimmed();
-
-    if( qPrompt.startsWith( QLatin1String("There are problems with the SSL certificate:"))) {
-        // its an SSL problem.
-        if( opts->trustSSL ) {
-            qstrcpy(buf, "yes");
-        } else {
-            qstrcpy(buf, "no");
-        }
-    } else {
-        re = -1;
-    }
-    return re;
-}
-
 int main(int argc, char **argv) {
     QCoreApplication app(argc, argv);
 
@@ -312,8 +303,11 @@ int main(int argc, char **argv) {
 
     SimpleSslErrorHandler *sslErrorHandler = new SimpleSslErrorHandler;
 
-    HttpCredentials *cred = new HttpCredentialsText(user, password);
+    HttpCredentialsText *cred = new HttpCredentialsText(user, password);
 
+    if( options.trustSSL ) {
+        cred->setSSLTrusted(true);
+    }
     account.setUrl(url);
     account.setCredentials(cred);
     account.setSslErrorHandler(sslErrorHandler);
@@ -339,8 +333,6 @@ restart_sync:
     opts = &options;
     cred->syncContextPreInit(_csync_ctx);
 
-    csync_set_auth_callback( _csync_ctx, getauth_cmd );
-
     if( csync_init( _csync_ctx ) < 0 ) {
         qFatal("Could not initialize csync!");
         return EXIT_FAILURE;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list