Bug 485075 - Launching apps from global shortcut ignores env set up by dbus-update-activation-environment
Summary: Launching apps from global shortcut ignores env set up by dbus-update-activat...
Status: REPORTED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keys (show other bugs)
Version: 6.0.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-05 11:27 UTC by Dino
Modified: 2024-04-05 20:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dino 2024-04-05 11:27:08 UTC
SUMMARY
Commands launched using any of the shortcuts does not inherit environment set using `dbus-update-activation-environment`.

This is causing problems especially when using SSH agent, which sets `SSH_AUTH_SOCK` as part of launching `ssh-agent` using the script in `/usr/lib/openssh/agent-launch`.

STEPS TO REPRODUCE
1. If Konsole is not present under `Applications` section, add Konsole application by clicking `Add New` > `Application...`. Then select `Konsole` and click `OK`.
2. Use the default key shortcut `Ctrl+Alt+T` or set the one of your choice.
3. Press `Apply`
4. Now hit the shortcut you selected in step 2.
5. In the terminal window, type the below command and press enter.
    ```
    export|grep SSH
    ```
6. The command will come back empty.
7. Close the window and make sure there are no other Konsole windows running. Alternatively, in the konsole window, type `killall konsole` and press enter.
8. Now launch Konsole from `Application Menu` or run it from KRunner (`Alt+F2`)
9. Try the same command as from step 5.
10. You will now see some output like below.
    ```
    declare -x SSH_AGENT_LAUNCHER="openssh"
    declare -x SSH_AUTH_SOCK="/run/user/1000/openssh_agent"
    ```

OBSERVED RESULT
When running Konsole via a global shortcut, no environment variables set from `dbus-update-activation-environment` are inherited.

EXPECTED RESULT
No matter how Konsole is run, it should inherit the environment set by `dbus-update-activation-environment`.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.3
Kernel Version: 6.5.0-26-generic (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-10510U CPU @ 1.80GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics

ADDITIONAL INFORMATION
Comment 1 Nicolas Fella 2024-04-05 12:49:48 UTC
See https://bugs.kde.org/show_bug.cgi?id=483541

I don't see how dbus-update-activation-environment is related. It updates the environment for DBus activation, but Konsole is not launched through DBus (whether by shortcut or not) since it's not a DBus-Activatable app
Comment 2 Dino 2024-04-05 19:47:30 UTC
Do pardon my ignorance. I am not that experienced with the technicality of launching apps on KDE / freedesktop system.

Do educate me! How is it that Konsole gets the expected environment variables when it is launched using KRunner?
Without fixing this, I can't see how Konsole and any scripts launched from within it can get SSH_AUTH_SOCK.

I tried setting the variable up in `$HOME/.config/plasma-workspace/env/ssh-agent-sock.sh`, but that actually prevents the `agent-launch` from working correctly, since the launch script checks for the variable to be empty.

I do have a workaround; just setting it in `.bashrc`, since the systemd service does not use temporary / randomised naming for the socket path.

I would rather have it working without. My worry is that a beginner would struggle to figure out...
Comment 3 Dino 2024-04-05 20:04:57 UTC
(In reply to Nicolas Fella from comment #1)
> See https://bugs.kde.org/show_bug.cgi?id=483541
> 
> I don't see how dbus-update-activation-environment is related. It updates
> the environment for DBus activation, but Konsole is not launched through
> DBus (whether by shortcut or not) since it's not a DBus-Activatable app

Pretty clear from the linked bug as to why its not working. I really hope a solution can be found for KDE Neon!