MODERNIZE: enable uv/pipx install with runtime sudo elevation - #36
Open
ventusff wants to merge 2 commits into
Open
MODERNIZE: enable uv/pipx install with runtime sudo elevation#36ventusff wants to merge 2 commits into
ventusff wants to merge 2 commits into
Conversation
Re-exec the command under sudo when a root-needing action (--list, --sync, --sync-all) is invoked by a non-root user, so the package can be installed at user level (uv tool / pipx / pip --user) without sudo and still get access to /var/lib/bluetooth and the Windows registry hive. Adds --no-elevate to opt out of the auto sudo re-exec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
NTFS is case-insensitive when accessed by Windows itself, but Linux NTFS drivers (ntfs-3g, ntfs3) are case-sensitive by default — and not every Windows install stores the SYSTEM hive on disk in upper-case; some have `system` (and lower-case `windows`/`system32`/`config`). The hard-coded `Windows/System32/config/SYSTEM` path then fails both auto-detection in locate_windows_mount_points (glob.glob) and reged invocation (`openHive(...) failed: No such file or directory`). Add a resolve_path_ci helper that walks each segment under a base, preferring exact match and falling back to a case-insensitive listdir lookup. Use it in WindowsRegistry._registry_file() and in locate_windows_mount_points (replacing glob.glob). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Make a user-level install (e.g.
uv tool install bt-dualboot,pipx install bt-dualboot) the recommended install path. The tool now self-elevates viasudoat runtime when a root-needing action is requested, andsudoprompts for the password on the TTY. Pass--no-elevateto opt out and run as root yourself.Also includes a drive-by fix for case-insensitive Windows registry path resolution, surfaced while testing on a real dual-boot machine.
Usage
What changed
Runtime privilege elevation (
6975ad1)bt_dualboot/cli/privilege.pywithaction_requires_root(opts)andelevate_via_sudo().cli/app.pycallselevate_via_sudo()frommain()for-l,--sync,--sync-all. New--no-elevateflag opts out.~/.local/bin/bt-dualboot); falls back topython -m bt_dualboototherwise. TheDEBUGenv var is preserved across the sudo boundary viasudo --preserve-env=DEBUG.sudo pip installis no longer recommended;uv tool installandpipx installare documented.Case-insensitive registry path resolution (
b990db1)resolve_path_ci(base, relative)walks each segment underbase, preferring exact match and falling back to a case-insensitivelistdirlookup.WindowsRegistry._registry_file()and bylocate_windows_mount_points()(replacingglob.glob, which is case-sensitive on Linux).openHive(...) failed: No such file or directoryon Windows installs whose hive is on disk assystem(lower-case) rather thanSYSTEM. NTFS is case-insensitive in Windows itself, but Linux NTFS drivers (ntfs-3g,ntfs3) are case-sensitive by default.Test plan
pytest tests/— 48 passed (was 42; +6 new tests covering the case-insensitive resolver)bt-dualboot --version,--list-win-mounts,-h— no sudo promptbt-dualboot -l— re-execs under sudo, prompts for password, lists devicesbt-dualboot --sync-all --dry-run --no-backup— DRY RUN output after sudo promptsudo bt-dualboot -l— runs without re-elevation (early return wheneuid == 0)--no-elevateexits with a clear error when the action would need rootsystem(lower-case) — failed withopenHive(...) failed: No such file or directorybefore this PR; resolves correctly nowSYSTEM— exact match is tried first, so this path should be unchanged🤖 Generated with Claude Code