Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dracut-lib.sh: quote variables in parameter expansion patterns #794

Merged
merged 1 commit into from Apr 20, 2020

Commits on Apr 18, 2020

  1. dracut-lib.sh: quote variables in parameter expansion patterns

    According to POSIX.1-2017, 2.6.2 Parameter Expansion:
    
    ${parameter%[word]} [...] The word shall be expanded to produce a
    pattern.
    
    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:
    
    i='a\c'; j='\'; echo "${i%$j*}"
    
    This prints "a\c" because "$j*" is expanded to "\*", escaping the
    asterisk. In contrast,
    
    i='a\c'; j='\'; echo "${i%"$j"*}"
    
    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 unsuitable
    for 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
    
    str_replace "$luksname" '\' '\\'
    
    in modules.d/90crypt/parse-crypt.sh is not able to escape the
    backslashes any more, see dracutdevsGH-723, dracutdevsGH-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.
    diabonas committed Apr 18, 2020
    Configuration menu
    Copy the full SHA
    a8d8d19 View commit details
    Browse the repository at this point in the history