Commit 7670688f authored by segfault's avatar segfault

Prevent service autostart when installing packages in contaienr

This fixes that SFTP installation failed because it involved starting
sshd, which failed because port 22 was already used by the host.
parent e1fe166b
......@@ -123,7 +123,8 @@ class OnionService(DBusObject, metaclass=abc.ABCMeta):
self.TransactionStatus = _("Starting container to install packages")
self.container.create()
with self.container.run():
self.container.install_packages(self.packages)
with self.prevent_service_autostart():
self.container.install_packages(self.packages)
self.TransactionStatus = _("Configuring service")
self.create_state_dir()
......@@ -555,9 +556,12 @@ class OnionService(DBusObject, metaclass=abc.ABCMeta):
@contextmanager
def prevent_service_autostart(self):
self.systemd.mask(self.systemd_service)
policy_rc = Path(self.container.machine_dir, "usr/sbin/policy-rc.d")
# Forbid all invoke-rc.d actions
# See https://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt
policy_rc.write_text("exit 101")
policy_rc.chmod(0o755)
try:
yield
finally:
self.systemd.unmask(self.systemd_service)
self.systemd.daemon_reload()
policy_rc.unlink()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment