Bug 465188 - When using Systemd boot, startplasma-x11 strips trailing spaces from its environment variables for calling plasmashell process
Summary: When using Systemd boot, startplasma-x11 strips trailing spaces from its envi...
Status: REOPENED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Startup process (show other bugs)
Version: 5.26.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-02 18:23 UTC by kde
Modified: 2023-04-02 09:34 UTC (History)
3 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 kde 2023-02-02 18:23:44 UTC
SUMMARY
***
Trailing spaces from environment variables get stripped between startplasma-x11 and plasmashell
***

Sorry, could not find the suitable category for plasma-workspace.
Originally affected my $PS1 prompt variable.

STEPS TO REPRODUCE
1. Put an export to /etc/profile (or profile.d/) with a trailing space: export XTEST=" xxx "
2. Login as the user
3. Open any terminal (for example Konsole+bash) and print the var: echo X${XTEST}X

OBSERVED RESULT
"X xxxX"

EXPECTED RESULT
"X xxx X"

SOFTWARE/OS VERSIONS
KDE Plasma Version:  5.26.5
KDE Frameworks Version: 5.102.0
Qt Version:  5.15.8

ADDITIONAL INFORMATION
Not sure if this bug is systemd related (because plasma-plasmashell.service is involved).
I've compared /proc/*/environ of plasmashell to startplasma-x11 and all trailing spaces are definitely missing.
pids of both components are directly related.
Directly sourcing the /etc/profile.d/file in a bash session works as expected.
No suspicious systemd logs found.
Env tracking in /usr/share/sddm/scripts/Xsession went "all good".
Also affects a fresh Kubuntu 22.10 installation.
Comment 1 Nate Graham 2023-02-06 21:20:33 UTC
If you disable systemd boot by running `kwriteconfig5 --file startkderc --group General --key systemdBoot false` in a terminal window and then rebooting, does it still happen?
Comment 2 kde 2023-02-06 22:25:09 UTC
(In reply to Nate Graham from comment #1)
> If you disable systemd boot by running `kwriteconfig5 --file startkderc
> --group General --key systemdBoot false` in a terminal window and then
> rebooting, does it still happen?

Can confirm, "~/.config/startkderc" has been created with content:
[General]
systemdBoot=false

Now it works as expected:

/etc/profile.d/*:
export TESTVAR=" xxx "

echo x${TESTVAR}x
"x xxx x"

If related: I'm not using systemd-boot btw. rEFInd just calls vmlinuz.
Comment 3 Nate Graham 2023-02-06 22:28:54 UTC
In that case it's an issue in either systemd or our generator code. I'll leave it here for David Edmundson to triage further. Might also be intentional. In any event, relying on trailing spaces seems fragile.
Comment 4 kde 2023-02-06 22:39:47 UTC
(In reply to Nate Graham from comment #3)
> Might also be intentional. In any event, relying on trailing spaces seems fragile.

Stripping trailing white spaces for all environment variables feels worse. I don't have a better example than my $PS1 which already wasn't critical enough :-)
Maybe a trailing LF is being stripped too? That could affect scripts in envs if the recommended LF on the last line is missing.

Thank you for your time!
Comment 5 Nate Graham 2023-02-06 22:44:23 UTC
If it's a bug in our code, I think it's reasonable to fix it. I'm just trying to prepare you for a potential response of "this is intentional, deal with it" if it ends up being a Systemd issue.
Comment 6 kde 2023-03-31 10:31:50 UTC
I've just noticed my $PS1 correctly displays the trailing space again. So this bug seems to be fixed silently? If a dev did something, I would grant a RESOLVED.

I did not test on Kubuntu, but my Arch machine is fine now. Thank you!
Comment 7 Nate Graham 2023-03-31 14:14:02 UTC
I don't think we made any changes here, so it was probably a systemd change/fix. Thanks a lot for following up!
Comment 8 kde 2023-04-02 09:34:08 UTC
Sorry, my bad... Forgot to undo "systemdBoot false". Bug still exists.

I would dig into the KDE code to investigate, but I can't find the component.