From edb5016809f3bc657283d8c2402970dbbab3c5cf Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 23 Jun 2026 20:55:07 -0400 Subject: fix(installer): RAID validation, set -e fix, drop dead shadow branch Two installer cleanups from the todo backlog. validate_config now rejects a RAID_LEVEL the selected disk count can't support, guarding the unattended path (the interactive path already constrains the choice). While adding it I found a latent bug: the error loop's ((errors++)) returned 0 on the first error and tripped set -e in the monolith's `[[ UNATTENDED == true ]] && validate_config` call, aborting after one warning instead of listing every problem. Switched to pre-increment so the count accumulates as designed. Added four bats cases, including one that runs validate_config under set -e outside bats' run shield. build.sh dropped the dead shadow-file rebuild else-branch. The profile is always copied fresh from releng (which ships /etc/shadow), so the branch never ran, and its hardcoded account list had drifted from what releng provides. Replaced with an assertion that fails the build loudly if the file is ever missing. --- build.sh | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'build.sh') diff --git a/build.sh b/build.sh index 6dbdef0..566a2a7 100755 --- a/build.sh +++ b/build.sh @@ -447,33 +447,14 @@ EOF info "Setting root password for live ISO..." # Generate password hash PASS_HASH=$(openssl passwd -6 "$LIVE_ROOT_PASSWORD") -# Modify the existing shadow file's root entry (don't replace entire file) -# The releng template has multiple accounts; replacing breaks the file -if [[ -f "$PROFILE_DIR/airootfs/etc/shadow" ]]; then - sed -i "s|^root:[^:]*:|root:${PASS_HASH}:|" "$PROFILE_DIR/airootfs/etc/shadow" -else - # Fallback: create complete shadow file if it doesn't exist - cat > "$PROFILE_DIR/airootfs/etc/shadow" << EOF -root:${PASS_HASH}:19000:0:99999:7::: -bin:!*:19000:::::: -daemon:!*:19000:::::: -mail:!*:19000:::::: -ftp:!*:19000:::::: -http:!*:19000:::::: -nobody:!*:19000:::::: -dbus:!*:19000:::::: -systemd-coredump:!*:19000:::::: -systemd-network:!*:19000:::::: -systemd-oom:!*:19000:::::: -systemd-journal-remote:!*:19000:::::: -systemd-resolve:!*:19000:::::: -systemd-timesync:!*:19000:::::: -tss:!*:19000:::::: -uuidd:!*:19000:::::: -polkitd:!*:19000:::::: -avahi:!*:19000:::::: -EOF -fi +# Modify the existing shadow file's root entry (don't replace the whole +# file — the releng template ships /etc/shadow with multiple accounts and +# rewriting it from scratch would drop them). The profile is always copied +# fresh from releng above, so the file is present; if it's missing, that +# copy is broken — fail loudly rather than silently rebuilding a stale list. +[[ -f "$PROFILE_DIR/airootfs/etc/shadow" ]] \ + || error "Expected shadow file missing: $PROFILE_DIR/airootfs/etc/shadow (releng profile copy broken?)" +sed -i "s|^root:[^:]*:|root:${PASS_HASH}:|" "$PROFILE_DIR/airootfs/etc/shadow" chmod 400 "$PROFILE_DIR/airootfs/etc/shadow" # Allow root SSH login with password (for testing) -- cgit v1.2.3