summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2014-02-18 20:52:28 +0100
committerMichael Stapelberg <michael@stapelberg.de>2014-02-18 20:52:28 +0100
commitcbfce36a16095b9f8155ecfb620e1d6194dcc7e7 (patch)
treee00c46e01f814c86712ce44932d642bce8c6e4b7
parent84217bc0b8beb60e082d6f836c4f6dc2e8d1fa28 (diff)
downloadinit-system-helpers-cbfce36a16095b9f8155ecfb620e1d6194dcc7e7.tar.gz
d-s-h: don’t error out when masking a service is not possible becausedebian/1.17
/etc/systemd/system/<service> already exists (but is not a symlink). Closes: #739090
-rw-r--r--debian/changelog8
-rwxr-xr-xscript/deb-systemd-helper8
-rw-r--r--t/001-deb-systemd-helper.t36
3 files changed, 50 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 9859f01..36e74b8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+init-system-helpers (1.17) unstable; urgency=low
+
+ * d-s-h: don’t error out when masking a service is not possible because
+ /etc/systemd/system/<service> already exists (but is not a symlink).
+ (Closes: #739090)
+
+ -- Michael Stapelberg <stapelberg@debian.org> Tue, 18 Feb 2014 20:52:20 +0100
+
init-system-helpers (1.16) unstable; urgency=low
* Don’t delete /etc/systemd/, only the hierarchy below /etc/systemd/system/.
diff --git a/script/deb-systemd-helper b/script/deb-systemd-helper
index f6b0fe7..efb6fe3 100755
--- a/script/deb-systemd-helper
+++ b/script/deb-systemd-helper
@@ -377,8 +377,12 @@ sub mask_service {
# If the link already exists, don’t do anything.
return if -l $mask_link && readlink($mask_link) eq '/dev/null';
- # Otherwise, error out.
- error("$mask_link already exists");
+ # If the file already exists, the user most likely copied the .service
+ # file to /etc/ to change it in some way. In this case we don’t need to
+ # mask the .service in the first place, since it will not be removed by
+ # dpkg.
+ debug "$mask_link already exists, not masking.";
+ return;
}
make_path(dirname($mask_link));
diff --git a/t/001-deb-systemd-helper.t b/t/001-deb-systemd-helper.t
index 4d814ea..652e3d1 100644
--- a/t/001-deb-systemd-helper.t
+++ b/t/001-deb-systemd-helper.t
@@ -208,4 +208,40 @@ $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');
+# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+# ┃ Verify “mask”/unmask don’t do anything when the user copied the .service. ┃
+# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
+
+unlink($mask_path);
+
+open($fh, '>', $mask_path);
+print $fh <<'EOT';
+[Unit]
+Description=test unit
+
+[Service]
+ExecStart=/bin/sleep 1
+
+[Install]
+WantedBy=multi-user.target
+EOT
+close($fh);
+
+ok(-e $mask_path, 'local service file exists');
+ok(! -l $mask_path, 'local service file is not a symlink');
+
+$retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh mask $random_unit");
+isnt($retval, -1, 'deb-systemd-helper could be executed');
+ok(!($retval & 127), 'deb-systemd-helper did not exit due to a signal');
+is($retval >> 8, 0, 'deb-systemd-helper exited with exit code 0');
+ok(-e $mask_path, 'local service file still exists');
+ok(! -l $mask_path, 'local service file is still not a symlink');
+
+$retval = system("DPKG_MAINTSCRIPT_PACKAGE=test $dsh unmask $random_unit");
+isnt($retval, -1, 'deb-systemd-helper could be executed');
+ok(!($retval & 127), 'deb-systemd-helper did not exit due to a signal');
+is($retval >> 8, 0, 'deb-systemd-helper exited with exit code 0');
+ok(-e $mask_path, 'local service file still exists');
+ok(! -l $mask_path, 'local service file is still not a symlink');
+
done_testing;