Skip to content

Commit

Permalink
Extract Xephyr to a separate script
Browse files Browse the repository at this point in the history
qubes-run-xorg will only start the "outer" Xorg instance. The
Xephyr session should be initiated using qrexec:

    qvm-run -p --no-gui --service $GUIVM qubes.GuiVMSession

The '-p' ensures that the above command will wait for the session
to finish.
  • Loading branch information
pwmarcz committed Jul 28, 2020
1 parent 70d3e8b commit 0ced677
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ install-common:
$(DESTDIR)/usr/bin/qubes-run-xorg
install -D appvm-scripts/usrbin/qubes-run-xephyr \
$(DESTDIR)/usr/bin/qubes-run-xephyr
install -D appvm-scripts/usrbin/qubes-start-xephyr \
$(DESTDIR)/usr/bin/qubes-start-xephyr
install -D appvm-scripts/usrbin/qubes-change-keyboard-layout \
$(DESTDIR)/usr/bin/qubes-change-keyboard-layout
install -D appvm-scripts/usrbin/qubes-set-monitor-layout \
Expand Down Expand Up @@ -170,6 +172,8 @@ endif
install -d $(DESTDIR)/etc/qubes-rpc
ln -s ../../usr/bin/qubes-set-monitor-layout \
$(DESTDIR)/etc/qubes-rpc/qubes.SetMonitorLayout
ln -s ../../usr/bin/qubes-start-xephyr \
$(DESTDIR)/etc/qubes-rpc/qubes.GuiVMSession
install -D window-icon-updater/icon-sender \
$(DESTDIR)/usr/lib/qubes/icon-sender
install -m 0644 -D window-icon-updater/qubes-icon-sender.desktop \
Expand Down
11 changes: 2 additions & 9 deletions appvm-scripts/usrbin/qubes-run-xorg
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,8 @@ if qsvc guivm-gui-agent; then
DISPLAY_XORG=:1
DISPLAY_XEPHYR=:0

# Create Xorg and Xephyr server (emulated GPU passthrough)
runuser -u "$DEFAULT_USER" -- /bin/sh -l -c "exec $XORG $DISPLAY_XORG -terminate -nolisten tcp vt07 -wr -config xorg-qubes.conf > ~/.xorg-errors 2>&1" &
# Wait Xorg display available
while ! xdpyinfo -display $DISPLAY_XORG > /dev/null 2>&1
do
sleep 1
done
# Run xsession into Xephyr
/usr/bin/qubes-gui-runuser "$DEFAULT_USER" /bin/sh -l -c "DISPLAY=$DISPLAY_XORG /usr/bin/xinit $XSESSION -- /usr/bin/qubes-run-xephyr $DISPLAY_XEPHYR > ~/.xsession-errors 2>&1"
# Create Xorg. Xephyr will be started using qubes-start-xephyr later.
exec runuser -u "$DEFAULT_USER" -- /bin/sh -l -c "exec $XORG $DISPLAY_XORG -nolisten tcp vt07 -wr -config xorg-qubes.conf > ~/.xorg-errors 2>&1" &
else
# Use sh -l here to load all session startup scripts (/etc/profile, ~/.profile
# etc) to populate environment. This is the environment that will be used for
Expand Down
25 changes: 25 additions & 0 deletions appvm-scripts/usrbin/qubes-start-xephyr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

if [ $(whoami) == "root" ]; then
echo "Should be run as normal user!"
exit 1
fi

DISPLAY_XORG=:1
DISPLAY_XEPHYR=:0

XSESSION="/etc/X11/xinit/xinitrc"
if [ -f /etc/X11/Xsession ]; then
# Debian-based distro, set Xsession appropriately
XSESSION="/etc/X11/Xsession qubes-session"
fi

# Wait for Xorg display (started by qubes-run-xorg)
if ! timeout 30s sh -c "while ! xdpyinfo -display $DISPLAY_XORG > /dev/null 2>&1; do sleep 1; done"; then
echo "Timed out waiting for Xorg display $DISPLAY_XORG"
exit 1
fi

# Run xsession into Xephyr
export DISPLAY=$DISPLAY_XORG
exec /usr/bin/xinit $XSESSION -- /usr/bin/qubes-run-xephyr $DISPLAY_XEPHYR > ~/.xsession-errors 2>&1
2 changes: 2 additions & 0 deletions debian/qubes-gui-agent.install
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ etc/profile.d/qubes-session.sh
etc/pam.d/qubes-gui-agent
etc/security/limits.d/90-qubes-gui.conf
etc/qubes-rpc/qubes.SetMonitorLayout
etc/qubes-rpc/qubes.GuiVMSession
etc/qubes/post-install.d/20-qubes-guivm-gui-agent.sh
etc/xdg/autostart/qubes-icon-sender.desktop
etc/xdg/autostart/qubes-qrexec-fork-server.desktop
Expand All @@ -24,6 +25,7 @@ usr/bin/qubes-gui
usr/bin/qubes-gui-runuser
usr/bin/qubes-run-xorg
usr/bin/qubes-run-xephyr
usr/bin/qubes-start-xephyr
usr/bin/qubes-session
usr/bin/qubes-set-monitor-layout
usr/lib/qubes/icon-sender
Expand Down
2 changes: 2 additions & 0 deletions rpm_spec/gui-agent.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ rm -f %{name}-%{version}
/usr/bin/qubes-session
/usr/bin/qubes-run-xorg
/usr/bin/qubes-run-xephyr
/usr/bin/qubes-start-xephyr
/usr/bin/qubes-change-keyboard-layout
/usr/bin/qubes-set-monitor-layout
%{_libdir}/xorg/modules/drivers/qubes_drv.so
Expand All @@ -168,6 +169,7 @@ rm -f %{name}-%{version}
/etc/X11/xinit/xinitrc.d/20qt-gnome-desktop-session-id.sh
/etc/X11/xinit/xinitrc.d/50guivm-windows-prefix.sh
/etc/qubes-rpc/qubes.SetMonitorLayout
/etc/qubes-rpc/qubes.GuiVMSession
/etc/qubes/post-install.d/20-qubes-guivm-gui-agent.sh
%config /etc/sysconfig/desktop
/lib/systemd/system/qubes-gui-agent.service
Expand Down

0 comments on commit 0ced677

Please sign in to comment.