]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: make TEST-02-CRYPTSETUP a bit more robust
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 9 Jun 2020 14:51:55 +0000 (16:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Jun 2020 15:42:25 +0000 (17:42 +0200)
Prompted by systemd/systemd#16111.

* check if /var is a mountpoint - if not, something went wrong. In case
  of systemd/systemd#16111 the /failed file was created, because
  systemd-cryptsetup failed, but it ended up being empty, making the result
  check incorrectly pass
* forward journal messages to console - if we fail to mount /var,
  journald won't flush logs to the persistent storage and we end up
  empty handed and with no clue what went wrong

For example, without systemd/systemd#16111 and with this patch:
...
[FAILED] Failed to start systemd-cryptsetup@varcrypt.service.
See 'systemctl status systemd-cryptsetup@varcrypt.service' for details.
[DEPEND] Dependency failed for cryptsetup.target.
...
[    3.882451] systemd-cryptsetup[581]: Key file /etc/varkey is world-readable. This is not a good idea!
[    3.883946] systemd-cryptsetup[581]: WARNING: Locking directory /run/cryptsetup is missing!
[    3.884846] systemd-cryptsetup[581]: Failed to load Bitlocker superblock on device /dev/disk/by-uuid/180ba5ef-873b-4018-9968-47c23431f71a: Invalid argument
...
[    4.099451] sh[606]: + mountpoint /var
[    4.100025] sh[603]: + systemctl poweroff --no-block
[    4.101636] systemd[1]: Finished systemd-user-sessions.service.
[    4.102598] sh[608]: /var is not a mountpoint
[FAILED] Failed to start testsuite-02.service.

test/TEST-02-CRYPTSETUP/test.sh
test/test-functions
test/units/testsuite-02.service

index 27b42223d1725d6bf5b6d499a0e13800b501ce1c..ef1811122e1346d0a632978cd14efa2bdeb2e439 100755 (executable)
@@ -52,6 +52,10 @@ EOF
         cat >>$initdir/etc/fstab <<EOF
 /dev/mapper/varcrypt    /var    ext4    defaults 0 1
 EOF
+
+        # Forward journal messages to the console, so we have something
+        # to investigate even if we fail to mount the encrypted /var
+        echo ForwardToConsole=yes >> $initdir/etc/systemd/journald.conf
     )
 }
 
index 7302b207b0acbe9bd649e194750368d6c41444d9..df87261ea2f32eef1e176490e93c23502e3ff252 100644 (file)
@@ -80,6 +80,7 @@ BASICTOOLS=(
     mktemp
     modprobe
     mount
+    mountpoint
     mv
     nc
     nproc
index 701610b790b1f3f4f9f8a67d297bb50698be867b..13e7ec363996a939c565d6a43249a86a6a0100b9 100644 (file)
@@ -4,5 +4,5 @@ After=multi-user.target
 
 [Service]
 ExecStartPre=rm -f /failed /testok
-ExecStart=sh -x -c 'systemctl --state=failed --no-legend --no-pager >/failed ; echo OK > /testok'
+ExecStart=sh -x -e -c 'mountpoint /var; systemctl --state=failed --no-legend --no-pager >/failed; echo OK >/testok'
 Type=oneshot