Files
systemd/test/test-execute
tunaichao 641c19e21e core: apply UnsetEnvironment= after command line expansion
UnsetEnvironment= was applied to the environment block before the
command line was expanded. Since the expansion looks the variables up
in that same block, any variable listed in UnsetEnvironment= was
already gone when $VAR in ExecStart= and friends was expanded, and a
whole-word $VAR reference was dropped from the command line.

Let the expansion see the full environment block, and apply the
unsetting only to the environment block passed to the executed
process. This way UnsetEnvironment= can hide variables from the
executed process without breaking command lines that reference them.

Extend the exec-unsetenvironment test accordingly: the whole-word
$VAR6 argument must be expanded into a positional parameter for the
shell, while ${VAR6-X} must evaluate to X in the executed process.

Also document in both the UnsetEnvironment= description and the
"Environment Variables in Spawned Processes" section that the
unsetting happens after command line variable expansion.

Fixes: #43343
2026-08-22 04:27:27 +09:00
..
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00
2025-12-07 09:09:03 +09:00