From 557100573c4c0d68f6d3e82c593c4da751ce7818 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 19 Sep 2013 02:34:12 +0000 Subject: Store masked state to respect user’s masking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We cannot just unconditionally unmask services on installation time, otherwise “systemctl mask” executed by the user will be reversed. To that end, files in /var/lib/systemd/deb-systemd-helper-masked/ signal that d-s-h masked the service and is allowed to unmask it. --- t/001-deb-systemd-helper.t | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/001-deb-systemd-helper.t') diff --git a/t/001-deb-systemd-helper.t b/t/001-deb-systemd-helper.t index 5bb9ecd..4d814ea 100644 --- a/t/001-deb-systemd-helper.t +++ b/t/001-deb-systemd-helper.t @@ -191,4 +191,21 @@ is(readlink($mask_path), '/dev/null', 'service masked'); $retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh unmask $random_unit"); ok(! -e $mask_path, 'symlink no longer exists'); +# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +# ┃ Verify “mask”/unmask don’t do anything when the user already masked. ┃ +# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + +ok(! -l $mask_path, 'mask link does not exist yet'); +symlink('/dev/null', $mask_path); +ok(-l $mask_path, 'mask link exists'); +is(readlink($mask_path), '/dev/null', 'service masked'); + +$retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh mask $random_unit"); +ok(-l $mask_path, 'mask link exists'); +is(readlink($mask_path), '/dev/null', 'service still masked'); + +$retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh unmask $random_unit"); +ok(-l $mask_path, 'mask link exists'); +is(readlink($mask_path), '/dev/null', 'service still masked'); + done_testing; -- cgit v1.2.3