Skip to content
Merged
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
25 changes: 25 additions & 0 deletions biglinux-livecd/usr/bin/startbiglive
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ _apply_default_config() {
_log "Applying default configuration (wizard was skipped)"
write_live_state language en_US
write_live_state desktop-theme breeze
write_live_state desktop 'startkde-biglinux classic'
}

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -694,6 +695,29 @@ _reset_gnome_portals() {
2>/dev/null || true
}

_plasma_live_layout_name() {
local desktop_state desktop_state_file layout
desktop_state_file=$(live_state_path desktop) || return 1
[[ -f $desktop_state_file && ! -L $desktop_state_file ]] || return 1
desktop_state=$(<"$desktop_state_file")
layout=$(cut -f2 -d" " <<<"$desktop_state")
[[ $layout =~ ^[A-Za-z0-9_.+-]+$ ]] || return 1
printf '%s\n' "$layout"
}

_prepare_plasma_live_defaults() {
local layout
if ! install_live_state_defaults; then
_log "WARNING - Could not install Plasma live defaults"
return 0
fi
[[ -n ${HOME:-} && $HOME != / ]] || return 0
rm -f -- "$HOME/.big_desktop_theme" "$HOME/.kdebiglinux/lastlogin" "$HOME/.kdebiglinux/lastused"
if layout=$(_plasma_live_layout_name); then
rm -rf -- "$HOME/.kdebiglinux/$layout"
fi
}

# libadwaita apps use their own color-scheme setting and can ignore GTK INI files
# in non-GNOME sessions. GNOME reads color-scheme from dconf directly, and the
# forced override would fight the wizard's choice there, so skip it on gdm.
Expand Down Expand Up @@ -736,6 +760,7 @@ elif [[ -e /usr/share/wayland-sessions/hyprland.desktop ]]; then

elif [[ "$display_manager" == "sddm" || "$display_manager" == "lxdm" ]]; then
# KDE Plasma
_prepare_plasma_live_defaults
if [[ "$session_type" == "x11" ]]; then
exec startkde-biglinux
else
Expand Down
27 changes: 25 additions & 2 deletions biglinux-livecd/usr/lib/biglinux-livecd/live-state
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

live_state_directory=/tmp
live_state_default_config_directory=/etc/big-default-config
live_state_legacy_theme_path=/etc/default-theme-biglinux
live_state_legacy_desktop_path=/etc/big_desktop_changed

live_state_path() {
case "$1" in
Expand Down Expand Up @@ -53,7 +56,27 @@ initialize_default_live_state() {
}

install_live_state_defaults() {
local desktop_state theme_state
require_live_state_directory || return 1
sudo install -m 0644 -- "$(live_state_path desktop-theme)" /etc/default-theme-biglinux
sudo install -m 0644 -- "$(live_state_path desktop)" /etc/big_desktop_changed
theme_state=$(live_state_path desktop-theme) || return 1
desktop_state=$(live_state_path desktop) || return 1
[[ -f $theme_state && ! -L $theme_state ]] || return 1
[[ -f $desktop_state && ! -L $desktop_state ]] || return 1

sudo -n install -d -m 0755 -- "$live_state_default_config_directory"
sudo -n install -m 0644 -- "$theme_state" "$live_state_default_config_directory/theme"
sudo -n install -m 0644 -- "$desktop_state" "$live_state_default_config_directory/desktop"
sudo -n install -m 0644 -- "$theme_state" "$live_state_legacy_theme_path"
sudo -n install -m 0644 -- "$desktop_state" "$live_state_legacy_desktop_path"

if [[ -f $(live_state_path enable-jamesdsp) && ! -L $(live_state_path enable-jamesdsp) ]]; then
sudo -n install -m 0644 -- "$(live_state_path enable-jamesdsp)" "$live_state_default_config_directory/jamesdsp"
else
sudo -n rm -f -- "$live_state_default_config_directory/jamesdsp"
fi
if [[ -f $(live_state_path improve-display) && ! -L $(live_state_path improve-display) ]]; then
sudo -n install -m 0644 -- "$(live_state_path improve-display)" "$live_state_default_config_directory/display-profile"
else
sudo -n rm -f -- "$live_state_default_config_directory/display-profile"
fi
}
61 changes: 61 additions & 0 deletions tests/test_livecd_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,67 @@ def test_startbiglive_resets_early_portals_before_gnome(tmp_path: Path) -> None:
assert reset < session


def test_live_state_defaults_publish_plasma_contract(tmp_path: Path) -> None:
state_directory = tmp_path / "state"
default_config = tmp_path / "etc/big-default-config"
legacy_theme = tmp_path / "etc/default-theme-biglinux"
legacy_desktop = tmp_path / "etc/big_desktop_changed"
state_directory.mkdir()
default_config.mkdir(parents=True)
(default_config / "jamesdsp").write_text("stale", encoding="utf-8")
(default_config / "display-profile").write_text("stale", encoding="utf-8")
result = run_bash(
"""
source "$LIVE_STATE"
sudo() {
if [[ ${1:-} == -n ]]; then
shift
fi
"$@"
}
live_state_directory=$STATE_DIRECTORY
live_state_default_config_directory=$DEFAULT_CONFIG
live_state_legacy_theme_path=$LEGACY_THEME
live_state_legacy_desktop_path=$LEGACY_DESKTOP
write_live_state desktop-theme biglinux
write_live_state desktop classic
install_live_state_defaults
""",
environment={
"LIVE_STATE": str(LIVE_STATE),
"STATE_DIRECTORY": str(state_directory),
"DEFAULT_CONFIG": str(default_config),
"LEGACY_THEME": str(legacy_theme),
"LEGACY_DESKTOP": str(legacy_desktop),
},
)
assert result.returncode == 0, result.stderr
assert (default_config / "theme").read_text(encoding="utf-8") == "biglinux"
assert (default_config / "desktop").read_text(encoding="utf-8") == "classic"
assert legacy_theme.read_text(encoding="utf-8") == "biglinux"
assert legacy_desktop.read_text(encoding="utf-8") == "classic"
assert not (default_config / "jamesdsp").exists()
assert not (default_config / "display-profile").exists()


def test_startbiglive_prepares_plasma_defaults_before_session() -> None:
source = STARTBIGLIVE.read_text(encoding="utf-8")
function_start = source.index("_prepare_plasma_live_defaults() {")
function_end = source.index("\n}\n", function_start) + 3
function = source[function_start:function_end]
assert "install_live_state_defaults" in function
assert 'rm -f -- "$HOME/.big_desktop_theme"' in function
assert '"$HOME/.kdebiglinux/lastlogin"' in function
assert '"$HOME/.kdebiglinux/lastused"' in function

plasma_branch = source.index(
'elif [[ "$display_manager" == "sddm" || "$display_manager" == "lxdm" ]]'
)
prepare = source.index("_prepare_plasma_live_defaults", plasma_branch)
session = source.index("exec startkde-biglinux", plasma_branch)
assert prepare < session


def test_wizard_defers_noninitial_pages_and_accessibility_backends() -> None:
app_window = (
PACKAGE / "usr/share/biglinux/livecd/ui/app_window.py"
Expand Down
Loading