Bug 483541

Summary: Running from the keyboard shortcut erases SSH_AUTH_SOCK from env
Product: [Frameworks and Libraries] frameworks-kglobalaccel Reporter: Grief <iamgrief>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: CONFIRMED ---    
Severity: normal CC: iamgrief, kde.mandarin882, lucavall90, nicolas.fella, sam, vetruvet
Priority: NOR Keywords: qt6
Version: 6.0.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Grief 2024-03-14 12:41:27 UTC
STEPS TO REPRODUCE
1. systemsettings → shortcurs → add new
2. it seems to be reproducible with both .desktop files and scripts
3. let's say it's script with this contest: shabang + `env >> /tmp/test.log`

OBSERVED RESULT
the printed env does not contain SSH_AUTH_SOCK variable. That leads to the situation when the IDE that was started from krunner or start menu works perfectly, but if you run it from the keyboard shortcut it is unable to connect to ssh agent

EXPECTED RESULT
The app, started with the press of the key sequence must be able to connect to ssh agent

SOFTWARE/OS VERSIONS
Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION

It was working until plasma 6 upgrade
Comment 1 Luca Vallerini 2024-03-15 20:59:02 UTC
I can reproduce it too. Just Konsole with the default Ctrl+Alt+T shortcut to see the ssh-add -l command fail, but this does not happen if Konsole is run from krunner.
Comment 2 Nicolas Fella 2024-03-18 16:33:22 UTC
How are you starting ssh-agent?
Comment 3 Luca Vallerini 2024-03-18 19:35:44 UTC
(In reply to Nicolas Fella from comment #2)
> How are you starting ssh-agent?

In my case, it is automatically started by KeePassXC. The agent works as expected in every situation but when launching Konsole with the shortcut. I usually use Yakuake (automatically started after login) and works as expected there too.
Comment 4 Grief 2024-03-18 19:48:52 UTC
I use keepassxc too. That might be the reason
Comment 5 Nicolas Fella 2024-03-18 22:25:20 UTC
Are you using X11 or Wayland?
Comment 6 Luca Vallerini 2024-03-18 22:30:19 UTC
(In reply to Nicolas Fella from comment #5)
> Are you using X11 or Wayland?

Wayland.
Comment 7 Nicolas Fella 2024-03-18 22:35:23 UTC
When you do "cat /proc/$(pidof kwin_wayland)/environ", does have SSH_AUTH_SOCK have the right value there?
Comment 8 Grief 2024-03-19 12:26:16 UTC
Sadly, I cannot answer your question anymore. I've updated the base layer of kde neon from jammy to noble (with just a few irrelevant packages left on hold) and I cannot reproduce the issue anymore after update.

```sudo cat /proc/$(pidof kwin_wayland)/environ|sed 's/\x0/\n/g'|grep -a SSH   
GSM_SKIP_SSH_AGENT_WORKAROUND=true
SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh```
Comment 9 Luca Vallerini 2024-03-19 19:30:48 UTC
(In reply to Nicolas Fella from comment #7)
> When you do "cat /proc/$(pidof kwin_wayland)/environ", does have
> SSH_AUTH_SOCK have the right value there?

This is the output:

HOME=/home/lucaLANG=it_IT.UTF-8LC_ADDRESS=it_IT.UTF-8LC_IDENTIFICATION=it_IT.UTF-8LC_MEASUREMENT=it_IT.UTF-8LC_MONETARY=it_IT.UTF-8LC_NAME=it_IT.UTF-8LC_NUMERIC=it_IT.UTF-8LC_PAPER=it_IT.UTF-8LC_TELEPHONE=it_IT.UTF-8LC_TIME=it_IT.UTF-8LOGNAME=lucaPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binSHELL=/bin/bashSYSTEMD_EXEC_PID=1311USER=lucaXDG_DATA_DIRS=/home/luca/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktopXDG_RUNTIME_DIR=/run/user/1000DEBUGINFOD_URLS=https://debuginfod.neon.kde.org/:QT_ACCESSIBILITY=1DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/busDESKTOP_SESSION=plasmaKCRASH_DUMP_ONLY=1KDE_APPLICATIONS_AS_SCOPE=1KDE_FORK_SLAVES=1KDE_FULL_SESSION=trueKDE_SESSION_UID=1000KDE_SESSION_VERSION=6MOZ_USE_XINPUT2=1PAM_KWALLET5_LOGIN=/run/user/1000/kwallet5.socketPWD=/home/lucaQT_AUTO_SCREEN_SCALE_FACTOR=0QT_EXCLUDE_GENERIC_BEARER=1QT_WAYLAND_RECONNECT=1XDG_CONFIG_DIRS=/home/luca/.config/kdedefaults:/etc/xdgXDG_CURRENT_DESKTOP=KDEXDG_MENU_PREFIX=plasma-XDG_SEAT=seat0XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0XDG_SESSION_CLASS=userXDG_SESSION_DESKTOP=KDEXDG_SESSION_ID=3XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1XDG_SESSION_TYPE=waylandXDG_VTNR=1XKB_DEFAULT_LAYOUT=itXKB_DEFAULT_MODEL=pc105NOTIFY_SOCKET=/run/user/1000/systemd/notifyMANAGERPID=1252WATCHDOG_PID=1311WATCHDOG_USEC=15000000INVOCATION_ID=c660a3af3b934a7695d24ed237c7b133JOURNAL_STREAM=8:22227

The output above is the same when run on a Konsole instance launched with krunner, where however the SSH_AUTH_SOCKET is correctly set, in fact "env | grep SSH_AUTH_SOCKET" results in:
SSH_AGENT_LAUNCHER=gnome-keyring
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
Comment 10 Nicolas Fella 2024-03-19 21:20:03 UTC
What seem to be happening is this:

When launching apps via global shortcuts they are launched from kwin_wayland whereas when they are launched from the app launcher/krunner the launching process is plasmashell/krunner.

When SSH_AUTH_SOCK is populated after kwin_wayland is started it will not be in kwin's environment, so it doesn't propagate to apps launched by kwin.

Fedora ships a file /etc/xdg/plasma-workspace/env/ssh-agent.sh that causes SSH_AUTH_SOCK to be set before kwin starts, so for me on Fedora it works fine.

However on Neon there's no such file so SSH_AUTH_SOCK is not set that way and only later set by something else
Comment 11 Alessandro Grassi 2024-10-06 21:07:37 UTC
Hello there! I just found this bug report while searching for an explanation to this weird behaviour, thanks so much Nicolas!

For anyone else who finds this from a search engine: I have opened a Debian (which is the upstream of the upstream of Neon) bug here --> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1084225

As a workaround you can add this line to your ~/.bashrc:

export SSH_AUTH_SOCK=/run/user/${EUID}/openssh_agent