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.
Description
Revisions and Commits
rX GpgEX | |||
rX0b7556fa662e Take UI-Server socket from gpgconf. | |||
rM GPGME | |||
rMeb37d6469e72 core: Support dirinfo("socketdir") |
Related Objects
Event Timeline
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 + // https://dev.gnupg.org/T5613 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. ensureDirectoryExists(gnupgHome); const QDir dir(gnupgHome); Q_ASSERT(dir.exists());
Patch has been applied to Kleopatra. See T5619: Kleopatra does not create the UI-Server socket in the socketdir.