app-crypt/gnupg: Enable SSH_AUTH_SOCK in systemctl --user mode
authorDavid Seifert <soap@gentoo.org>
Fri, 20 Mar 2020 15:29:00 +0000 (16:29 +0100)
committerDavid Seifert <soap@gentoo.org>
Fri, 20 Mar 2020 15:29:00 +0000 (16:29 +0100)
Package-Manager: Portage-2.3.94, Repoman-2.3.21
Acked-by: Kristian Fiskerstrand <k_f@gentoo.org>
Signed-off-by: David Seifert <soap@gentoo.org>
app-crypt/gnupg/gnupg-2.2.19.ebuild

index 0a1d2df46afd392051a6e33a2748aa8fc440abdf..e756ff966ad182a6a9a877806a80c923bdb14556 100644 (file)
@@ -53,6 +53,19 @@ PATCHES=(
        "${FILESDIR}/${PN}-2.1.20-gpgscm-Use-shorter-socket-path-lengts-to-improve-tes.patch"
 )
 
+src_prepare() {
+       default
+
+       # Inject SSH_AUTH_SOCK into user's sessions after enabling gpg-agent-ssh.socket in systemctl --user mode,
+       # idea borrowed from libdbus, see
+       #   https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/bus/systemd-user/dbus.socket.in#L6
+       #
+       # This cannot be upstreamed, as it requires determining the exact prefix of 'systemctl',
+       # which in turn requires discovery in Autoconf, something that upstream deeply resents.
+       sed -e "/DirectoryMode=/a ExecStartPost=-${EPREFIX}/bin/systemctl --user set-environment SSH_AUTH_SOCK=%t/gnupg/S.gpg-agent.ssh" \
+               -i doc/examples/systemd-user/gpg-agent-ssh.socket || die
+}
+
 src_configure() {
        local myconf=()