From: Frantisek Sumsal Date: Fri, 4 Jan 2019 15:51:15 +0000 (+0100) Subject: 00systemd: check if systemd version is a number X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31b995cd00376d2c4f210fbd78baaf897a2770f9;p=thirdparty%2Fdracut.git 00systemd: check if systemd version is a number The recent systemd upstream introduced a slightly modified version string which included information about a git commit, which however broke the version check in dracut. Unfortunately, the (( )) bash syntax went along with it in certain cases and introduced a pretty nasty issue, when the systemd would boot up but with slightly changed environment. To prevent this from happening in the future, let's at least check if the version parsed from the `systemd --version` output is a comparable number. --- diff --git a/modules.d/00systemd/module-setup.sh b/modules.d/00systemd/module-setup.sh index 1ed4b34f6..3583062b5 100755 --- a/modules.d/00systemd/module-setup.sh +++ b/modules.d/00systemd/module-setup.sh @@ -5,6 +5,11 @@ check() { [[ $mount_needs ]] && return 1 if require_binaries $systemdutildir/systemd; then SYSTEMD_VERSION=$($systemdutildir/systemd --version | { read a b a; echo $b; }) + # Check if the systemd version is a valid number + if ! [[ $SYSTEMD_VERSION =~ ^[0-9]+$ ]]; then + dfatal "systemd version is not a number ($SYSTEMD_VERSION)" + exit 1 + fi (( $SYSTEMD_VERSION >= 198 )) && return 0 return 255 fi