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

Adapt agama-live to work with the new architecture #1119

Merged
merged 27 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2e6c2c2
Add a Firefox startup script
imobachgs Mar 25, 2024
469a92c
Optionally write the token when starting the server
imobachgs Mar 25, 2024
8936558
Add the agama-web-server service
imobachgs Mar 25, 2024
b8ef5f5
Disable @typescript-eslint/no-unused-vars
imobachgs Mar 25, 2024
4bc5a75
Update the agama-web-ui.spec to the new code
imobachgs Mar 25, 2024
ec1ad7b
Serve precompressed (gz) files if they are available
imobachgs Mar 25, 2024
2fe7df5
Remove the extra slash from HTTP methods
imobachgs Mar 25, 2024
4b8410a
Drop cockpit.socket dependency in agama.service
imobachgs Mar 26, 2024
51c0ff4
Add modified agama-live KIWI files
imobachgs Mar 26, 2024
1650fc6
Add a temporary README to the 'live' directory
imobachgs Mar 26, 2024
a6507db
Add a README.md to the live/ directory
imobachgs Mar 26, 2024
4bdcceb
Add support to login from the query string
imobachgs Apr 3, 2024
22f5174
Use the login endpoint to start the local browser
imobachgs Apr 3, 2024
cd270da
Update the list of packages in the KIWI image
imobachgs Apr 3, 2024
c1d93cf
Merge branch 'architecture_2024' into agama-live-update
imobachgs Apr 3, 2024
78d595d
Keep uncompressed assets when building the UI
imobachgs Apr 3, 2024
8ac6eb4
Minor formatting change
imobachgs Apr 3, 2024
68cd286
Keep uncompressed files in agama-web-ui RPM package
imobachgs Apr 3, 2024
ff670b0
Make the login redirection temporary
imobachgs Apr 3, 2024
9f8c7b2
Move the token creation to a function
imobachgs Apr 3, 2024
5dfe0d5
Add root.tar contents to agama-live directory
imobachgs Apr 3, 2024
be2b5ef
Inject the token in Firefox's preferences
imobachgs Apr 3, 2024
ce1f5ff
Remove the startup script from the old location
imobachgs Apr 3, 2024
512e444
Fix sed invocation
imobachgs Apr 3, 2024
16b36e0
Fix Firefox start-up
imobachgs Apr 3, 2024
bd5549b
Fix agama-web-server dependency
imobachgs Apr 4, 2024
86afb33
Merge branch 'architecture_2024' into agama-live-update
imobachgs Apr 4, 2024
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
14 changes: 14 additions & 0 deletions live/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Directory contents

This directory contains the changes that are required to make Agama Live to
work with the HTTP-based version of Agama. In the future, it should contains all
the files.

## Skipping the authentication

In order to skip the authentication, we decided to inject a valid authentication
token in the browser. This token is autogenerated by the `agama-web-server serve`
command (using the `--generate-token` option).

Then, the Firefox start-up script (`startup`) takes care of injecting such a token
in the cookies database (`/root/.mozilla/firefox/profile/cookies.sqlite`).
195 changes: 195 additions & 0 deletions live/agama-live.kiwi
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- OBS-ExclusiveArch: aarch64 ppc64le x86_64 s390x -->
<!-- OBS-Profiles: @BUILD_FLAVOR@ -->

<image schemaversion="7.5" name="agama-live">
<description type="system">
<author>YaST Team</author>
<contact>yast2-maintainers@suse.de</contact>
<specification>Agama Live ISO</specification>
</description>
<profiles>
<profile name="openSUSE" description="openSUSE multiproduct image" import="true" />
<profile name="ALP" description="ALP-only image" />
<profile name="openSUSE-Playwright" description="openSUSE image with Playwright integration tests" arch="aarch64,x86_64" />
<profile name="ALP-Playwright" description="ALP image with Playwright integration tests" arch="aarch64,x86_64" />
<profile name="ALP-PXE" description="ALP OEM image for remote installation" />
</profiles>
<preferences>
<version>7.0.0</version>
<packagemanager>zypper</packagemanager>
<locale>en_US</locale>
<keytable>us</keytable>
<timezone>Europe/Berlin</timezone>
<rpm-excludedocs>true</rpm-excludedocs>
<rpm-check-signatures>false</rpm-check-signatures>
<bootsplash-theme>bgrt</bootsplash-theme>
<bootloader-theme>openSUSE</bootloader-theme>
</preferences>
<preferences arch="ppc64le" profiles="openSUSE,ALP">
<type image="iso" flags="dmsquash" firmware="ofw" mediacheck="true" volid="agama" editbootconfig="fix_bootconfig">
<bootloader name="grub2" console="serial" timeout="10"/>
</type>
</preferences>
<preferences arch="aarch64,x86_64" profiles="openSUSE,ALP,openSUSE-Playwright,ALP-Playwright">
<type image="iso" flags="dmsquash" firmware="uefi" mediacheck="true" volid="agama" editbootconfig="fix_bootconfig">
<bootloader name="grub2" timeout="10"/>
</type>
</preferences>
<preferences arch="s390x" profiles="openSUSE,ALP">
<type image="iso" flags="dmsquash" volid="agama" editbootconfig="fix_bootconfig">
<bootloader name="custom" />
</type>
</preferences>
<preferences arch="ppc64le" profiles="ALP-PXE">
<!-- For some reason the compression results on ppc64le are not as good as on the other archs -->
<type image="oem" filesystem="btrfs" fsmountoptions="compress=zstd:15" firmware="ofw" installpxe="true" installboot="install" kernelcmdline="rd.kiwi.ramdisk ramdisk_size=3174400" volid="agama">
<bootloader name="grub2" console="serial" timeout="1"/>
<oemconfig>
<oem-skip-verify>true</oem-skip-verify>
<oem-unattended>true</oem-unattended>
<oem-unattended-id>/dev/ram1</oem-unattended-id>
<oem-swap>false</oem-swap>
<oem-multipath-scan>false</oem-multipath-scan>
</oemconfig>
<size unit="M">3000</size>
</type>
</preferences>
<preferences arch="s390x" profiles="ALP-PXE">
<type image="oem" filesystem="btrfs" fsmountoptions="compress=zstd:15" installpxe="true" installboot="install" kernelcmdline="rd.kiwi.ramdisk ramdisk_size=2097152" volid="agama">
<bootloader name="custom"/>
<oemconfig>
<oem-skip-verify>true</oem-skip-verify>
<oem-unattended>true</oem-unattended>
<oem-unattended-id>/dev/ram1</oem-unattended-id>
<oem-swap>false</oem-swap>
<oem-multipath-scan>false</oem-multipath-scan>
</oemconfig>
<size unit="M">1900</size>
</type>
</preferences>
<preferences arch="aarch64,x86_64" profiles="ALP-PXE">
<type image="oem" filesystem="btrfs" fsmountoptions="compress=zstd:15" firmware="uefi" installiso="true" installpxe="true" installboot="install" kernelcmdline="rd.kiwi.ramdisk ramdisk_size=2097152" volid="agama">
<bootloader name="grub2" timeout="1"/>
<oemconfig>
<oem-skip-verify>true</oem-skip-verify>
<oem-unattended>true</oem-unattended>
<oem-unattended-id>/dev/ram1</oem-unattended-id>
<oem-swap>false</oem-swap>
<oem-multipath-scan>false</oem-multipath-scan>
</oemconfig>
<size unit="M">1900</size>
</type>
</preferences>
<users>
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root" groups="root"/>
</users>
<repository type="rpm-md">
<source path="obsrepositories:/"/>
</repository>
<packages type="image" profiles="ALP-PXE">
<package name="dracut-kiwi-oem-repart"/>
<package name="dracut-kiwi-oem-dump"/>
<archive name="brd.tar.gz"/>
</packages>
<packages type="image">
<package name="avahi"/>
<package name="bind-utils"/>
<package name="patterns-openSUSE-base"/>
<package name="systemd"/>
<package name="grub2-branding-openSUSE" arch="aarch64,x86_64"/>
<package name="iputils"/>
<package name="vim"/>
<package name="grub2"/>
<package name="grub2-arm64-efi" arch="aarch64"/>
<package name="grub2-x86_64-efi" arch="x86_64"/>
<package name="grub2-i386-pc" arch="x86_64"/>
<package name="grub2-s390x-emu" arch="s390x" />
<package name="grub2-powerpc-ieee1275" arch="ppc64le"/>
<package name="syslinux" arch="x86_64"/>
<package name="fontconfig"/>
<package name="fonts-config"/>
<package name="adobe-sourcecodepro-fonts"/>
<package name="adobe-sourcehansans-jp-fonts"/>
<package name="openssh"/>
<package name="iproute2"/>
<package name="less"/>
<package name="bash-completion"/>
<package name="dhcp-client"/>
<package name="which"/>
<package name="kernel-default"/>
<!-- the firmware files not referenced by any kernel driver are removed from the image -->
<package name="kernel-firmware"/>
<package name="adaptec-firmware"/>
<package name="atmel-firmware"/>
<package name="bluez-firmware"/>
<package name="ipw-firmware"/>
<package name="mpt-firmware"/>
<package name="zd1211-firmware"/>
<package name="systemd-zram-service"/> <!--- needed for zram -->
<package name="shim" arch="aarch64,x86_64"/>
<package name="timezone"/>
<package name="dracut-kiwi-live"/>
<package name="blog" arch="s390x" />
<package name="libblogger2" arch="s390x" />
<package name="xauth"/>
<package name="patterns-base-x11"/>
<namedCollection name="x11"/>
<package name="patterns-yast-yast2_basis"/>
<package name="MozillaFirefox" arch="aarch64,x86_64"/>
<package name="MozillaFirefox-branding-openSUSE" arch="aarch64,x86_64"/>
<package name="libpwquality-tools"/>
<package name="NetworkManager"/>
<package name="ruby3.3-rubygem-byebug"/>
<package name="ruby3.3-rubygem-agama-yast"/>
<package name="agama"/>
<package name="agama-cli"/>
<package name="agama-web-ui"/>
<package name="microos-tools"/>
<package name="staging-build-key"/>
<package name="icewm-lite"/>
<package name="xinit"/>
<package name="psmisc"/>
<package name="joe"/>
<package name="checkmedia"/>
<package name="spice-vdagent"/>
<package name="libtss2-tcti-device0"/>
<archive name="root.tar"/>
<archive name="etc.tar"/>
<archive name="dracut-cmdline-menu.tar.xz"/>
<!-- just a helper script for firmware cleanup, removed from the image -->
<archive name="fw_cleanup.tar.xz"/>
</packages>
<!-- additional packages for the openSUSE flavors -->
<packages type="image" profiles="openSUSE,openSUSE-Playwright">
<package name="agama-products-opensuse"/>
<package name="openSUSE-build-key"/>
</packages>
<!-- additional packages for the ALP flavors -->
<packages type="image" profiles="ALP,ALP-Playwright">
<package name="agama-products-ALP-Dolomite"/>
<package name="suse-build-key"/>
</packages>
<!-- additional packages for the Playwright flavors -->
<packages type="image" profiles="openSUSE-Playwright,ALP-Playwright">
<package name="playwright"/>
<!-- <package name="cockpit-agama-playwright"/> -->
<!-- Playwright does not work with the openSUSE Firefox, -->
<!-- install the chromium browser for running the tests -->
<!-- unfortunately it is not available for s390x -->
<package name="chromium"/>
</packages>
<packages type="image">
<archive name="autoinstallation.tar.xz"/>
</packages>
<packages type="bootstrap">
<package name="udev"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="openSUSE-release"/>
<package name="openSUSE-release-ftp"/>
</packages>
</image>
133 changes: 133 additions & 0 deletions live/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#! /bin/bash

set -x

# KIWI functions
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile

# greeting
echo "Configure image: [$kiwi_iname]..."

# setup baseproduct link
suseSetupProduct

# activate services
systemctl enable sshd.service
systemctl enable NetworkManager.service
systemctl enable avahi-daemon.service
systemctl enable agama.service
systemctl enable agama-auto.service
systemctl enable agama-hostname.service
systemctl enable agama-proxy-setup.service
systemctl enable setup-systemd-proxy-env.path
systemctl enable x11-autologin.service
systemctl enable spice-vdagent.service
systemctl enable zramswap

# default target
systemctl set-default graphical.target

# adjust owner of extracted files
chown -R root:root /root
find /etc -user 1000 | xargs chown root:root

### setup dracut for live system

label=${kiwi_install_volid:-$kiwi_iname}
arch=$(uname -m)

echo "Setting default live root: live:LABEL=$label"
mkdir /etc/cmdline.d
echo "root=live:LABEL=$label" >/etc/cmdline.d/10-liveroot.conf
echo "root_disk=live:LABEL=$label" >>/etc/cmdline.d/10-liveroot.conf
# if there's a default network location, add it here
# echo "root_net=" >> /etc/cmdline.d/10-liveroot.conf
echo 'install_items+=" /etc/cmdline.d/10-liveroot.conf "' >/etc/dracut.conf.d/10-liveroot-file.conf
echo 'add_dracutmodules+=" dracut-menu "' >>/etc/dracut.conf.d/10-liveroot-file.conf

if [ "${arch}" = "s390x" ];then
# workaround for custom bootloader setting
touch /config.bootoptions
fi

################################################################################
# Reducing the used space

# Clean-up logs
rm /var/log/zypper.log /var/log/zypp/history

du -h -s /usr/{share,lib}/locale/
# delete translations and unusupported languages (makes ISO about 22MiB smaller)
# build list of ignore options for "ls" with supported languages like "-I cs* -I de* -I es* ..."
readarray -t IGNORE_OPTS < <(ls /usr/share/cockpit/agama/po.*.js.gz | sed -e "s#/usr/share/cockpit/agama/po\.\(.*\)\.js\.gz#-I\n\\1*#")
# additionally keep the en_US translations
ls -1 "${IGNORE_OPTS[@]}" -I en_US /usr/share/locale/ | xargs -I% sh -c "echo 'Removing translations %...' && rm -rf /usr/share/locale/%"

# delete locale definitions for unsupported languages (explicitly keep the C and en_US locales)
ls -1 "${IGNORE_OPTS[@]}" -I "en_US*" -I "C.*" /usr/lib/locale/ | xargs -I% sh -c "echo 'Removing locale %...' && rm -rf /usr/lib/locale/%"

# delete unused translations (MO files)
for t in zypper gettext-runtime p11-kit polkit-1 xkeyboard-config; do
rm /usr/share/locale/*/LC_MESSAGES/$t.mo
done
du -h -s /usr/{share,lib}/locale/

# remove documentation
du -h -s /usr/share/doc/packages/
rm -rf /usr/share/doc/packages/*
# remove man pages
du -h -s /usr/share/man
rm -rf /usr/share/man/*

## removing drivers and firmware makes the Live ISO about 370MiB smaller
# sound related, Agama does not use sound, added by icewm dependencies
rpm -e --nodeps alsa alsa-utils alsa-ucm-conf

# driver and firmware cleanup
# Note: openSUSE Tumbleweed Live completely removes firmware for some server
# network cars, because you very likely won't run TW KDE Live on a server.
# But for Agama installer it makes more sense to run on server. So we keep it
# and remove the drivers for sound cards and TV cards instead. Those do not
# make sense on a server.
du -h -s /lib/modules /lib/firmware
# delete sound drivers
rm -rfv /lib/modules/*/kernel/sound
# delete TV cards and radio cards
rm -rfv /lib/modules/*/kernel/drivers/media/

# remove the unused firmware (not referenced by kernel drivers)
/fw_cleanup.rb --delete
# remove the script, not needed anymore
rm /fw_cleanup.rb
du -h -s /lib/modules /lib/firmware

################################################################################
# The rest of the file was copied from the openSUSE Tumbleweed Live ISO
# https://build.opensuse.org/package/view_file/openSUSE:Factory:Live/livecd-tumbleweed-kde/config.sh?expand=1
#

# disable the services included by dependencies
for s in purge-kernels; do
systemctl -f disable $s || true
done

# Only used for OpenCL and X11 acceleration on vmwgfx (?), saves ~50MiB
rpm -e --nodeps Mesa-gallium
# Too big and will have to be dropped anyway (unmaintained, known security issues)
rm -rf /usr/lib*/libmfxhw*.so.* /usr/lib*/mfx/

# the new, optional nvidia gsp firmware blobs are huge - ~ 70MB
du -h -s /lib/firmware/nvidia
find /lib/firmware/nvidia -name gsp | xargs -r rm -rf
du -h -s /lib/firmware/nvidia
# The gems are unpackaged already, no need to store them twice
du -h -s /usr/lib*/ruby/gems/*/cache/
rm -rf /usr/lib*/ruby/gems/*/cache/

# Not needed, boo#1166406
rm -f /boot/vmlinux*.[gx]z
rm -f /lib/modules/*/vmlinux*.[gx]z

# Remove generated files (boo#1098535)
rm -rf /var/cache/zypp/* /var/lib/zypp/AnonymousUniqueId /var/lib/systemd/random-seed
7 changes: 7 additions & 0 deletions live/startup
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
# Start a browser to connect to Agama's web user interface skipping the authentication.

TOKEN_FILE=/run/agama/token
TOKEN=$(cat $TOKEN_FILE)

firefox --kiosk --profile $HOME/.mozilla/firefox/profile "http://localhost/login?token=$TOKEN"
Copy link
Contributor

@lslezak lslezak Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is simpler without using a helper token.html file. On the other hand the token is then visible in the ps output. I'm not sure how serious is this problem... 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you might need to access to the system (as root, as it is the only user in the ISO) and, at that point, you can read the token from the file anyway. Alternatively, we could set the URL as the homepage for the browser (we are doing other tweaks anyway), so we do not need to specify any URL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, once you are root you can do everything...

The problem is that for running simple ps you do not need to be root. If e.g. the avahi daemon running as avahi user is vulnerable and allows arbitrary code execution then you could still get the root token if you force it to run ps and get the output although it's not running as root.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW setting the home page looks like a good trick...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's give the homepage setting a try.

Loading
Loading