On Sat, May 23, 2020 at 09:45:55AM +0800, Paul Wise wrote: > On pure-Wayland systems, the ssh-agent.service is not going to be able > to start because x11-common won't nessecarily be installed. I think > either the ConditionPathExists should get dropped and the script should > check if the Xsession.options file exists before using it, when it > doesn't exist people using Wayland without x11-common installed can just use > `systemctl --user mask/enable/disable` to manage the service.
Hm. I'm somewhat inclined to do something like this. What do you think? (I'm aware using loginctl to figure out the session type might be more technically correct. On the other hand, I seem to be suffering from something similar to https://askubuntu.com/questions/1238984/ubuntu-20-04-xdg-seat-xdg-vtnr-xdg-session-id-env-variables-are-not-set here, so can't easily test it. Besides, checking the environment variables is likely faster, so as long as it isn't hopelessly wrong ...) diff --git a/debian/agent-launch b/debian/agent-launch index 3b2abdbf7..75f185b72 100755 --- a/debian/agent-launch +++ b/debian/agent-launch @@ -8,8 +8,23 @@ if [ ! -d "$XDG_RUNTIME_DIR" ]; then exit 1 fi +session_is_x11 () { + [ "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] +} + +session_uses_ssh_agent () { + if session_is_x11; then + grep -s -q '^use-ssh-agent$' /etc/X11/Xsession.options + else + # Users of non-X11 sessions can use "systemctl --user mask + # ssh-agent.service" or similar to control whether this service + # should run. + return 0 + fi +} + if [ "$1" = start ]; then - if [ -z "$SSH_AUTH_SOCK" ] && grep -s -q '^use-ssh-agent$' /etc/X11/Xsession.options; then + if [ -z "$SSH_AUTH_SOCK" ] && session_uses_ssh_agent; then S="$XDG_RUNTIME_DIR/openssh_agent" dbus-update-activation-environment --verbose --systemd SSH_AUTH_SOCK="$S" SSH_AGENT_LAUNCHER=openssh exec ssh-agent -D -a "$S" diff --git a/debian/systemd/ssh-agent.service b/debian/systemd/ssh-agent.service index cdc10bb47..4d5d3faf8 100644 --- a/debian/systemd/ssh-agent.service +++ b/debian/systemd/ssh-agent.service @@ -2,7 +2,6 @@ Description=OpenSSH Agent Documentation=man:ssh-agent(1) Before=graphical-session-pre.target -ConditionPathExists=/etc/X11/Xsession.options Wants=dbus.socket After=dbus.socket > PS: shellcheck reports some issues for the agent-launch script. Fixed in git master, thanks. -- Colin Watson (he/him) [cjwat...@debian.org]