On Thu, Aug 29, 2024 at 05:14:06PM CEST, Max Nikulin <maniku...@gmail.com> said:
> On 29/08/2024 12:56, Erwan David wrote:
> > On Mon, Aug 26, 2024 at 06:13:23PM CEST, Max Nikulin said:
> > > > > > On 23/08/2024 23:30, Max Nikulin wrote:
> > > > > > > It is started by /etc/X11/Xsession.d/90x11-common_ssh-agent
> > > 
> > > [Unit]
> > > After=dbus.service ssh-agent.service
> > > Wants=dbus.service ssh-agent.service
> > > [Install]
> > > WantedBy=
> > > WantedBy=graphical-session-pre.target
> > 
> > After some investigations :
> [...]
> > In the sourced snippets is /etc/X11/Xsession.d/90x11-common_ssh-agent
> > 
> > The effect is that if /etc/Xsession.options sets use-ssh-agent, it
> > starts plasma with the ssh-agent startplasmax11 command. Thus, systemd
> > is given the SSH_AUTH_SOCK variable (and the sock is at a random place
> > under /tmp)
> 
> I have had a look into startplasma sources. It pushes environment to systemd
> *before* initiating plasma-workspace-x11.target. (My additional interest was
> the following: If some variable is set in both ~/.profile and environment.d,
> what value wins?)
> 
> > Setting no-use-ssh-agent in /etc/X11/Xsession.option is a no go : it
> > is also tested by ssh-agent.service
> 
> It seems /usr/lib/openssh/agent-launch checks /etc/X11/Xsession.options, but
> not /etc/X11/Xsession.options.d. However it would be a rather fragile hack.
> 
> > Only solutions I see would imply modifying
> > /etc/X11/Xsession.d/90x11-common_ssh-agent, but is it a configuration
> > file ?
> 
> Ask "dpkg -s PKG" or dpkg-query with some options.
> 
> Do you really need emacs as a part of default.target and
> graphical-session.target is too late for you? The override for
> emacs.service, I posted earlier, should work otherwise.
> 
> As an alternative I would consider configuring either ssh-agent.service or a
> dedicated unit to execute in addition 'emacsclient --eval "(putenv ...)"'.
> See emacsclient-mailto.desktop how escape argument for Emacs-28.

The after/wants does not work (starnge since ssh-agent.service seems
to see the SSH_AUTH_SOCK variable.

But /etc/X11/Xsession.d/90x11-common_ssh-agent is a configuration file
and we can add SSHARGS. I added a
SSHARGS="-a $XDG_RUNTIME_DIR/ssh-agent"

Then I added an override to emacs.service
Environment=SSH_AUTH_SOCK=%t/ssh-agent

And it works

-- 
Erwan David

Reply via email to