Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement openSUSE support #1

Open
wants to merge 18 commits into
base: opensuse
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ VERSION := $(shell cat version)
LIBDIR ?= /usr/lib64
USRLIBDIR ?= /usr/lib
SYSLIBDIR ?= /lib
UNITDIR ?= $(SYSLIBDIR)/systemd/system
DATADIR ?= /usr/share
PA_VER_FULL ?= $(shell pkg-config --modversion libpulse | cut -d "-" -f 1 || echo 0.0)
PA_VER_MAJOR_MINOR ?= $(shell echo $(PA_VER_FULL) | cut -d "." -f 1,2)
Expand Down Expand Up @@ -77,11 +78,14 @@ clean:

install: install-rh-agent install-pulseaudio

install-rh-agent: appvm install-common
install -m 0644 -D appvm-scripts/qubes-gui-agent.service \
$(DESTDIR)/$(SYSLIBDIR)/systemd/system/qubes-gui-agent.service
install-rh-agent: appvm install-common install-systemd
ifeq (openSUSE, $(shell lsb_release -is))
install -m 0644 -D appvm-scripts/usr/share/xsessions/qubes.desktop \
$(DESTDIR)/usr/share/xsessions/qubes.desktop
else
install -m 0644 -D appvm-scripts/etc/sysconfig/desktop \
$(DESTDIR)/etc/sysconfig/desktop
endif
install -D appvm-scripts/etc/X11/xinit/xinitrc.d/20qt-x11-no-mitshm.sh \
$(DESTDIR)/etc/X11/xinit/xinitrc.d/20qt-x11-no-mitshm.sh
install -D appvm-scripts/etc/X11/xinit/xinitrc.d/20qt-gnome-desktop-session-id.sh \
Expand All @@ -91,13 +95,11 @@ install-rh-agent: appvm install-common
install -D appvm-scripts/etc/X11/xinit/xinitrc.d/60xfce-desktop.sh \
$(DESTDIR)/etc/X11/xinit/xinitrc.d/60xfce-desktop.sh

install-debian: appvm install-common install-pulseaudio
install-debian: appvm install-common install-pulseaudio install-systemd
install -d $(DESTDIR)/etc/X11/Xsession.d
install -m 0644 appvm-scripts/etc/X11/Xsession.d/* $(DESTDIR)/etc/X11/Xsession.d/
install -d $(DESTDIR)/etc/xdg
install -m 0644 appvm-scripts/etc/xdg-debian/* $(DESTDIR)/etc/xdg
install -m 0644 -D appvm-scripts/qubes-gui-agent.service \
$(DESTDIR)/$(SYSLIBDIR)/systemd/system/qubes-gui-agent.service

install-pulseaudio:
install -D pulse/start-pulseaudio-with-vchan \
Expand All @@ -116,6 +118,10 @@ endif
install -m 0644 -D appvm-scripts/etc/xdgautostart/qubes-pulseaudio.desktop \
$(DESTDIR)/etc/xdg/autostart/qubes-pulseaudio.desktop

install-systemd:
install -m 0644 -D appvm-scripts/qubes-gui-agent.service \
$(DESTDIR)/$(UNITDIR)/qubes-gui-agent.service

install-common:
install -D gui-agent/qubes-gui $(DESTDIR)/usr/bin/qubes-gui
install -D gui-common/qubes-gui-runuser $(DESTDIR)/usr/bin/qubes-gui-runuser
Expand All @@ -130,6 +136,8 @@ install-common:
$(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-run-x11vnc \
$(DESTDIR)/usr/bin/qubes-run-x11vnc
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 All @@ -142,6 +150,10 @@ install-common:
$(DESTDIR)$(LIBDIR)/xorg/modules/drivers/dummyqbs_drv.so
install -m 0644 -D appvm-scripts/etc/X11/xorg-qubes.conf.template \
$(DESTDIR)/etc/X11/xorg-qubes.conf.template
install -m 0644 -D appvm-scripts/etc/X11/xorg-qubes-x11vnc.conf.template \
$(DESTDIR)/etc/X11/xorg-qubes-x11vnc.conf.template
install -m 0644 -D appvm-scripts/etc/systemd/system/lightdm.service.d/qubes-guivm-vnc.conf \
$(DESTDIR)/etc/systemd/system/lightdm.service.d/qubes-guivm-vnc.conf
install -m 0644 -D appvm-scripts/etc/profile.d/qubes-gui.sh \
$(DESTDIR)/etc/profile.d/qubes-gui.sh
install -m 0644 -D appvm-scripts/etc/profile.d/qubes-gui.csh \
Expand Down Expand Up @@ -184,6 +196,9 @@ else ifeq ($(shell lsb_release -is), Ubuntu)
else ifeq ($(shell lsb_release -is), Arch)
install -D -m 0644 appvm-scripts/etc/pam.d/qubes-gui-agent.archlinux \
$(DESTDIR)/etc/pam.d/qubes-gui-agent
else ifeq ($(shell lsb_release -is), openSUSE)
install -D -m 0644 appvm-scripts/etc/pam.d/qubes-gui-agent.opensuse \
$(DESTDIR)/etc/pam.d/qubes-gui-agent
else
install -D -m 0644 appvm-scripts/etc/pam.d/qubes-gui-agent \
$(DESTDIR)/etc/pam.d/qubes-gui-agent
Expand Down
4 changes: 2 additions & 2 deletions appvm-scripts/etc/X11/Xsession.d/50guivm-windows-prefix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
QUBES_VMNAME="$(qubesdb-read /guivm-windows-prefix)"

# Set _QUBES_VMNAME atom for a window manager (e.g. xfwm4)
if qsvc guivm-gui-agent; then
if qsvc guivm; then
xprop -root -f _QUBES_VMNAME 8s -set _QUBES_VMNAME "${QUBES_VMNAME:-GuiVM}"
fi
fi
4 changes: 2 additions & 2 deletions appvm-scripts/etc/X11/Xsession.d/60xfce-desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# shellcheck disable=SC1091
. /usr/lib/qubes/init/functions

if ! qsvc guivm-gui-agent; then
if ! qsvc guivm; then

XDG_MENU_PREFIX="xfce-"
export XDG_MENU_PREFIX
Expand All @@ -27,4 +27,4 @@ fi
export QT_QPA_PLATFORMTHEME=qt5ct

xfsettingsd --replace&
fi
fi
34 changes: 34 additions & 0 deletions appvm-scripts/etc/X11/xorg-qubes-x11vnc.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Section "Module"
Load "fb"
EndSection

Section "ServerLayout"
Identifier "Default Layout"
Screen 0 "Screen0" 0 0
EndSection

Section "Device"
Identifier "Videocard0"
Driver "dummyqbs"
VideoRam %MEM%
Option "GUIDomID" "%GUI_DOMID%"
EndSection

Section "Monitor"
Identifier "Monitor0"
HorizSync %MIN_MAX_HSYNC%
VertRefresh %MIN_MAX_VSYNC%
%MODELINES%
Option "PreferredMode" "QB1024x768"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth %DEPTH%
SubSection "Display"
Viewport 0 0
Depth %DEPTH%
EndSubSection
EndSection
8 changes: 8 additions & 0 deletions appvm-scripts/etc/pam.d/qubes-gui-agent.opensuse
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#%PAM-1.0
auth sufficient pam_rootok.so
auth include common-auth
account sufficient pam_rootok.so
account include common-account
password include common-password
session include common-session
session optional pam_xauth.so
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
ConditionPathExists=/run/qubes-service/lightdm

[Service]
ExecStartPre=/usr/bin/qubes-run-x11vnc pre
ExecStartPost=/usr/bin/qubes-run-x11vnc
ExecStopPost=/usr/bin/qubes-run-x11vnc post
5 changes: 5 additions & 0 deletions appvm-scripts/usr/share/xsessions/qubes.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Desktop Entry]
Encoding=UTF-8
Type=XSession
Exec=qubes-session
Name=QubesOS
151 changes: 151 additions & 0 deletions appvm-scripts/usrbin/qubes-run-x11vnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/bin/bash
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2021 Frédéric Pierret <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#

# Source Qubes library.
# shellcheck disable=SC1091
. /usr/lib/qubes/init/functions

array_min_max() {
read -r -a array <<< "$@"
max=${array[0]}
min=${array[0]}

for i in ${array[*]}; do
(( i > max )) && max=$i
(( i < min )) && min=$i
done
echo "$min"-"$max"
}


guivm_vnc_pre () {
# Common part from qubes-run-xorg to setup dummyqbs xorg.org
GUI_DOMID="$(qubesdb-read /qubes-gui-domain-xid 2>/dev/null)"
MEM_MIN="$(qubesdb-read /qubes-gui-videoram-min 2>/dev/null)"
MEM_OVERHEAD="$(qubesdb-read /qubes-gui-videoram-overhead 2>/dev/null)"
: "${MEM_MIN:=0}"
: "${MEM_OVERHEAD:=$((2560 * 1600 * 4 / 1024))}"

MEM=$((MEM + MEM_OVERHEAD))
if [ $MEM -lt $MEM_MIN ]; then
MEM=$MEM_MIN
fi

DUMMY_MAX_CLOCK=300
PREFERRED_HSYNC=50
DEPTH=24

HSYNC=()
VSYNC=()
MODELINES=()
# Set of common resolutions (VGA, VGA wide and HD)
RESOLUTIONS="320x240
640x480
800x600
1024x768
1152x864
1280x1024
1400x1050
1600x1200
2048x1536
800x480
1366x768
1440x900
1600x1024
1680x1050
1920x1200
2560x1600
1280x720
1920x1080"

for RES in ${RESOLUTIONS[*]};
do
# Defines every modeline like qubes.SetMonitorLayout
W=${RES%x*}
H=${RES#*x}
HTOTAL=$((W+3))
VTOTAL=$((H+3))
CLOCK=$((PREFERRED_HSYNC*HTOTAL/1000))
if [ $CLOCK -gt $DUMMY_MAX_CLOCK ]; then CLOCK=$DUMMY_MAX_CLOCK ; fi
MODELINE="$CLOCK $W $((W+1)) $((W+2)) $HTOTAL $H $((H+1)) $((H+2)) $VTOTAL"

HSYNC_START=$((CLOCK*1000/HTOTAL))
HSYNC_END=$((HSYNC_START+1))

VREFR_START=$((CLOCK*1000000/HTOTAL/VTOTAL))
VREFR_END=$((VREFR_START+1))

# Store computed h/v sync and Xorg Modeline entry
HSYNC+=("$HSYNC_START" "$HSYNC_END")
VSYNC+=("$VREFR_START" "$VREFR_END")
MODELINES+=(" Modeline \"QB$RES\" $MODELINE")
done

ALL_MODELINES="$(printf '%s\\n' "${MODELINES[@]}")"
MIN_MAX_HSYNC="$(array_min_max "${HSYNC[@]}")"
MIN_MAX_VSYNC="$(array_min_max "${VSYNC[@]}")"

# Backup xorg.conf if user has created custom one
if [ -e /etc/X11/xorg.conf ]; then
cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup_guivm_vnc
fi

# Render the template
sed -e s/%MEM%/$MEM/ \
-e s/%GUI_DOMID%/"${GUI_DOMID:-0}"/ \
-e s/%DEPTH%/$DEPTH/ \
-e s/%MODELINES%/"$ALL_MODELINES"/ \
-e s/%MIN_MAX_HSYNC%/"$MIN_MAX_HSYNC"/ \
-e s/%MIN_MAX_VSYNC%/"$MIN_MAX_VSYNC"/ \
< /etc/X11/xorg-qubes-x11vnc.conf.template > /etc/X11/xorg.conf

# 2**30
echo 1073741824 > /sys/module/xen_gntalloc/parameters/limit
}

guivm_vnc() {
X11VNC=/usr/bin/x11vnc

# WIP: Ensure to have the good set of x11vnc options.
OPTIONS_VNC="-display :0 -auth /var/run/lightdm/root/:0 -forever"

$X11VNC $OPTIONS_VNC &
}

guivm_vnc_post() {
# Remove temporary xorg.conf
rm -f /etc/X11/xorg.conf
# Restore original xorg.conf
if [ -e /etc/X11/xorg.conf.backup_guivm_vnc ]; then
mv /etc/X11/xorg.conf.backup_guivm_vnc /etc/X11/xorg.conf
fi
}

if qsvc guivm-vnc; then
if [ "$1" == "pre" ]; then
guivm_vnc_pre
elif [ "$1" == "post" ]; then
guivm_vnc_post
elif [ -z "$1" ]; then
guivm_vnc
fi
fi
7 changes: 6 additions & 1 deletion appvm-scripts/usrbin/qubes-run-xorg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# shellcheck disable=SC1091
. /usr/lib/qubes/init/functions

## This script is triggered by qubes-gui-agent systemd service.

#expects W, H, MEM and DEPTH env vars to be set by invoker
DUMMY_MAX_CLOCK=300 #hardcoded in dummy_drv
PREFERRED_HSYNC=50
Expand Down Expand Up @@ -82,6 +84,10 @@ if [ -f /etc/X11/Xsession ]; then
XORG="/usr/bin/Xorg"
fi
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
# openSUSE
XSESSION="/etc/X11/xinit/xinitrc.common"
fi

# Defaults value in case default-user value is not available
DEFAULT_USER="$(qubesdb-read /default-user 2>/dev/null)"
Expand All @@ -107,7 +113,6 @@ fi

if qsvc guivm-gui-agent; then
DISPLAY_XORG=:1
DISPLAY_XEPHYR=:0

# 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" &
Expand Down
19 changes: 19 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
qubes-gui-agent (4.1.19-1) unstable; urgency=medium

[ Frédéric Pierret (fepitre) ]
* Implement VNC GuiVM
* guivm-vnc: use /run directly in lightdm preset conf
* guivm-vnc: simplify options set
* guivm-vnc: add few comments for pre script
* Use only one script for pre and post
* spec: remove xorg-x11-utils and replace by dependencies

-- Marek Marczykowski-Górecki <[email protected]> Thu, 01 Jul 2021 05:45:06 +0200

qubes-gui-agent (4.1.18-1) unstable; urgency=medium

[ Frédéric Pierret (fepitre) ]
* spec: ensure R for few x11 tools

-- Marek Marczykowski-Górecki <[email protected]> Sat, 12 Jun 2021 17:57:09 +0200

qubes-gui-agent (4.1.17-1) unstable; urgency=medium

[ Rusty Bird ]
Expand Down
9 changes: 9 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ Depends:
${misc:Depends}
Description: XFCE desktop support for Qubes VM
XFCE desktop support for Qubes VM

Package: qubes-gui-vnc
Architecture: any
Depends:
x11vnc
${shlibs:Depends},
${misc:Depends}
Description: Remote GuiVM support using VNC
Remote GuiVM support using VNC
3 changes: 3 additions & 0 deletions debian/qubes-gui-vnc.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
usr/bin/qubes-run-x11vnc
etc/X11/xorg-qubes-x11vnc.conf.template
etc/systemd/system/lightdm.service.d/qubes-guivm-vnc.conf
Loading