Page MenuHome GnuPG

Closed, ResolvedPublic


GpgEX has not yet been updated to use Local\gnupg for the sockets. This needs to be fixed. Kleopatra also needs to be fixed to create the UI-Server socket in the socketdir.

Event Timeline

werner triaged this task as High priority.Sep 21 2021, 4:16 PM
werner created this task.
werner created this object with edit policy "Contributor (Project)".

It will be useful to have support in libkleo:


For Kleopatra this patch

should be sufficient. Take care this is fully untested and not very elegant.

gpgme_get_dirinfo does already have support for "uiserver-socket" since about 7 years. I don't think a separate "socketdir" which requires a brand new gpgme makes much sense.

We want to deprecate the whole UI-Server thing and thus I considered it better to provide the generic socket dir instead of adding support in libkleo for the uiserver socket. For the time being, doing this in Kleopatra sounds better to me. From my understanding. libkleo shall be an interface to gpgme++, right?

Not from understanding. libkleo adds high-level functionality that's useful for KDE applications, but out-of-scope for gpgme and its C++/Qt wrappers gpgme++ and qgpgme. I would use GpgME::dirInfo() directly in Kleopatra. It would make sense to add an overload of GpgME::dirInfo() that takes an enum, so that one does not have to use the low-level string names in Kleopatra. The downside is that a string-based interface can be extended easily. OTOH, deprecating values of a string-based interface is hard and after removing it the compiler won't complain.

Alternative patch for Kleopatra:

diff --git a/src/uiserver/uiserver.cpp b/src/uiserver/uiserver.cpp
index d9746f0b..ab4d2ca7 100644
--- a/src/uiserver/uiserver.cpp
+++ b/src/uiserver/uiserver.cpp
@@ -23,6 +23,8 @@
 #include "kleopatra_debug.h"
 #include <KLocalizedString>
+#include <gpgme++/global.h>
 #include <QTcpSocket>
 #include <QDir>
 #include <QEventLoop>
@@ -234,10 +236,23 @@ QString UiServer::Private::makeFileName(const QString &socket) const
     if (!socket.isEmpty()) {
         return socket;
+    const QString socketPath{QString::fromUtf8(GpgME::dirInfo("uiserver-socket"))};
+    if (!socketPath.isEmpty()) {
+        // Note: The socket directory exists after GpgME::dirInfo() has been called.
+        return socketPath;
+    }
+    // GPGME (or GnuPG) is too old to return the socket path.
+    // In this case we fallback to assume that the socket directory is
+    // the home directory as we did in the past.  This is not correct but
+    // probably the safest fallback we can do despite that it is a
+    // bug to assume the socket directory in the home directory.  See
+    //
     const QString gnupgHome = gnupgHomeDirectory();
     if (gnupgHome.isEmpty()) {
         throw_<std::runtime_error>(i18n("Could not determine the GnuPG home directory. Consider setting the GNUPGHOME environment variable."));
+    // We should not create the home directory, but this only happens for very
+    // old and long unsupported versions of gnupg.
     const QDir dir(gnupgHome);
werner claimed this task.

Fixed in gpgex 1.0.8