dracut-lib.sh: quote variables in parameter expansion patterns #794
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to POSIX.1-2017, 2.6.2 Parameter Expansion:
This means if word contains variables that itself contain special characters like asterisks or backslashes, these are treated as pattern characters unless the variable is quoted. Try e.g. the following example in bash, dash or (busybox) ash:
This prints
a\c
because$j*
is expanded to\*
, escaping the asterisk. In contrast,produces the expected result
a
because the backslash is not specially treated any more after quoting.The quotes that this commit adds have been previously removed in commit f9c96cf, citing issues with busybox hush without further specifying the actual error. I tested a recent busybox build (upstream commit 9aa751b08ab03d6396f86c3df77937a19687981b) and couldn't find any problems. Note that the above example always produces
a\c
in hush regardless of quoting$j
, making hush unsuitablefor use with dracut, but using quotes in parameter expansions generally works.
The unquoted variables break the "rd.luks.uuid/name" kernel command line options in dracut 050 because
dracut/modules.d/90crypt/parse-crypt.sh
Line 68 in 25c7a13
is not able to escape the backslashes any more, see #723, #727: backslashes in the
systemd-cryptsetup@.service
unit name stay unescaped for use in udev (cf. commit 0f6d93e), leading to failures in starting the unit.This partially reverts commit f9c96cf.