Skip to content

Commit f9c1fdf

Browse files
committed
Allow logging in to rescue/emergency shell as root
In Qubes OS guests, the console is _always_ the Xen console. There are _never_ untrusted entities with access to this under _any_ circumstances. The only supported way to get access to this from a VM is the admin.vm.Console service, which is (by design) equivalent to root access in the destination VM. Other consoles, such as a USB serial console, are not supported as domU consoles under Qubes OS. Therefore, set SYSTEMD_SULOGIN_FORCE=1 to tell systemd-sulogin-shell to pass --force to sulogin(8). Since the root account is locked in Qubes VMs, this causes sulogin(8) to allow login as root without a password. Use TTYPath= to enforce that the console is, in fact, the Xen console and not some other console, in case the assumption in the previous paragraph turns out false for some reason. This will break if the Xen drivers are not included in the guest kernel config, but an HVM guest with Qubes tools but no Xen drivers is not a supported configuration.
1 parent df1ffd4 commit f9c1fdf

File tree

8 files changed

+60
-3
lines changed

8 files changed

+60
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ SYSTEM_DROPINS += systemd-random-seed.service
5050
SYSTEM_DROPINS += tor.service [email protected]
5151
SYSTEM_DROPINS += systemd-timesyncd.service
5252
SYSTEM_DROPINS += systemd-logind.service
53-
SYSTEM_DROPINS += sysinit.target
53+
SYSTEM_DROPINS += sysinit.target emergency.service rescue.service
5454
ifeq ($(ENABLE_SELINUX),1)
5555
SYSTEM_DROPINS += selinux-autorelabel.target selinux-autorelabel.service
5656
endif

boot/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
LIBDIR ?= /usr/lib
22
SYSCONFDIR ?= /etc
33
GRUBCONFDIR ?= $(SYSCONFDIR)/default
4-
DRACUTCONFDIR ?= $(LIBDIR)/dracut/dracut.conf.d
54
GRUBCFGNAME ?= grub.qubes
5+
DRACUTDIR ?= $(LIBDIR)/dracut
6+
DRACUTCONFDIR ?= $(DRACUTDIR)/dracut.conf.d
7+
DRACUTMODDIR ?= $(DRACUTDIR)/modules.d
68

79
.PHONY: install
810

911
install:
1012
install -D -m 0644 grub.qubes $(DESTDIR)$(GRUBCONFDIR)/$(GRUBCFGNAME)
1113
install -D -m 0644 dracut-qubes.conf $(DESTDIR)$(DRACUTCONFDIR)/30-qubes.conf
14+
install -D -m 0755 module-setup.sh $(DESTDIR)$(DRACUTMODDIR)/99qubes/module-setup.sh

boot/dracut-qubes.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ omit_dracutmodules+=" tpm2-tss "
1919
# drivers, and none of the boot screen is visible in a qube anyway
2020
omit_dracutmodules+=" plymouth "
2121

22+
# Include Qubes OS-specific module to enable passwordless login on the Xen
23+
# console as root.
24+
force_add_dracutmodules+=" qubes "
25+
2226
# Exclude microcode, as VM cannot load it anyway, saves over 10MB of space
2327
early_microcode="no"

boot/module-setup.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
depends () {
2+
}
3+
4+
install () {
5+
if [ -h /lib ]; then
6+
inst_multiple /usr/lib/systemd/system/rescue.service.d/30_qubes.conf /usr/lib/systemd/system/emergency.service.d/30_qubes.conf
7+
else
8+
inst_multiple /lib/systemd/system/rescue.service.d/30_qubes.conf /lib/systemd/system/emergency.service.d/30_qubes.conf
9+
fi
10+
}

debian/qubes-core-agent.install

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ lib/systemd/system/sysinit.target.d/30_qubes.conf
107107
lib/systemd/system/systemd-timesyncd.service.d/30_qubes.conf
108108
lib/systemd/system/systemd-logind.service.d/30_qubes.conf
109109
lib/systemd/resolved.conf.d/30_resolved-no-mdns-or-llmnr.conf
110+
lib/systemd/system/rescue.service.d/30_qubes.conf
111+
lib/systemd/system/emergency.service.d/30_qubes.conf
110112
usr/lib/sysctl.d/20-qubes-core.conf
111113
usr/lib/systemd/user/tracker-extract-3.service.d/30_qubes.conf
112114
usr/lib/systemd/user/tracker-miner-fs-3.service.d/30_qubes.conf
@@ -139,6 +141,7 @@ usr/bin/qvm-connect-tcp
139141
usr/bin/qvm-sync-clock
140142
usr/lib/environment.d/60-gnome-software-fix.conf
141143
usr/lib/dracut/dracut.conf.d/30-qubes.conf
144+
usr/lib/dracut/modules.d/99qubes/module-setup.sh
142145
usr/lib/python3/dist-packages/qubesagent-*.egg-info/*
143146
usr/lib/python3/dist-packages/qubesagent/*
144147
usr/lib/qubes-bind-dirs.d/30_cron.conf

rpm_spec/core-agent.spec.in

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Requires: sed
134134
Requires: util-linux
135135
Requires: e2fsprogs
136136
Requires: hostname
137+
Requires: (%{name}-dracut if dracut)
137138
# for Qubes Manager VM updater
138139
Requires: xterm
139140
# for qubes-desktop-run
@@ -373,6 +374,19 @@ switching from user to root. Since all the user data in a VM is accessible
373374
already from normal user account, there is not much more to guard there. Qubes
374375
VMs are single user systems.
375376

377+
%package dracut
378+
Summary: Dracut configuration needed in Qubes OS
379+
License: GPL
380+
Group: Qubes
381+
Requires: dracut
382+
Requires: qubes-core-agent = %{version}
383+
384+
%description dracut
385+
Dracut configuration useful for Qubes OS. This enables
386+
passwordless login in rescue and emergency modes. Unlike the
387+
configuration in qubes-kernel-vm-support, it isn't needed to
388+
boot a VM, but it does make recovery of broken VMs easier.
389+
376390
%package thunar
377391
Summary: Thunar support for Qubes VM tools
378392
Requires: Thunar
@@ -521,6 +535,10 @@ sed -i \
521535
$RPM_BUILD_ROOT/etc/yum.repos.d/qubes-*.repo
522536
%endif
523537

538+
install -D -m 0644 boot/dracut-qubes.conf $RPM_BUILD_ROOT/usr/lib/dracut/dracut.conf.d/30-qubes.conf
539+
install -D -m 0644 boot/grub.qubes $RPM_BUILD_ROOT/etc/default/grub.qubes
540+
install -D -m 0755 boot/module-setup.sh $RPM_BUILD_ROOT/usr/lib/dracut/modules.d/99qubes/module-setup.sh
541+
524542
%if ! %with_sysvinit
525543
rm -rf $RPM_BUILD_ROOT/etc/init.d/qubes-* $RPM_BUILD_ROOT/etc/sysconfig/modules/qubes-core.modules
526544
%endif
@@ -1026,7 +1044,7 @@ rm -f %{name}-%{version}
10261044
/usr/lib/qubes/resize-rootfs
10271045
/usr/lib/qubes/set-default-text-editor
10281046
/usr/lib/qubes/tinyproxy-wrapper
1029-
/usr/lib/dracut/dracut.conf.d/30-qubes.conf
1047+
10301048
/usr/lib/environment.d/60-gnome-software-fix.conf
10311049
%dir /usr/lib/qubes/init
10321050
/usr/lib/qubes/init/bind-dirs.sh
@@ -1096,6 +1114,11 @@ rm -f %{name}-%{version}
10961114
/usr/share/caja-python/extensions/qvm_dvm_caja.py*
10971115
%endif
10981116

1117+
%files dracut
1118+
/usr/lib/dracut/dracut.conf.d/30-qubes.conf
1119+
%dir /usr/lib/dracut/modules.d/99qubes
1120+
/usr/lib/dracut/modules.d/99qubes/module-setup.sh
1121+
10991122
%files nautilus
11001123
/usr/share/nautilus-python/extensions/qvm_copy_nautilus.py*
11011124
/usr/share/nautilus-python/extensions/qvm_move_nautilus.py*
@@ -1304,6 +1327,10 @@ The Qubes core startup configuration for SystemD init.
13041327
%dir %_unitdir/sysinit.target.d
13051328
%_unitdir/sysinit.target.d/30_qubes.conf
13061329
%dir %_userunitdir/*.service.d
1330+
%dir %_unitdir/rescue.service.d
1331+
%dir %_unitdir/emergency.service.d
1332+
%_unitdir/emergency.service.d/30_qubes.conf
1333+
%_unitdir/rescue.service.d/30_qubes.conf
13071334
%_userunitdir/tracker-extract-3.service.d/30_qubes.conf
13081335
%_userunitdir/tracker-miner-fs-3.service.d/30_qubes.conf
13091336
%_userunitdir/tracker-miner-fs-control-3.service.d/30_qubes.conf
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Service]
2+
# Ensure that the console is the secure Xen console,
3+
# not e.g. a serial console that is exposed to the outside world.
4+
TTYPath=/dev/hvc0
5+
Environment=SYSTEMD_SULOGIN_FORCE=1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Service]
2+
# Ensure that the console is the secure Xen console,
3+
# not e.g. a serial console that is exposed to the outside world.
4+
TTYPath=/dev/hvc0
5+
Environment=SYSTEMD_SULOGIN_FORCE=1

0 commit comments

Comments
 (0)