[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:27:19 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=830dd34

The following commit has been merged in the master branch:
commit 830dd34402558934826e6b303410182929ffd68d
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Thu Jan 23 21:00:24 2014 +0100

    PrivateKey field in KConfig is now PrivateKeyPath
    
    It was causing errors on pre-existent installations, that used the field
    as if it contained the key.
    
    Relaxed permissions check, as it was silently return if they were wrong
    and this is very confusing for a user (that should open the log to see the
    error)
---
 kded/daemon.cpp               | 13 +++++++------
 kded/device.cpp               | 24 ++++++++++++------------
 kded/device.h                 |  3 +--
 kded/kdeconnectd.cpp          | 20 ++++++++++++++++++++
 kded/kded.cpp                 |  5 ++---
 kded/kded.h                   |  2 +-
 kded/plugins/sftp/mounter.cpp |  2 +-
 7 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/kded/daemon.cpp b/kded/daemon.cpp
index d717831..c4ee427 100644
--- a/kded/daemon.cpp
+++ b/kded/daemon.cpp
@@ -57,7 +57,7 @@ Daemon::Daemon(QObject *parent) : QObject(parent)
     }
 
     const QFile::Permissions strict = QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser;
-    if (!config->group("myself").hasKey("privateKey"))
+    if (!config->group("myself").hasKey("privateKeyPath"))
     {
         const QString privateKeyPath = KStandardDirs::locateLocal("appdata", "key.pem", true, KComponentData("kdeconnect", "kdeconnect"));
         
@@ -72,20 +72,21 @@ Daemon::Daemon(QObject *parent) : QObject(parent)
         if (!privKey.setPermissions(strict))
         {
             kWarning(kdeconnect_kded()) << "Error: KDE Connect could not set permissions for private file: " << privateKeyPath;
-            return;
+            //return;
         }
 
         //http://delta.affinix.com/docs/qca/rsatest_8cpp-example.html        
         privKey.write(QCA::KeyGenerator().createRSA(2048).toPEM().toAscii());
         privKey.close();
         
-        config->group("myself").writeEntry("privateKey", privateKeyPath);
+        config->group("myself").writeEntry("privateKeyPath", privateKeyPath);
     }
     
-    if (QFile::permissions(config->group("myself").readEntry("privateKey")) != strict)
+    if (QFile::permissions(config->group("myself").readEntry("privateKeyPath")) != strict)
     {
-        kWarning(kdeconnect_kded()) << "Error: KDE Connect detects wrong permissions for private file " << config->group("myself").readEntry("privateKey");
-        return;
+        kWarning(kdeconnect_kded()) << "Error: KDE Connect detects wrong permissions for private file " << config->group("myself").readEntry("privateKeyPath");
+        //FIXME: Do not silently fail, because user won't notice the problem
+        //return;
     }
 
     //Debugging
diff --git a/kded/device.cpp b/kded/device.cpp
index aaedcf1..0d43e5d 100644
--- a/kded/device.cpp
+++ b/kded/device.cpp
@@ -36,11 +36,11 @@ Device::Device(QObject* parent, const QString& id)
     const QString& key = data.readEntry<QString>("publicKey", QString());
     m_publicKey = QCA::RSAPublicKey::fromPEM(key);
     
-    QFile privKey(config->group("myself").readEntry("privateKey"));
-    if (privKey.open(QIODevice::ReadOnly))
-    {
-        m_privateKey = QCA::PrivateKey::fromPEM(privKey.readAll());
-    }
+    //TODO: It is redundant to have our own private key in every instance of Device, move this to a signleton somewhere (Daemon?)
+    const QString privateKeyPath = KStandardDirs::locateLocal("appdata", "key.pem", true, KComponentData("kdeconnect", "kdeconnect"));
+    QFile privKey(privateKeyPath);
+    privKey.open(QIODevice::ReadOnly);
+    m_privateKey = QCA::PrivateKey::fromPEM(privKey.readAll());
 
     //Register in bus
     QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
@@ -54,11 +54,11 @@ Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLin
     , m_pairStatus(Device::NotPaired)
     , m_protocolVersion(identityPackage.get<int>("protocolVersion"))
 {
-    QFile privKey(KSharedConfig::openConfig("kdeconnectrc")->group("myself").readEntry("privateKey"));
-    if (privKey.open(QIODevice::ReadOnly))
-    {
-        m_privateKey = QCA::PrivateKey::fromPEM(privKey.readAll());
-    }
+    //TODO: It is redundant to have our own private key in every instance of Device, move this to a signleton somewhere (Daemon?)
+    const QString privateKeyPath = KStandardDirs::locateLocal("appdata", "key.pem", true, KComponentData("kdeconnect", "kdeconnect"));
+    QFile privKey(privateKeyPath);
+    privKey.open(QIODevice::ReadOnly);
+    m_privateKey = QCA::PrivateKey::fromPEM(privKey.readAll());
 
     addLink(identityPackage, dl);
     
@@ -258,9 +258,9 @@ void Device::removeLink(DeviceLink* link)
     }
 }
 
-QString Device::privateKey() const
+QString Device::privateKeyPath() const
 {
-    return KSharedConfig::openConfig("kdeconnectrc")->group("myself").readEntry("privateKey");
+    return KSharedConfig::openConfig("kdeconnectrc")->group("myself").readEntry("privateKeyPath");
 }
 
 bool Device::sendPackage(NetworkPackage& np)
diff --git a/kded/device.h b/kded/device.h
index 901350e..f576d06 100644
--- a/kded/device.h
+++ b/kded/device.h
@@ -83,7 +83,7 @@ public:
     void addLink(const NetworkPackage& identityPackage, DeviceLink*);
     void removeLink(DeviceLink*);
 
-    QString privateKey() const;
+    QString privateKeyPath() const;
     
     Q_SCRIPTABLE bool isPaired() const { return m_pairStatus==Device::Paired; }
     Q_SCRIPTABLE bool pairRequested() const { return m_pairStatus==Device::Requested; }
@@ -120,7 +120,6 @@ Q_SIGNALS:
     Q_SCRIPTABLE void unpaired();
 
 private:
-    //TODO: Replace device id by public key
     const QString m_deviceId;
     QString m_deviceName;
     DeviceType m_deviceType;
diff --git a/kded/kdeconnectd.cpp b/kded/kdeconnectd.cpp
index 5929256..e99e8f8 100644
--- a/kded/kdeconnectd.cpp
+++ b/kded/kdeconnectd.cpp
@@ -1,7 +1,27 @@
+/**
+ * Copyright 2014 Yuri Samoilenko <kinnalru at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
 
 #include <sys/socket.h>
 #include <unistd.h>
 #include <signal.h>
+#include <unistd.h>
 
 #include <QApplication>
 #include <QSocketNotifier>
diff --git a/kded/kded.cpp b/kded/kded.cpp
index 588af75..a15afcc 100644
--- a/kded/kded.cpp
+++ b/kded/kded.cpp
@@ -1,5 +1,5 @@
 /**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ * Copyright 2014 Yuri Samoilenko <kinnalru at gmail.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -20,7 +20,6 @@
 
 #include "kded.h"
 
-#include <QDBusConnection>
 #include <QTimer>
 
 #include <KPluginFactory>
@@ -62,7 +61,7 @@ bool Kded::start()
     m_daemon->setProgram(daemon);
     m_daemon->setOutputChannelMode(KProcess::SeparateChannels);
     m_daemon->start();
-    if (!m_daemon->waitForStarted(10000))
+    if (!m_daemon->waitForStarted(2000)) //FIXME: KDEDs should be non-blocking, do we really need to wait for it to start?
     {
         kError(kdeconnect_kded()) << "Can't start " << daemon;
         return false;
diff --git a/kded/kded.h b/kded/kded.h
index da24752..5914d96 100644
--- a/kded/kded.h
+++ b/kded/kded.h
@@ -1,5 +1,5 @@
 /**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ * Copyright 2014 Yuri Samoilenko <kinnalru at gmail.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
diff --git a/kded/plugins/sftp/mounter.cpp b/kded/plugins/sftp/mounter.cpp
index 57336b6..6d2e16f 100644
--- a/kded/plugins/sftp/mounter.cpp
+++ b/kded/plugins/sftp/mounter.cpp
@@ -116,7 +116,7 @@ void Mounter::onPakcageReceived(const NetworkPackage& np)
         << "-p" << np.get<QString>("port")
         << "-d"
         << "-f"
-        << "-o" << "IdentityFile=" + m_sftp->device()->privateKey();
+        << "-o" << "IdentityFile=" + m_sftp->device()->privateKeyPath();
     
     m_proc->setProgram(program, arguments);
 

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list