shared/bus-unit-util: tweak bus_append_exec_command to use Ex prop only if necessary
This changes little in behaviour, the conceptual part is more important. The non-Ex variant is the actual name on the command line, and we should use the non-Ex D-Bus property too, if it works. This increases compatibility with old versions. But the code was mostly doing the right thing. Even the tests tested the right thing. Follow-up forb3d593673cand898fc00e79. The test is simplified by taking advantage of the fact that both names on the commandline are supposed to behave identically. Partially resolves https://github.com/systemd/systemd/issues/37174.
This commit is contained in:
@@ -20,25 +20,16 @@ property[7_seven]=ExecStopPost
|
||||
# These should all get upgraded to the corresponding Ex property as the non-Ex variant
|
||||
# does not support the ":" prefix (no-env-expand).
|
||||
for c in "${!property[@]}"; do
|
||||
systemd-run --unit="$c" -r -p "Type=oneshot" -p "${property[$c]}=:/bin/echo \${$c}" /bin/true
|
||||
systemd-run --unit="$c" -r -p "Type=oneshot" -p "${property[$c]}=:/bin/echo \${$c}" true
|
||||
systemctl show -p "${property[$c]}" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; ignore_errors=no"
|
||||
systemctl show -p "${property[$c]}Ex" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; flags=no-env-expand"
|
||||
done
|
||||
|
||||
declare -A property_ex
|
||||
|
||||
property_ex[1_one_ex]=ExecConditionEx
|
||||
property_ex[2_two_ex]=ExecStartPreEx
|
||||
property_ex[3_three_ex]=ExecStartEx
|
||||
property_ex[4_four_ex]=ExecStartPostEx
|
||||
property_ex[5_five_ex]=ExecReloadEx
|
||||
property_ex[6_six_ex]=ExecStopEx
|
||||
property_ex[7_seven_ex]=ExecStopPostEx
|
||||
|
||||
for c in "${!property_ex[@]}"; do
|
||||
systemd-run --unit="$c" -r -p "Type=oneshot" -p "${property_ex[$c]}=:/bin/echo \${$c}" /bin/true
|
||||
systemctl show -p "${property_ex[$c]%??}" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; ignore_errors=no"
|
||||
systemctl show -p "${property_ex[$c]}" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; flags=no-env-expand"
|
||||
# Ex names on the commandline are supported for backward compat.
|
||||
for c in "${!property[@]}"; do
|
||||
systemd-run --unit="${c}_ex" -r -p "Type=oneshot" -p "${property[$c]}Ex=:/bin/echo \${$c}" true
|
||||
systemctl show -p "${property[$c]}" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; ignore_errors=no"
|
||||
systemctl show -p "${property[$c]}Ex" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; flags=no-env-expand"
|
||||
done
|
||||
|
||||
systemd-analyze log-level info
|
||||
|
||||
Reference in New Issue
Block a user