Bug 380311 - No way to launch ssh-agent with interactivity under Wayland
Summary: No way to launch ssh-agent with interactivity under Wayland
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: 5.9.5
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-29 11:27 UTC by Hector Martin
Modified: 2021-06-09 23:20 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hector Martin 2017-05-29 11:27:59 UTC
AIUI, the supported method for launching background daemons that also set environment variables under Plasma is ~/.config/plasma-workspace/env/*.sh. Under X11, the $DISPLAY environment variable exists when these scripts are sourced. However, under Wayland, these scripts are sourced before the compositor is started and $WAYLAND_DISPLAY does not exist. This makes it impossible to launch ssh-agent and use it interactively, e.g. with SSH_ASKPASS=ksshaskpass because ksshaskpass has no idea what display to start in.

I suspect the env scripts ought to be sourced from /usr/lib/startplasma (after kwin_wayland starts), not /usr/bin/startplasmacompositor. Or perhaps there should be two config directories, one for pre-compositor scripts and one for post-compositor scripts.

Ugly workarounds are possible, of course (e.g. an autostart script that dumps the required variables somewhere, and an sshaskpass wrapper that pulls them in), but there should clearly be a better way.
Comment 1 David Edmundson 2017-05-29 14:13:14 UTC
Ideally we shouldn't have anything interactive in env/*.sh because they'll block the login process; and it's at a point where we have no control over what is drawn on the root window. 

We certainly can't move those scripts. Having two dirs could be possible.
Comment 2 Hector Martin 2017-05-29 14:28:40 UTC
To be clear, the problem isn't that this is an interactive process *when those scripts are executed*, it's that the appropriate display environment variables need to be available so they are inherited by an intearctive child process at a later time, in response to a user request.

For now I resorted to the aforementioned hack of wrapping ksshaskpass in a script that sources the display environment variables from somewhere else filled in by an autostart script. ssh-agent still starts from env/, but now the script it calls injects the right variables before execing ksshaskpass. I did have to set DISPLAY to a dummy value in the parent script, though, because ssh-agent checks that it is set before even trying to call askpass...
Comment 3 Roman Gilg 2018-05-24 05:28:52 UTC
What's your plan? To launch ssh-agent in Wayland on startup? What's your solution now?

I'm looking into providing the same ssh-agent functionality in Wayland session as in X. So I'm looking for info about it.
Comment 4 Andrius Štikonas 2018-08-13 20:39:24 UTC
(In reply to Roman Gilg from comment #3)
> What's your plan? To launch ssh-agent in Wayland on startup? What's your
> solution now?
> 
> I'm looking into providing the same ssh-agent functionality in Wayland
> session as in X. So I'm looking for info about it.

Is there anything we can learn from GNOME? I found they had something related:
https://bugzilla.gnome.org/show_bug.cgi?id=772919
Comment 5 David Edmundson 2018-08-16 12:57:25 UTC
Had a discussion at Akademy:

Short term.

I think one can do
ssh-agent as you are now
*THEN* set SSH_ASKPASS

it will then be interactive on the next ssh-add or whatever by which time you should have a display manager you can connect to.

(untested)

------

Longer term:

kwin will be a systemd service, only consider "started" after it has launched the display socket
plasmashell (et al) will be a target also as a service

putting ssh-agent between the two and being sure to run dbus-update-activation-env --systemd at the end of the script would then work.
Comment 6 Andrius Štikonas 2020-10-02 10:54:06 UTC
(In reply to David Edmundson from comment #5)
> Longer term:
> 
> kwin will be a systemd service, only consider "started" after it has
> launched the display socket
> plasmashell (et al) will be a target also as a service
> 
> putting ssh-agent between the two and being sure to run
> dbus-update-activation-env --systemd at the end of the script would then
> work.

I guess this longer term goal is now unblocked?
Comment 7 Nate Graham 2021-03-04 20:11:14 UTC
Looks like it, yeah.
Comment 8 Nate Graham 2021-03-20 01:29:38 UTC
With systemd startup and everything in slices, if I run `ssh-add -q < /dev/null` in a Wayland session, ksshaskpass runs normally and seems to work. Will that suffice for your purposes?
Comment 9 Bug Janitor Service 2021-04-04 04:33:30 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 10 Bug Janitor Service 2021-04-19 04:33:18 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 11 Andrius Štikonas 2021-06-09 23:20:32 UTC
(In reply to Nate Graham from comment #8)
> With systemd startup and everything in slices, if I run `ssh-add -q <
> /dev/null` in a Wayland session, ksshaskpass runs normally and seems to
> work. Will that suffice for your purposes?

I'm not original reporter but SSH works much better for me in Plasma 5.21.5 (on Wayland). Note that I use gnuk token with gpg-agent, so somewhat different setup.