Repository navigation
Harden omarchy-refresh-limine's privileged read against a caller-controlled OMARCHY_PATH #14073
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
Open
Josehbr
wants to merge
4
commits into
omacom:quattro
Choose a base branch
from
Josehbr:harden-refresh-limine
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a2c3acd
Harden omarchy-refresh-limine's privileged read against a caller-cont…
Josehbr ca7b98e
Test successful Limine refresh with and without an existing config
Josehbr c3b5dbe
Keep the sudo boundary fixture out of TMPDIRs containing spaces
Josehbr d7138c3
Run omarchy-refresh-limine's sudo steps behind the command-scoped wra…
Josehbr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
| source "$SHELL_TEST_DIR/fixtures/sudo-boundary-test.sh" | ||
|
|
||
| copy_boundary_file bin/omarchy-refresh-limine | ||
|
|
||
| # Keep every bootloader operation inside the fixture. The sudo stand-in logs | ||
| # each request and runs only commands against these temporary paths. | ||
| boot_dir="$boundary_tmp/boot" | ||
| mkdir -p "$boot_dir" "$SUDO_TEST_ROOT/default/limine" | ||
| printf 'fixture-machine\n' >"$boundary_tmp/machine-id" | ||
| printf 'new limine config\n' >"$SUDO_TEST_ROOT/default/limine/limine.conf" | ||
| python3 - "$SUDO_TEST_ROOT/bin/omarchy-refresh-limine" "$boot_dir" "$boundary_tmp/machine-id" <<'PY' | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| script, boot_dir, machine_id = map(Path, sys.argv[1:]) | ||
| text = script.read_text().replace('/boot', str(boot_dir)).replace('/etc/machine-id', str(machine_id)) | ||
| script.write_text(text) | ||
| PY | ||
| ln -s test-step "$SUDO_TEST_ROOT/bin/limine-update" | ||
| ln -s test-step "$SUDO_TEST_ROOT/bin/limine-snapper-sync" | ||
| # The shared fixture stubs cp for update tests; this test needs the real copy | ||
| # to verify the staged config reaches its temporary boot directory. | ||
| rm "$SUDO_TEST_ROOT/bin/cp" | ||
|
|
||
| for initial_config in present missing; do | ||
| reset_boundary | ||
| rm -f "$boot_dir/limine.conf" "$boot_dir/limine.conf.bak" | ||
| if [[ $initial_config == "present" ]]; then | ||
| printf 'old limine config\n' >"$boot_dir/limine.conf" | ||
| fi | ||
|
|
||
| PATH="$SUDO_TEST_ROOT/bin:$PATH" "$SUDO_TEST_ROOT/bin/omarchy-refresh-limine" >"$boundary_tmp/output" 2>&1 || | ||
| fail "refresh failed with $initial_config boot config" "$(<"$boundary_tmp/output")" | ||
|
|
||
| [[ $(<"$boot_dir/limine.conf") == "new limine config" ]] || fail "refresh did not copy the default config" | ||
| if [[ $initial_config == "present" ]]; then | ||
| [[ $(<"$boot_dir/limine.conf.bak") == "old limine config" ]] || fail "refresh did not back up the existing config" | ||
| else | ||
| [[ ! -e $boot_dir/limine.conf.bak ]] || fail "refresh made a backup without an existing config" | ||
| fi | ||
|
|
||
| python3 - "$SUDO_TEST_LOG" "$initial_config" "$boot_dir" "$SUDO_TEST_ROOT" <<'PY' | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| log, initial_config, boot_dir, root = sys.argv[1:] | ||
| events = Path(log).read_text().splitlines() | ||
| expected = [ | ||
| 'sudo -k', | ||
| 'sudo /usr/bin/true', | ||
| 'sudo -h', | ||
| f'sudo -N test -f {boot_dir}/EFI/Linux/omarchy_linux.efi', | ||
| f'sudo -N test -f {boot_dir}/limine.conf', | ||
| ] | ||
| if initial_config == 'present': | ||
| expected.append(f'sudo -N mv {boot_dir}/limine.conf {boot_dir}/limine.conf.bak') | ||
| expected += [ | ||
| f'sudo -N cp {root}/default/limine/limine.conf {boot_dir}/limine.conf', | ||
| 'sudo -N limine-update', | ||
| 'step:limine-update ', | ||
| 'sudo -N limine-snapper-sync', | ||
| 'step:limine-snapper-sync ', | ||
| 'sudo -k', | ||
| ] | ||
| assert events == expected, (events, expected) | ||
| PY | ||
| assert_boundary_cold "refresh with $initial_config boot config" | ||
| pass "refresh with $initial_config boot config copies and rebuilds, then revokes sudo" | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.