diff -Nru systemd-240/debian/changelog systemd-240/debian/changelog --- systemd-240/debian/changelog 2019-05-16 17:22:15.000000000 -0400 +++ systemd-240/debian/changelog 2019-05-18 16:56:20.000000000 -0400 @@ -1,3 +1,27 @@ +systemd (240-6ubuntu7) eoan; urgency=medium + + * d/p/Add-check-to-switch-VTs-only-between-K_XLATE-or-K_UNICODE.patch: + - revert, due to upstream regression + - https://github.com/systemd/systemd/issues/12616 + * d/t/systemd-fsckd: + - remove expected failure from passing test (LP: #1829450) + * d/t/boot-and-services: + - don't fail if some kernel msgs are missed (LP: #1830479) + * d/t/storage: + - fix handling of scsi_debug module, test drives (LP: #1829347) + * d/p/ask-password-prevent-buffer-overrow-when-reading-fro.patch: + - prevent buffer overflow when reading keyring (LP: #1814373) + * d/p/network-wireguard-fixes-sending-wireguard-peer-setti.patch, + d/p/test-network-add-more-checks-in-NetworkdNetDevTests..patch, + d/p/sd-netlink-introduce-sd_netlink_message_append_socka.patch, + d/p/network-wireguard-use-sd_netlink_message_append_sock.patch: + - systemd doesn't set wireguard peer endpoint (LP: #1825378) + * d/t/boot-smoke: + - Fix false negative checking for running jobs after boot + (LP: #1825997) + + -- Dan Streetman Sat, 18 May 2019 16:56:20 -0400 + systemd (240-6ubuntu6) eoan; urgency=medium * Add check to switch VTs only between K_XLATE or K_UNICODE. diff -Nru systemd-240/debian/patches/ask-password-prevent-buffer-overrow-when-reading-fro.patch systemd-240/debian/patches/ask-password-prevent-buffer-overrow-when-reading-fro.patch --- systemd-240/debian/patches/ask-password-prevent-buffer-overrow-when-reading-fro.patch 1969-12-31 19:00:00.000000000 -0500 +++ systemd-240/debian/patches/ask-password-prevent-buffer-overrow-when-reading-fro.patch 2019-05-18 16:56:20.000000000 -0400 @@ -0,0 +1,35 @@ +From 59c55e73eaee345e1ee67c23eace8895ed499693 Mon Sep 17 00:00:00 2001 +From: Thadeu Lima de Souza Cascardo +Date: Mon, 13 May 2019 16:58:01 -0300 +Subject: [PATCH] ask-password: prevent buffer overrow when reading from + keyring + +When we read from keyring, a temporary buffer is allocated in order to +determine the size needed for the entire data. However, when zeroing that area, +we use the data size returned by the read instead of the lesser size allocate +for the buffer. + +That will cause memory corruption that causes systemd-cryptsetup to crash +either when a single large password is used or when multiple passwords have +already been pushed to the keyring. + +Signed-off-by: Thadeu Lima de Souza Cascardo + +Origin: upstream, https://github.com/systemd/systemd/commit/59c55e73eaee345e1ee67c23eace8895ed499693 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1814373 + +--- + src/shared/ask-password-api.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/src/shared/ask-password-api.c ++++ b/src/shared/ask-password-api.c +@@ -81,7 +81,7 @@ + if (n < m) + break; + +- explicit_bzero_safe(p, n); ++ explicit_bzero_safe(p, m); + free(p); + m *= 2; + } diff -Nru systemd-240/debian/patches/network-wireguard-fixes-sending-wireguard-peer-setti.patch systemd-240/debian/patches/network-wireguard-fixes-sending-wireguard-peer-setti.patch --- systemd-240/debian/patches/network-wireguard-fixes-sending-wireguard-peer-setti.patch 1969-12-31 19:00:00.000000000 -0500 +++ systemd-240/debian/patches/network-wireguard-fixes-sending-wireguard-peer-setti.patch 2019-05-18 16:56:20.000000000 -0400 @@ -0,0 +1,33 @@ +From 2301c54fa91379f5fe2458e28ed902aff5cf12d2 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 28 Jan 2019 09:42:35 +0100 +Subject: [PATCH] network/wireguard: fixes sending wireguard peer settings + +This fixes a bug introduced by e1f717d4a02e15ae11a191dd4962b2f4d117678d. + +Fixes #11579. + +Origin: upstream, https://github.com/systemd/systemd/pull/11580/commits/2301c54fa91379f5fe2458e28ed902aff5cf12d2 +Bug: https://github.com/systemd/systemd/issues/11579 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1825378 + +--- + src/network/netdev/wireguard.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c +index 1efd8863f6..dd239f79a8 100644 +--- a/src/network/netdev/wireguard.c ++++ b/src/network/netdev/wireguard.c +@@ -109,7 +109,7 @@ static int wireguard_set_peer_one(NetDev *netdev, sd_netlink_message *message, c + if (r < 0) + goto cancel; + +- if (!start) { ++ if (!*mask_start) { + r = sd_netlink_message_append_data(message, WGPEER_A_PRESHARED_KEY, &peer->preshared_key, WG_KEY_LEN); + if (r < 0) + goto cancel; +-- +2.20.1 + diff -Nru systemd-240/debian/patches/network-wireguard-use-sd_netlink_message_append_sock.patch systemd-240/debian/patches/network-wireguard-use-sd_netlink_message_append_sock.patch --- systemd-240/debian/patches/network-wireguard-use-sd_netlink_message_append_sock.patch 1969-12-31 19:00:00.000000000 -0500 +++ systemd-240/debian/patches/network-wireguard-use-sd_netlink_message_append_sock.patch 2019-05-18 16:56:20.000000000 -0400 @@ -0,0 +1,33 @@ +From 624a47694cad4c87b2e807c32db656f3e9d679c5 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 28 Jan 2019 12:27:37 +0100 +Subject: [PATCH] network/wireguard: use + sd_netlink_message_append_sockaddr_in{,6}() + +Origin: upstream, https://github.com/systemd/systemd/pull/11580/commits/624a47694cad4c87b2e807c32db656f3e9d679c5 +Bug: https://github.com/systemd/systemd/issues/11579 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1825378 + +--- + src/network/netdev/wireguard.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c +index dd239f79a8..0c0b16d1da 100644 +--- a/src/network/netdev/wireguard.c ++++ b/src/network/netdev/wireguard.c +@@ -123,9 +123,9 @@ static int wireguard_set_peer_one(NetDev *netdev, sd_netlink_message *message, c + goto cancel; + + if (peer->endpoint.sa.sa_family == AF_INET) +- r = sd_netlink_message_append_data(message, WGPEER_A_ENDPOINT, &peer->endpoint.in, sizeof(peer->endpoint.in)); ++ r = sd_netlink_message_append_sockaddr_in(message, WGPEER_A_ENDPOINT, &peer->endpoint.in); + else if (peer->endpoint.sa.sa_family == AF_INET6) +- r = sd_netlink_message_append_data(message, WGPEER_A_ENDPOINT, &peer->endpoint.in6, sizeof(peer->endpoint.in6)); ++ r = sd_netlink_message_append_sockaddr_in6(message, WGPEER_A_ENDPOINT, &peer->endpoint.in6); + if (r < 0) + goto cancel; + } +-- +2.20.1 + diff -Nru systemd-240/debian/patches/sd-netlink-introduce-sd_netlink_message_append_socka.patch systemd-240/debian/patches/sd-netlink-introduce-sd_netlink_message_append_socka.patch --- systemd-240/debian/patches/sd-netlink-introduce-sd_netlink_message_append_socka.patch 1969-12-31 19:00:00.000000000 -0500 +++ systemd-240/debian/patches/sd-netlink-introduce-sd_netlink_message_append_socka.patch 2019-05-18 16:56:20.000000000 -0400 @@ -0,0 +1,105 @@ +From abd48ec87f2ac5dd571a99dcb4db88c4affdffc8 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 28 Jan 2019 12:19:29 +0100 +Subject: [PATCH] sd-netlink: introduce + sd_netlink_message_append_sockaddr_in{,6}() + +Origin: upstream, https://github.com/systemd/systemd/pull/11580/commits/abd48ec87f2ac5dd571a99dcb4db88c4affdffc8 +Bug: https://github.com/systemd/systemd/issues/11579 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1825378 + +--- + src/libsystemd/sd-netlink/netlink-message.c | 36 +++++++++++++++++++++ + src/libsystemd/sd-netlink/netlink-types.c | 2 +- + src/libsystemd/sd-netlink/netlink-types.h | 1 + + src/systemd/sd-netlink.h | 2 ++ + 4 files changed, 40 insertions(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c +index b0b25639f4..5e9bc45139 100644 +--- a/src/libsystemd/sd-netlink/netlink-message.c ++++ b/src/libsystemd/sd-netlink/netlink-message.c +@@ -370,6 +370,42 @@ int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short typ + return 0; + } + ++int sd_netlink_message_append_sockaddr_in(sd_netlink_message *m, unsigned short type, const struct sockaddr_in *data) { ++ int r; ++ ++ assert_return(m, -EINVAL); ++ assert_return(!m->sealed, -EPERM); ++ assert_return(data, -EINVAL); ++ ++ r = message_attribute_has_type(m, NULL, type, NETLINK_TYPE_SOCKADDR); ++ if (r < 0) ++ return r; ++ ++ r = add_rtattr(m, type, data, sizeof(struct sockaddr_in)); ++ if (r < 0) ++ return r; ++ ++ return 0; ++} ++ ++int sd_netlink_message_append_sockaddr_in6(sd_netlink_message *m, unsigned short type, const struct sockaddr_in6 *data) { ++ int r; ++ ++ assert_return(m, -EINVAL); ++ assert_return(!m->sealed, -EPERM); ++ assert_return(data, -EINVAL); ++ ++ r = message_attribute_has_type(m, NULL, type, NETLINK_TYPE_SOCKADDR); ++ if (r < 0) ++ return r; ++ ++ r = add_rtattr(m, type, data, sizeof(struct sockaddr_in6)); ++ if (r < 0) ++ return r; ++ ++ return 0; ++} ++ + int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data) { + int r; + +diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c +index bb7e8c33ba..9dcd3f2ac8 100644 +--- a/src/libsystemd/sd-netlink/netlink-types.c ++++ b/src/libsystemd/sd-netlink/netlink-types.c +@@ -721,7 +721,7 @@ static const NLType genl_wireguard_peer_types[] = { + [WGPEER_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, + [WGPEER_A_PRESHARED_KEY] = { .size = WG_KEY_LEN }, + [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U16 }, +- [WGPEER_A_ENDPOINT] = { /* either size of sockaddr_in or sockaddr_in6 depending on address family */ }, ++ [WGPEER_A_ENDPOINT] = { .type = NETLINK_TYPE_SOCKADDR }, + [WGPEER_A_ALLOWEDIPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_allowedip_type_system }, + }; + +diff --git a/src/libsystemd/sd-netlink/netlink-types.h b/src/libsystemd/sd-netlink/netlink-types.h +index 3133e4863d..b84fa4762b 100644 +--- a/src/libsystemd/sd-netlink/netlink-types.h ++++ b/src/libsystemd/sd-netlink/netlink-types.h +@@ -16,6 +16,7 @@ enum { + NETLINK_TYPE_CACHE_INFO, + NETLINK_TYPE_NESTED, /* NLA_NESTED */ + NETLINK_TYPE_UNION, ++ NETLINK_TYPE_SOCKADDR, + }; + + typedef enum NLMatchType { +diff --git a/src/systemd/sd-netlink.h b/src/systemd/sd-netlink.h +index a97a965ec4..9e6e437bab 100644 +--- a/src/systemd/sd-netlink.h ++++ b/src/systemd/sd-netlink.h +@@ -78,6 +78,8 @@ int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, ui + int sd_netlink_message_append_data(sd_netlink_message *m, unsigned short type, const void *data, size_t len); + int sd_netlink_message_append_in_addr(sd_netlink_message *m, unsigned short type, const struct in_addr *data); + int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short type, const struct in6_addr *data); ++int sd_netlink_message_append_sockaddr_in(sd_netlink_message *m, unsigned short type, const struct sockaddr_in *data); ++int sd_netlink_message_append_sockaddr_in6(sd_netlink_message *m, unsigned short type, const struct sockaddr_in6 *data); + int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data); + int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short type, const struct ifa_cacheinfo *info); + +-- +2.20.1 + diff -Nru systemd-240/debian/patches/series systemd-240/debian/patches/series --- systemd-240/debian/patches/series 2019-05-16 17:22:15.000000000 -0400 +++ systemd-240/debian/patches/series 2019-05-18 16:56:20.000000000 -0400 @@ -143,4 +143,9 @@ shared-dissect-image-make-sure-that-we-don-t-truncate-dev.patch journal-avoid-buffer-overread-when-locale-name-is-too-lon.patch Move-verify_vc_kbmode-to-terminal-util.c-as-vt_verify_kbm.patch -Add-check-to-switch-VTs-only-between-K_XLATE-or-K_UNICODE.patch +#Add-check-to-switch-VTs-only-between-K_XLATE-or-K_UNICODE.patch +network-wireguard-fixes-sending-wireguard-peer-setti.patch +test-network-add-more-checks-in-NetworkdNetDevTests..patch +sd-netlink-introduce-sd_netlink_message_append_socka.patch +network-wireguard-use-sd_netlink_message_append_sock.patch +ask-password-prevent-buffer-overrow-when-reading-fro.patch diff -Nru systemd-240/debian/patches/test-network-add-more-checks-in-NetworkdNetDevTests..patch systemd-240/debian/patches/test-network-add-more-checks-in-NetworkdNetDevTests..patch --- systemd-240/debian/patches/test-network-add-more-checks-in-NetworkdNetDevTests..patch 1969-12-31 19:00:00.000000000 -0500 +++ systemd-240/debian/patches/test-network-add-more-checks-in-NetworkdNetDevTests..patch 2019-05-18 16:56:20.000000000 -0400 @@ -0,0 +1,45 @@ +From 16ab043bda149ab1117b27464aa98d98ed4f2616 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 28 Jan 2019 10:09:22 +0100 +Subject: [PATCH] test-network: add more checks in + NetworkdNetDevTests.test_wireguard + +Origin: upstream, https://github.com/systemd/systemd/pull/11580/commits/16ab043bda149ab1117b27464aa98d98ed4f2616 +Bug: https://github.com/systemd/systemd/issues/11579 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1825378 + +--- + test/test-network/conf/25-wireguard.netdev | 3 ++- + test/test-network/systemd-networkd-tests.py | 10 ++++++++++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +--- a/test/test-network/conf/25-wireguard.netdev ++++ b/test/test-network/conf/25-wireguard.netdev +@@ -10,6 +10,7 @@ + [WireGuardPeer] + PublicKey=RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA= + AllowedIPs=fd31:bf08:57cb::/48,192.168.26.0/24 +-Endpoint=wireguard.example.com:51820 ++#Endpoint=wireguard.example.com:51820 ++Endpoint=192.168.27.3:51820 + PresharedKey=IIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M= + PersistentKeepalive=20 +--- a/test/test-network/systemd-networkd-tests.py ++++ b/test/test-network/systemd-networkd-tests.py +@@ -388,6 +388,16 @@ + + if shutil.which('wg'): + subprocess.call('wg') ++ output = subprocess.check_output(['wg', 'show', 'wg99', 'listen-port']).rstrip().decode('utf-8') ++ self.assertTrue(output, '51820') ++ output = subprocess.check_output(['wg', 'show', 'wg99', 'fwmark']).rstrip().decode('utf-8') ++ self.assertTrue(output, '0x4d2') ++ output = subprocess.check_output(['wg', 'show', 'wg99', 'allowed-ips']).rstrip().decode('utf-8') ++ self.assertTrue(output, 'RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t192.168.26.0/24 fd31:bf08:57cb::/48') ++ output = subprocess.check_output(['wg', 'show', 'wg99', 'persistent-keepalive']).rstrip().decode('utf-8') ++ self.assertTrue(output, 'RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t20') ++ output = subprocess.check_output(['wg', 'show', 'wg99', 'endpoints']).rstrip().decode('utf-8') ++ self.assertTrue(output, 'RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t192.168.27.3:51820') + + self.assertTrue(self.link_exits('wg99')) + diff -Nru systemd-240/debian/tests/boot-and-services systemd-240/debian/tests/boot-and-services --- systemd-240/debian/tests/boot-and-services 2019-05-16 17:22:15.000000000 -0400 +++ systemd-240/debian/tests/boot-and-services 2019-05-18 16:56:20.000000000 -0400 @@ -100,15 +100,17 @@ out = subprocess.check_output(['ps', 'u', '-C', 'rsyslogd']) self.assertIn(b'bin/rsyslogd', out) self.active_unit('rsyslog') + out = subprocess.check_output(['journalctl']) + if re.search(b'Missed.*kernel messages', out): + # if we missed some, just check for any kernel msg + kernel_regex = 'kernel:.*' + else: + # otherwise, check for the first(ish) kernel msg + kernel_regex = 'kernel:.*[cC]ommand line:' with open('/var/log/syslog') as f: log = f.read() # has kernel messages - try: - self.assertRegex(log, 'kernel:.*[cC]ommand line:') - except AssertionError: - # hm syslog is trimmed, for some reason?! - subprocess.call(['journalctl', '-k']) - self.assertRegex(log, 'kernel:.*') + self.assertRegex(log, kernel_regex) # has init messages self.assertRegex(log, 'systemd.*Reached target Graphical Interface') # has other services @@ -180,8 +182,14 @@ def test_no_options(self): out = subprocess.check_output(['journalctl']) + if re.search(b'Missed.*kernel messages', out): + # if we missed some, just check for any kernel msg + kernel_regex = b'kernel:.*' + else: + # otherwise, check for the first(ish) kernel msg + kernel_regex = b'kernel:.*[cC]ommand line:' # has kernel messages - self.assertRegex(out, b'kernel:.*[cC]ommand line:') + self.assertRegex(out, kernel_regex) # has init messages self.assertRegex(out, b'systemd.*Reached target Graphical Interface') # has other services diff -Nru systemd-240/debian/tests/boot-smoke systemd-240/debian/tests/boot-smoke --- systemd-240/debian/tests/boot-smoke 2019-05-16 17:22:15.000000000 -0400 +++ systemd-240/debian/tests/boot-smoke 2019-05-18 16:56:20.000000000 -0400 @@ -5,6 +5,10 @@ # with --copy /host/path/systemd-foo:/tmp/systemd-replace/systemd-foo set -e +RUNNING_TIMEOUT=35 +JOBS_TIMEOUT=35 +REBOOTS=5 + . `dirname $0`/assert.sh if [ -z "$ADT_REBOOT_MARK" ]; then @@ -32,7 +36,7 @@ ret=0 echo "waiting to boot..." - TIMEOUT=35 + TIMEOUT=$RUNNING_TIMEOUT while [ $TIMEOUT -ge 0 ]; do state="$(systemctl is-system-running || true)" case $state in @@ -71,9 +75,15 @@ fi echo "checking that there are no running jobs" - running="$(systemctl --no-pager --no-legend list-jobs || true)" + TIMEOUT=$JOBS_TIMEOUT + while [ $TIMEOUT -ge 0 ]; do + running="$(systemctl --no-pager --no-legend list-jobs || true)" + [ -n "$running" ] || break + sleep 1 + TIMEOUT=$((TIMEOUT - 1)) + done if [ -n "$running" ]; then - echo "running jobs after remaining timeout $TIMEOUT: $running" + echo "running jobs after remaining timeout $JOBS_TIMEOUT: $running" journalctl --sync journalctl -ab > $ADT_ARTIFACTS/journal.txt udevadm info --export-db > $ADT_ARTIFACTS/udevdb.txt @@ -85,7 +95,7 @@ fi fi -if [ "$ADT_REBOOT_MARK" -ge 5 ]; then +if [ "$ADT_REBOOT_MARK" -ge "$REBOOTS" ]; then exit 0 fi diff -Nru systemd-240/debian/tests/storage systemd-240/debian/tests/storage --- systemd-240/debian/tests/storage 2019-05-16 17:22:15.000000000 -0400 +++ systemd-240/debian/tests/storage 2019-05-18 16:56:20.000000000 -0400 @@ -12,44 +12,69 @@ from glob import glob -@unittest.skipIf(os.path.isdir('/sys/module/scsi_debug'), - 'The scsi_debug module is already loaded') -@unittest.skipIf(subprocess.call(['modinfo', 'scsi_debug'], stdout=subprocess.DEVNULL) != 0, - 'The scsi_debug module is not available') +SCSI_DEBUG_DIR='/sys/bus/pseudo/drivers/scsi_debug' + class FakeDriveTestBase(unittest.TestCase): @classmethod def setUpClass(klass): - # create a fake SCSI hard drive - subprocess.check_call(['modprobe', 'scsi_debug', 'dev_size_mb=32']) + if not os.path.isdir(SCSI_DEBUG_DIR): + subprocess.call(['modprobe', 'scsi_debug', 'dev_size_mb=32'], + stderr=subprocess.DEVNULL) + # if still not available, we can't run any of our tests + if not os.path.isdir(SCSI_DEBUG_DIR): + klass.skipTest('scsi_debug module not loaded') + + def setUp(self): + # remove any existing drives, then add back one for us to use + self.remove_scsi_debug_drives() + with open(os.path.join(SCSI_DEBUG_DIR, 'add_host'), 'r+') as f: + print('Adding scsi_debug drive') + f.write('1') + for wait in range(10): + f.seek(0) + if f.read().strip() == '1': + break + time.sleep(0.1) + else: + self.skipTest('Could not add scsi_debug drive to test') # wait until drive got created sys_dirs = [] - while not sys_dirs: - sys_dirs = glob('/sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*:*/block') + for tries in range(100): + sys_dirs = glob(os.path.join(SCSI_DEBUG_DIR, + 'adapter*/host*/target*/*:*/block')) + if sys_dirs: + break time.sleep(0.1) - assert len(sys_dirs) == 1 + if len(sys_dirs) < 1: + self.skipTest('could not find scsi_debug block device') + elif len(sys_dirs) > 1: + self.skipTest('too many scsi_debug block devices (%s)' % len(sys_dirs)) devs = os.listdir(sys_dirs[0]) assert len(devs) == 1 - klass.device = '/dev/' + devs[0] - - @classmethod - def tearDownClass(klass): - # create a fake SCSI hard drive - # if this fails to remove the module, will not be able to rerun this test again - # but this is not critical to cleanup everything, if the tests passed otherwise - subprocess.call(['rmmod', 'scsi_debug']) + self.device = '/dev/' + devs[0] def tearDown(self): - # clear drive - with open(self.device, 'wb') as f: - block = b'0' * 1048576 - try: - while True: - f.write(block) - except OSError: - pass + self.remove_scsi_debug_drives() subprocess.check_call(['udevadm', 'settle']) subprocess.check_call(['systemctl', 'daemon-reload']) + def remove_scsi_debug_drives(self): + with open(os.path.join(SCSI_DEBUG_DIR, 'add_host'), 'r+') as f: + n = f.read().strip() + f.seek(0) + if n == '0': + return + print('Removing %s scsi_debug test drive(s)' % n) + f.write('-%s' % n) + for wait in range(50): + f.seek(0) + n = f.read().strip() + if n == '0': + break + time.sleep(0.1) + else: + self.skipTest('Could not remove %s scsi_debug drives' % n) + class CryptsetupTest(FakeDriveTestBase): def setUp(self): @@ -219,6 +244,7 @@ self.format_luks() with open('/etc/crypttab', 'w') as f: f.write('%s %s none luks,tmp\n' % (self.plaintext_name, self.device)) + self.apply('cryptsetup.target') mountpoint = '/run/crypt1.systemdtest' os.mkdir(mountpoint) @@ -234,17 +260,15 @@ self.apply('local-fs.target') # should be mounted - found = False with open('/proc/mounts') as f: for line in f: fields = line.split() if fields[0] == self.plaintext_dev: self.assertEqual(fields[1], mountpoint) self.assertEqual(fields[2], 'ext2') - found = True break - if not found: - self.fail('%s is not mounted' % self.plaintext_dev) + else: + self.fail('%s is not mounted' % self.plaintext_dev) if __name__ == '__main__': diff -Nru systemd-240/debian/tests/systemd-fsckd systemd-240/debian/tests/systemd-fsckd --- systemd-240/debian/tests/systemd-fsckd 2019-05-16 17:22:15.000000000 -0400 +++ systemd-240/debian/tests/systemd-fsckd 2019-05-18 16:56:20.000000000 -0400 @@ -130,7 +130,6 @@ self.assertWasRunning('plymouth-start') self.assertSystemRunning() - @unittest.expectedFailure def test_systemd_fsck_with_plymouth_failure(self): '''Ensure that a failing plymouth doesn't prevent fsckd to reconnect/exit''' if not self._after_reboot: