]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
00systemd: check if systemd version is a number
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 4 Jan 2019 15:51:15 +0000 (16:51 +0100)
committerLukáš Nykrýn <lnykryn@redhat.com>
Thu, 31 Jan 2019 12:52:41 +0000 (13:52 +0100)
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.

modules.d/00systemd/module-setup.sh

index 1ed4b34f689d9f2766084a5f2fc1ad3d36c005b5..3583062b5ce10a23136940e52bf595f76ffe367c 100755 (executable)
@@ -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