Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
74b1d46
create also file with kernel only files for bootloader proposal
jreidinger Jan 14, 2025
0d11399
Revert "create also file with kernel only files for bootloader proposal"
jreidinger Jan 15, 2025
6cc2517
add script to filter out kernel cmdline to live root
jreidinger Jan 15, 2025
8d4679f
add systemd service for filtering kernel
jreidinger Jan 16, 2025
ae97e49
remove space and add note
jreidinger Jan 17, 2025
10a9a8f
first version of info expansion script
jreidinger Jan 17, 2025
d761a98
change param from info to agama.info
jreidinger Jan 20, 2025
b476c61
update systemd services config and scripts
jreidinger Jan 20, 2025
feb8ef7
Merge remote-tracking branch 'origin/master' into info_param
jreidinger Jan 20, 2025
cf47628
fix matching start of line
jreidinger Jan 20, 2025
c3e5920
remove debug output and fix sed
jreidinger Jan 20, 2025
e35af4e
allow password on kernel command line to handle new lines
jreidinger Jan 20, 2025
0138767
remove properly info param
jreidinger Jan 20, 2025
c693a25
add ci for live directory
jreidinger Jan 21, 2025
4960315
Update live/test/info_cmdline_test.rb
jreidinger Jan 21, 2025
67abcfc
fix ci name
jreidinger Jan 21, 2025
bde6563
update kernel cmdline location
jreidinger Jan 29, 2025
74f7c33
follow redirects in info file url
jreidinger Jan 29, 2025
2a78da5
avoid exception if cmdline args does not exist
jreidinger Jan 30, 2025
e0184bd
adapt fixtures to reflect new structure
jreidinger Jan 30, 2025
4dc697b
more test adaptation
jreidinger Jan 30, 2025
5348b50
Added module for translating ifcfg option
teclator Jan 27, 2025
1be61eb
Simplify scripts as many options are not supported
teclator Jan 28, 2025
69d7351
Changes based on CR
teclator Jan 31, 2025
58e31c5
Added changelog
teclator Jan 31, 2025
7d4bfd8
Add support for translating ifcfg kernel cmdline argument to ip (#1957)
teclator Feb 1, 2025
1d02e6f
Update live/root/usr/bin/agama-self-update
jreidinger Feb 18, 2025
661afa1
Merge branch 'master' into info_param
jreidinger Feb 18, 2025
85bde8d
Apply suggestions from code review
jreidinger Feb 18, 2025
45e2daf
Merge branch 'master' into info_param
jreidinger Feb 18, 2025
e831ed9
adapt to changes in master
jreidinger Feb 18, 2025
56fdc9e
Update live/src/agama-installer.changes
jreidinger Feb 18, 2025
ada9f71
changes from review
jreidinger Feb 19, 2025
6523fce
Merge branch 'master' into info_param
jreidinger Feb 19, 2025
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
59 changes: 59 additions & 0 deletions .github/workflows/ci-live.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI - ISO definition

on:
push:
paths:
# NOTE: GitHub Actions do not allow using YAML references, the same path
# list is used below for the pull request event. Keep both lists in sync!!

# this file as well
- .github/workflows/ci-live.yml
# any change in the service subfolder
- live/**

pull_request:
paths:
# NOTE: GitHub Actions do not allow using YAML references, the same path
# list is used above for the push event. Keep both lists in sync!!

# this file as well
- .github/workflows/ci-live.yml
# any change in the service subfolder
- live/**

# allow running manually
workflow_dispatch:

jobs:
ruby_tests:
runs-on: ubuntu-latest
env:
COVERAGE: 1

defaults:
run:
working-directory: ./live

strategy:
fail-fast: false
matrix:
distro: [ "tumbleweed" ]

container:
image: registry.opensuse.org/yast/head/containers_${{matrix.distro}}/yast-ruby

steps:

- name: Git Checkout
uses: actions/checkout@v4

- name: Configure and refresh repositories
# disable unused repositories to have faster refresh
run: zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && zypper ref

- name: Install Ruby development files
run: zypper --non-interactive install
make

- name: Run the tests
run: make check
2 changes: 1 addition & 1 deletion autoinstallation/bin/agama-auto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export YAST_SKIP_XML_VALIDATION=1

if [ -z "$1" ]
then
url=$(awk -F 'agama.auto=' '{sub(/ .*$/, "", $2); print $2}' < /proc/cmdline)
url=$( grep 'agama.auto=' < /run/agama/cmdline.d/agama.conf | awk -F 'agama.auto=' '{sub(/ .*$/, "", $2); print $2}' )
else
url="$1"
fi
Expand Down
3 changes: 3 additions & 0 deletions live/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,7 @@ build: $(DESTDIR)
$(MAKE) all
(cd $(DESTDIR) && osc -A $(OBS_API) build -M $(FLAVOR) $(OSC_OPTS) $(OBS_TARGET) $(ARCH) $(KIWI_FILE))

check:
for i in ./test/*_test.*; do $${i}; done

.PHONY: build all clean
1 change: 1 addition & 0 deletions live/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This directory contains a set of files that are used to build the Agama Live ISO
a separate [PXE documentation](PXE.md) for more details about the PXE boot
- [config-cdroot](config-cdroot) subdirectory contains file which are copied to the uncompressed
root of the ISO image, the files can be accessed just by mounting the ISO file or the DVD medium
- [test](test) subdirectory contains tests to verify correctness of content. Can be run with `make check`

## Building the sources

Expand Down
21 changes: 21 additions & 0 deletions live/root/etc/systemd/system/agama-cmdline-process.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Agama kernel cmdline processing

# have to be after network to be able to download info files
# TODO: what to do in air gap scenario where we still need process cmdline?
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is still and issue, we should record it somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap, we need to test it. It is not just here, but also all password services is after network up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done as #2023

After=network-online.target

# before starting the Agama servers so they read configuration parsed
Before=agama-web-server.service
Before=agama.service
Before=x11-autologin.service

[Service]
Type=oneshot
Environment=TERM=linux
ExecStart=agama-kernel-cmdline.sh
StandardInput=tty
TimeoutSec=0

[Install]
WantedBy=default.target
8 changes: 3 additions & 5 deletions live/root/etc/systemd/system/agama-self-update.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Description=Agama self-update

After=network-online.target

# and after we process agama params like info which can contain password
After=agama-cmdline-process.service

# before starting the Agama servers so they use the new packages
Before=agama-web-server.service
Before=agama.service
Expand All @@ -11,11 +14,6 @@ Before=x11-autologin.service
Before=live-password-dialog.service
Before=live-password-systemd.service

# kernel command line option
ConditionKernelCommandLine=|agama.self_update
# linuxrc/YaST backward compatibility
ConditionKernelCommandLine=|agama.selfupdate

[Service]
Type=oneshot
Environment=TERM=linux
Expand Down
5 changes: 2 additions & 3 deletions live/root/etc/systemd/system/live-password-cmdline.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ Before=agama-web-server.service
Before=live-password-dialog.service
Before=live-password-systemd.service

# plain text password or hashed password passed via kernel command line
ConditionKernelCommandLine=|live.password
ConditionKernelCommandLine=|live.password_hash
# and after we process agama params like info which can contain password
After=agama-cmdline-process.service

[Service]
ExecStart=live-password --kernel
Expand Down
4 changes: 2 additions & 2 deletions live/root/etc/systemd/system/live-password-dialog.service
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Before=serial-getty@ttyS1.service
Before=serial-getty@ttyS2.service
Before=serial-getty@ttysclp0.service

# kernel command line option
ConditionKernelCommandLine=live.password_dialog
# and after we process agama params like info which can contain kernel parameters
After=agama-cmdline-process.service

[Service]
Type=oneshot
Expand Down
4 changes: 2 additions & 2 deletions live/root/etc/systemd/system/live-password-systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Before=serial-getty@ttyS1.service
Before=serial-getty@ttyS2.service
Before=serial-getty@ttysclp0.service

# kernel command line option
ConditionKernelCommandLine=live.password_systemd
# and after we process agama params like info which can contain kernel parameters
After=agama-cmdline-process.service

[Service]
Type=oneshot
Expand Down
4 changes: 4 additions & 0 deletions live/root/usr/bin/agama-kernel-cmdline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/sh

kernel-cmdline-conf.sh
info-cmdline-conf.sh
4 changes: 4 additions & 0 deletions live/root/usr/bin/agama-self-update
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# This script updates the Agama packages in the Live system from the
# Agama Devel OBS project.

# check if self-update is required
if ! grep -q "[[:space:]^]agama.self_update=1\([[:space:]]\|$\)" /run/agama/cmdline.d/agama.conf; then
exit 0
fi

# first try a quick and simple solution, refreshing the distributions repository takes a
# lot of time so try using only the agama-devel for update
Expand Down
28 changes: 28 additions & 0 deletions live/root/usr/bin/info-cmdline-conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/sh

# Script that expand agama.info parameter by downloading its file and appending it to agama.conf
# the info content is stored in info.conf

set -e

TARGET="${1:-/run/agama/cmdline.d/agama.conf}"
INFO_CONTENT="${2:-/run/agama/cmdline.d/info.conf}"

expand_info_arg() {
INFO_URL=$(sed -n 's/\(.*[[:space:]]\|^\)agama\.info=\([^[:space:]]\+\).*/\2/p' "$TARGET")
Copy link
Contributor

Choose a reason for hiding this comment

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

This picks up only one info file. Linuxrc supports multiple info arguments. Then it downloads and merges all info files.

This might be pretty useful. You can have a generic info file and an optional debugging one which additionally enables some debug features. This avoids duplicating the common parts between the info files. Just use the common one and if needed easily add the debugging one.

Copy link
Contributor

Choose a reason for hiding this comment

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

And linuxrc supports nested info files, you can use info= in info file as well... 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know about both of those linuxrc features and it is possible to implement it, I just do not see much usage for it. What I see so far from bug reports is that there is just single info file param that contain required parameters. In the end there is not so much parameters you need to use and usually it is more like debug.info and if needed some production.info file.
I plan to document this limitation to old linuxrc behavior and if there is interest in extending it, we can always do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It also allow different locations not sure if the same supported by curl... so something to document too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap, also true

if [ -z "${INFO_URL}" ]; then
return 0
fi

# TODO: should we use also --location-trusted if info file url contain user and password?
Copy link
Contributor

Choose a reason for hiding this comment

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

Another item for a follow-up card.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done as #2024

# if so check with security team
curl --location --silent "${INFO_URL}" > "${INFO_CONTENT}"
# remove info param
sed -in 's/\([[:space:]]\|^\)agama\.info=[^[:space:]]\+//' "${TARGET}"
# and add content of info file
cat "${INFO_CONTENT}" >> "${TARGET}"

return 0
}

expand_info_arg
34 changes: 34 additions & 0 deletions live/root/usr/bin/kernel-cmdline-conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /bin/sh

# Script to clean kernel command line from agama specific parameters. Result is later used for bootloader proposal.

SOURCE="${1:-/proc/cmdline}"
TARGET="${2:-/run/agama/cmdline.d/kernel.conf}"

write_kernel_args() {
DIR=$(dirname "${TARGET}")
mkdir -p "$DIR"
# ensure that kernel cmdline line is created to avoid reading agama params
# if there is no kernel params
touch "${TARGET}"

for _i in $(cat "${SOURCE}"); do
case ${_i} in
# remove all agama kernel params
# Add here also all linuxrc supported parameters
LIBSTORAGE_* | YAST_* | agama* | Y2* | ZYPP_* | autoyast* )
_found=1
;;
esac

if [ -z "$_found" ]; then
echo "Non-Agama parameter found ($_i)"
echo -n " $_i" >>"${TARGET}"
fi
unset _found
done

return 0
}

write_kernel_args
18 changes: 14 additions & 4 deletions live/root/usr/bin/live-password
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ msg_box() {
}

ask_password() {
# check if user wants dialog password
if ! grep -q "[[:space:]^]live.password_dialog=1\([[:space:]]\|$\)" /run/agama/cmdline.d/agama.conf; then
exit 0
fi

if ! PWD1=$(dialog --keep-tite --title "$TITLE" --backtitle "$BTITLE" --stdout --insecure --passwordbox "Password:" 8 40); then
confirm_exit
ask_password
Expand All @@ -36,7 +41,7 @@ ask_password() {
confirm_exit
ask_password
fi

if [ "$PWD1" != "$PWD2" ]; then
msg_box "Passwords do not match.\nPlease try again."
ask_password
Expand All @@ -51,6 +56,10 @@ ask_password() {

# functions for entering the password using the "systemd-ask-password" tool
ask_password_systemd() {
# check if user wants systemd password
if ! grep -q "[[:space:]^]live.password_systemd=1\([[:space:]]\|$\)" /run/agama/cmdline.d/agama.conf; then
exit 0
fi
if ! PWD1=$(systemd-ask-password --timeout=0 "Set login password: "); then
exit 1
fi
Expand Down Expand Up @@ -141,13 +150,14 @@ random_password() {
}

if [ "$1" = "--kernel" ]; then
# get the password from the kernel command line
PWD=$(awk -F 'live.password=' '{sub(/ .*$/, "", $2); print $2}' < /proc/cmdline)
# get the password from the kernel command line. It can contain newlines
PWD=$(grep 'live.password=' < /run/agama/cmdline.d/agama.conf | awk -F 'live.password=' '{sub(/ .*$/, "", $2); print $2}')
if [ -n "$PWD" ]; then
echo "$PWD" | passwd --stdin
fi

PWD=$(awk -F 'live.password_hash=' '{sub(/ .*$/, "", $2); print $2}' < /proc/cmdline)
# get the password hash from the kernel command line. It can contain newlines
PWD=$(grep 'live.password_hash=' < /run/agama/cmdline.d/agama.conf | awk -F 'live.password_hash=' '{sub(/ .*$/, "", $2); print $2}')
if [ -n "$PWD" ]; then
usermod -p "$PWD" root
fi
Expand Down
17 changes: 17 additions & 0 deletions live/root/usr/lib/dracut/modules.d/99agama-cmdline/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@ dracut agama-cmdline module
This module writes any agama configuration given through the kernel cmdline
to its own cmdline conf file copying it to the sysroot.

It also tries to translate the linuxrc ifcfg kernel cmdline argument to the
corresponding ip one but only basic scenarios are supported.

## Supported examples

ifcfg=*=dhcp
ip=dhcp

ifcfg=eth0=dhcp
ip=eth0:dhcp

ifcfg=eth0.10=192.168.0.100/24,192.168.0.1
vlan=eth0.10:eth0 ip=192.168.0.100::192.168.0.1:24::eth0.10

ifcfg="eth0=192.168.0.33/24 10.0.0.100/24,192.168.0.1,192.168.0.1 10.0.0.1,suse.de"
ip=192.168.0.33::192.168.0.1:24::eth0 nameserver=192.168.0.1 nameserver=10.0.0.1 ip=10.0.0.100:::24::eth0

Loading