From 85aa2882e49a3229115cbad7945a19b54bd530ca Mon Sep 17 00:00:00 2001 From: Joseph Woolley Date: Sat, 5 Sep 2026 17:19:20 -0400 Subject: [PATCH 1/2] Strip password keyring auth from sddm-autologin too --- install/login/sddm.sh | 4 ++ migrations/1788600002.sh | 21 ++++++++++ test/shell.d/sddm-keyring-test.sh | 66 +++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 migrations/1788600002.sh create mode 100644 test/shell.d/sddm-keyring-test.sh diff --git a/install/login/sddm.sh b/install/login/sddm.sh index 250ce80e1f7e..6ceecae8b2ef 100644 --- a/install/login/sddm.sh +++ b/install/login/sddm.sh @@ -5,3 +5,7 @@ if [[ -f /etc/pam.d/sddm ]]; then sed -i '/-auth.*pam_gnome_keyring\.so/d' /etc/pam.d/sddm sed -i '/-password.*pam_gnome_keyring\.so/d' /etc/pam.d/sddm fi +if [[ -f /etc/pam.d/sddm-autologin ]]; then + sed -i '/-auth.*pam_gnome_keyring\.so/d' /etc/pam.d/sddm-autologin + sed -i '/-password.*pam_gnome_keyring\.so/d' /etc/pam.d/sddm-autologin +fi diff --git a/migrations/1788600002.sh b/migrations/1788600002.sh new file mode 100644 index 000000000000..fed86d33e69a --- /dev/null +++ b/migrations/1788600002.sh @@ -0,0 +1,21 @@ +echo "Strip password keyring auth from the SDDM autologin PAM stack" + +# Autologin uses /etc/pam.d/sddm-autologin, not sddm. Existing installs that +# already ran install/login/sddm.sh still have gnome-keyring auth/password +# modules on the autologin stack, which create an encrypted login keyring +# against Omarchy's passwordless default. + +pam=/etc/pam.d/sddm-autologin +[[ -f $pam ]] || exit 0 + +if ! grep -qE -- '-auth.*pam_gnome_keyring\.so|-password.*pam_gnome_keyring\.so' "$pam"; then + exit 0 +fi + +if (( EUID == 0 )); then + sed -i '/-auth.*pam_gnome_keyring\.so/d' "$pam" + sed -i '/-password.*pam_gnome_keyring\.so/d' "$pam" +else + sudo sed -i '/-auth.*pam_gnome_keyring\.so/d' "$pam" + sudo sed -i '/-password.*pam_gnome_keyring\.so/d' "$pam" +fi diff --git a/test/shell.d/sddm-keyring-test.sh b/test/shell.d/sddm-keyring-test.sh new file mode 100644 index 000000000000..31fad54af538 --- /dev/null +++ b/test/shell.d/sddm-keyring-test.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +script="$ROOT/install/login/sddm.sh" +shipped_migration="$ROOT/migrations/1788600002.sh" + +grep -q 'sddm-autologin' "$script" || + fail "SDDM keyring strip covers the autologin PAM stack" +grep -q "/etc/pam.d/sddm-autologin" "$script" || + fail "SDDM keyring strip names the autologin PAM file" +[[ -f $shipped_migration ]] || fail "existing installs get an autologin keyring migration" +[[ $(head -n 1 "$shipped_migration") == echo* ]] || + fail "autologin keyring migration starts with an echo" +! grep -q '^#!' "$shipped_migration" || fail "autologin keyring migration has no shebang" +grep -Fxq 'pam=/etc/pam.d/sddm-autologin' "$shipped_migration" || + fail "the production autologin PAM path is a fixed literal" +if grep -q 'OMARCHY_.*PAM' "$shipped_migration"; then + fail "the migration does not accept caller-controlled privileged paths" +fi +pass "SDDM keyring strip covers password and autologin stacks" + +test_dir=$(mktemp -d) +trap 'rm -rf "$test_dir"' EXIT +mkdir -p "$test_dir/bin" +pam="$test_dir/sddm-autologin" +calls="$test_dir/calls" + +cat >"$test_dir/bin/sudo" <<'STUB' +#!/bin/bash +printf 'sudo %s\n' "$*" >>"${CALLS:?}" +exec "$@" +STUB +chmod +x "$test_dir/bin/sudo" + +sed "s|^pam=/etc/pam.d/sddm-autologin$|pam=$pam|" "$shipped_migration" >"$test_dir/migration.sh" + +cat >"$pam" <<'PAM' +#%PAM-1.0 +auth required pam_permit.so +-auth optional pam_gnome_keyring.so +account include system-local-login +password include system-local-login +-password optional pam_gnome_keyring.so use_authtok +-session optional pam_gnome_keyring.so auto_start +session include system-local-login +PAM + +: >"$calls" +CALLS="$calls" PATH="$test_dir/bin:$PATH" bash -euo pipefail "$test_dir/migration.sh" >/dev/null + +grep -q 'pam_permit.so' "$pam" || fail "keyring strip keeps required autologin auth" +grep -q 'pam_gnome_keyring.so auto_start' "$pam" || + fail "keyring strip keeps session keyring auto_start" +if grep -qE -- '-auth.*pam_gnome_keyring\.so|-password.*pam_gnome_keyring\.so' "$pam"; then + fail "keyring strip removes autologin auth and password gnome-keyring modules" +fi +grep -q '^sudo sed' "$calls" || fail "non-root migration elevates with sudo" +pass "keyring strip removes autologin auth and password gnome-keyring modules" + +: >"$calls" +CALLS="$calls" PATH="$test_dir/bin:$PATH" bash -euo pipefail "$test_dir/migration.sh" >/dev/null +[[ ! -s $calls ]] || fail "an already-stripped autologin stack is a no-op" "$(<"$calls")" +pass "an already-stripped autologin stack is a no-op" From aa06e70beb09f08f799a88dd268e381c968f3211 Mon Sep 17 00:00:00 2001 From: Joseph Woolley Date: Wed, 30 Sep 2026 09:55:17 -0400 Subject: [PATCH 2/2] Cover root and fresh-install paths in the SDDM keyring test --- test/shell.d/sddm-keyring-test.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/test/shell.d/sddm-keyring-test.sh b/test/shell.d/sddm-keyring-test.sh index 31fad54af538..73315bc1a207 100644 --- a/test/shell.d/sddm-keyring-test.sh +++ b/test/shell.d/sddm-keyring-test.sh @@ -37,7 +37,7 @@ chmod +x "$test_dir/bin/sudo" sed "s|^pam=/etc/pam.d/sddm-autologin$|pam=$pam|" "$shipped_migration" >"$test_dir/migration.sh" -cat >"$pam" <<'PAM' +cat >"$test_dir/pam-fixture" <<'PAM' #%PAM-1.0 auth required pam_permit.so -auth optional pam_gnome_keyring.so @@ -47,6 +47,7 @@ password include system-local-login -session optional pam_gnome_keyring.so auto_start session include system-local-login PAM +cp "$test_dir/pam-fixture" "$pam" : >"$calls" CALLS="$calls" PATH="$test_dir/bin:$PATH" bash -euo pipefail "$test_dir/migration.sh" >/dev/null @@ -57,10 +58,35 @@ grep -q 'pam_gnome_keyring.so auto_start' "$pam" || if grep -qE -- '-auth.*pam_gnome_keyring\.so|-password.*pam_gnome_keyring\.so' "$pam"; then fail "keyring strip removes autologin auth and password gnome-keyring modules" fi -grep -q '^sudo sed' "$calls" || fail "non-root migration elevates with sudo" +# Root runs the migration's direct sed path, so the sudo stub stays silent. +if (( EUID != 0 )); then + grep -q '^sudo sed' "$calls" || fail "non-root migration elevates with sudo" +else + [[ ! -s $calls ]] || fail "root migration edits the autologin stack without sudo" "$(<"$calls")" +fi pass "keyring strip removes autologin auth and password gnome-keyring modules" : >"$calls" CALLS="$calls" PATH="$test_dir/bin:$PATH" bash -euo pipefail "$test_dir/migration.sh" >/dev/null [[ ! -s $calls ]] || fail "an already-stripped autologin stack is a no-op" "$(<"$calls")" pass "an already-stripped autologin stack is a no-op" + +# install/login/sddm.sh hardcodes /etc/pam.d. Point a copy at the fixture +# instead of editing the host PAM stacks or the installer. +install_pam_dir="$test_dir/etc/pam.d" +mkdir -p "$install_pam_dir" +cp "$test_dir/pam-fixture" "$install_pam_dir/sddm" +cp "$test_dir/pam-fixture" "$install_pam_dir/sddm-autologin" +sed "s|/etc/pam.d|$install_pam_dir|g" "$script" >"$test_dir/install-sddm.sh" +bash -euo pipefail "$test_dir/install-sddm.sh" + +for stack in sddm sddm-autologin; do + target="$install_pam_dir/$stack" + grep -q 'pam_permit.so' "$target" || fail "fresh install keeps required auth in $stack" + grep -q 'pam_gnome_keyring.so auto_start' "$target" || + fail "fresh install keeps session keyring auto_start in $stack" + if grep -qE -- '-auth.*pam_gnome_keyring\.so|-password.*pam_gnome_keyring\.so' "$target"; then + fail "fresh install removes auth and password gnome-keyring modules from $stack" + fi +done +pass "fresh install strips password and autologin keyring auth"