Skip to content

Commit 76cf95e

Browse files
committed
Also "mask" services when disabling them
In addition to disabling services when `snap set service.{ssh,syslog}.disable=true` is called we need to mask them. The reason is that the /etc/systemd/system directory is marked "synced" and the core snap has a "syslog.service" symlink. So on each boot if there is no "syslog.service" (or ssh) link there writable-path will happily copy it. This is not what we want. By using "mask" in addition to disable systemd will create a symlink with the name of the service to /dev/null. This prevents writable-path from interfering.
1 parent 92acd7a commit 76cf95e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

hooks/configure

+10-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ switch_service() {
5252
false)
5353
# When the unit is already enabled but not active a call with
5454
# --now does start the unit so we have to check for that case
55-
# and explicitly start the unit.
55+
# and explicitly start the unit.
56+
if systemctl status "$2.service"|grep -q "Loaded: masked"; then
57+
systemctl unmask "$2.service"
58+
fi
5659
if [ "$(systemctl is-enabled "$2.service")" = "disabled" ]; then
5760
systemctl enable "$2.service"
5861
fi
@@ -66,6 +69,12 @@ switch_service() {
6669
# in two steps here and disable first and then stopping the
6770
# service unit.
6871
systemctl disable "$2.service"
72+
# we need to mask the unit so that there is a symlink
73+
# with the service name in /etc/systemd/system. If
74+
# there is nothing the "writable-path" magic will
75+
# copy the "$2.service" symlink on boot because the
76+
# directory /etc/systemd/system is "synced"
77+
systemctl mask "$2.service"
6978
systemctl stop "$2.service"
7079
;;
7180
*)

0 commit comments

Comments
 (0)