kssl: Ensure user certificate directory has been created before use.
authorMichael Pyne <mpyne@kde.org>
Wed, 11 Jan 2017 02:05:48 +0000 (21:05 -0500)
committerMaximiliano Curia <maxy@debian.org>
Wed, 5 Apr 2017 08:10:59 +0000 (09:10 +0100)
The KSSL KCM (in kdelibs4support) fails to save imported certificates to
the user certificate store, unless the user store directory is manually
created by the user first.  Fix by ensuring the directory is created
before trying to save user certs.

Differential Revision: https://phabricator.kde.org/D4060
BUG: 342958
FIXED-IN: 5.31

Gbp-Pq: Name kssl-Ensure-user-certificate-directory-has-been-created-b.patch

src/core/ksslcertificatemanager.cpp

index 2c51cf7cd5d96dcf5c3cbfe24d42d50c134aaf7f..2e57e32f129568873200c3edbac4956245cf97cf 100644 (file)
@@ -247,9 +247,9 @@ bool KSslCertificateManagerPrivate::addCertificate(const KSslCaCertificate &in)
     }
 
     QString certFilename = userCertDir + QString::fromLatin1(in.certHash);
-    //qDebug() << certFilename;
+
     QFile certFile(certFilename);
-    if (certFile.open(QIODevice::ReadOnly)) {
+    if (!QDir().mkpath(userCertDir) || certFile.open(QIODevice::ReadOnly)) {
         return false;
     }
     if (!certFile.open(QIODevice::WriteOnly)) {