diff --git a/linux/systemd/qubesd.service b/linux/systemd/qubesd.service index 447117619..bb0051674 100644 --- a/linux/systemd/qubesd.service +++ b/linux/systemd/qubesd.service @@ -6,7 +6,6 @@ Before=systemd-user-sessions.service Type=notify ExecStart=/usr/bin/qubesd StandardOutput=syslog -KillMode=process Restart=on-failure RestartSec=1s diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index d117b0b76..f2245cbf7 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -1724,8 +1724,7 @@ async def start_daemon(*command, input=None, **kwargs): # some files (like clipboard) may be created as root and cause # permission problems qubes_group = grp.getgrnam('qubes') - command = ['runuser', '-u', qubes_group.gr_mem[0], '--'] + \ - list(command) + command = ['runuser', '-u', qubes_group.gr_mem[0], '--', *command] p = await asyncio.create_subprocess_exec(*command, **kwargs) stdout, stderr = await p.communicate(input=input) if p.returncode: @@ -1740,25 +1739,33 @@ async def start_qrexec_daemon(self, stubdom=False): self.log.debug('Starting the qrexec daemon') if stubdom: - qrexec_args = [str(self.stubdom_xid), self.name + '-dm', 'root'] + unit = "qrexec-daemon@" + self.name.replace("-", "\\x2d") + "\\x2ddm" + qrexec_args = ["--", str(self.stubdom_xid), self.name + '-dm', 'root'] else: - qrexec_args = [str(self.xid), self.name, self.default_user] + unit = "qrexec-daemon@" + self.name.replace("-", "\\x2d") + ".service" + qrexec_args = ["--", str(self.xid), self.name, self.default_user] if not self.debug: qrexec_args.insert(0, "-q") - qrexec_env = os.environ.copy() if not self.features.check_with_template('qrexec', False): self.log.debug( 'Starting the qrexec daemon in background, because of features') - qrexec_env['QREXEC_STARTUP_NOWAIT'] = '1' + env_arg = "-EQREXEC_STARTUP_NOWAIT=1" else: - qrexec_env['QREXEC_STARTUP_TIMEOUT'] = str(self.qrexec_timeout) + env_arg = "-EQREXEC_STARTUP_TIMEOUT=" + str(self.qrexec_timeout) try: await self.start_daemon( - qubes.config.system_path['qrexec_daemon_path'], *qrexec_args, - env=qrexec_env, stderr=subprocess.PIPE) + "systemd-run", + "--service-type=forking", + "--user", + "--unit=" + unit, + env_arg, + "--", + qubes.config.system_path['qrexec_daemon_path'], + *qrexec_args, + stderr=subprocess.PIPE) except subprocess.CalledProcessError as err: if err.returncode == 3: raise qubes.exc.QubesVMError( @@ -1782,6 +1789,11 @@ async def start_qubesdb(self): self.log.info('Starting Qubes DB') try: await self.start_daemon( + "systemd-run", + "--service-type=notify", + "--user", + "--unit=qubesdb-daemon@" + self.name.replace("-", "\\x2d") + ".service" + "--", qubes.config.system_path['qubesdb_daemon_path'], str(self.xid), self.name)