Bug 489834 - Action opening attachment fails with "Invalid environment block." due to environment variable of third party software
Summary: Action opening attachment fails with "Invalid environment block." due to envi...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 6.2.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-06 15:39 UTC by Alexander
Modified: 2024-07-06 20:39 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2024-07-06 15:39:39 UTC
SUMMARY
openSUSE Tumbleweed, up-to-date. Wayland session. A software called midnight commander is installed. I sets an environment variable 

BASH_FUNC_mc%%=() {  . /usr/share/mc/mc-wrapper.sh
}
_=/usr/bin/printenv

This may or maybe not posix conform. But since update to a recent version of Plasma6 this variable prevents kmail from opening an attachment. OK, after reading this sentence again, I have to admit that I guess that the variable is the cause for the kmail malfunction. However, after I uninstalled mc, kmail works as expected.

After starting kmail on command line and clicking on an attachment in kmail to make it open a pdf e.g.,  the error message there is:

kf.kio.gui: Failed to launch process as service: "app-org.kde.okular@6af406497e054a04a6adc583bf0242da.service" "org.freedesktop.DBus.Error.InvalidArgs" "Invalid environment block."

STEPS TO REPRODUCE
1. Install midnight commander
2. reboot
3. open kmail and try to open an attachment to an email, a pdf e.g.

I reported that bug here as well https://bugzilla.opensuse.org/show_bug.cgi?id=1227388

I regard that behaviour of kmail as a bug, because even the environment variable set by mc is somehow wrong, kmail should be immune to such errors. Besides that, isn't this even a security risk, if any other software which sets a wrong variable can cause kmail to malfunction?

OBSERVED RESULT
Error message

EXPECTED RESULT
Okular opens displaying attached pdf

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 

Operating System: openSUSE Tumbleweed 20240704
KDE Plasma Version: 6.1.2
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.2
Kernel Version: 6.9.7-1-default (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i7-1165G7 @ 2.80GHz
Memory: 31.1 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Comment 1 Nicolas Fella 2024-07-06 20:31:48 UTC
Only uppercase letters and underscores are allowed in environment variable names, systemd refuses to launch processes with non-conforming environments.

https://invent.kde.org/frameworks/kio/-/commit/4e27e6d9014a51b9c2b4698979e088cb1d009ac0 strips non-conforming variables before launch
Comment 2 Fabian Vogt 2024-07-06 20:39:58 UTC
(In reply to Nicolas Fella from comment #1)
> Only uppercase letters and underscores are allowed in environment variable
> names,

That's an arbitrary restriction purely made by systemd.

POSIX says (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html):

> Environment variable names used by the utilities in the Shell and Utilities volume of POSIX.1-2017 consist solely of uppercase letters, digits, and the <underscore> ( '_' ) from the characters defined in Portable Character Set and do not begin with a digit. Other characters may be permitted by an implementation; applications shall tolerate the presence of such names.

> systemd refuses to launch processes with non-conforming environments.

i.e. systemd actually violates POSIX because it does not tolerate what the implementation (Linux) permits (all except = and NUL)...

> https://invent.kde.org/frameworks/kio/-/commit/
> 4e27e6d9014a51b9c2b4698979e088cb1d009ac0 strips non-conforming variables
> before launch