fix(install): Stop before the download when sudo needs a password - #7
Merged
Merged
Conversation
This was referenced Sep 25, 2026
ananos
changed the base branch from
fix/rootless-per-user-device-grant
to
main
September 25, 2026 22:40
For a user install on a host that is not prepared, install.sh printed the missing host settings as a warning and went on. It downloaded and unpacked the bundle, about 488 MB, and then brig-rootless-setup.sh asked for sudo. A user without sudo was left at `[sudo] password for <user>:`, or without a terminal, with a failed install. brig's install guide says a user install asks for sudo at no point. The preflight now covers every sudo call the setup can make: the device grant, loading kvm and vhost_vsock, loading vhost_vsock at boot, the AppArmor profile, and home directories an earlier sudo run left root-owned. When any of them is missing and `sudo -n true` fails, it stops before the download. It prints what is missing and one `sudo sh` block that fixes it for this user and this prefix. An admin runs that block, and the next run of the installer needs no sudo. With sudo that runs without a password, nothing changes: the setup makes the settings at the end. Missing packages and a missing subuid range stop the install as before, since the setup never made them. The block now covers those too, and the subuid range it offers starts past every range already handed out. The setup no longer asks sudo to load a module the kernel does not have. That was a password prompt for nothing. This builds on the per-user grant file. The block writes 99-brig-kvm-<user>.rules, and the setup reads the grant back from the devices. tests/install-preflight.sh runs install.sh against a stub sudo, getfacl, stat and sysctl, and points it at a bundle that does not exist. Without sudo, it checks that the install stops before the fetch, writes nothing under $HOME, and prints a valid block with the udev rule and the AppArmor profile for this user. With sudo, it checks that the install goes on. On a prepared host, it checks that no sudo is asked for. Against the previous install.sh it fails the first check: the install goes on to fetch the bundle. Checked live on an Ubuntu 24.04 host, with a user who has no sudo. The previous installer unpacked 488M into their home and then failed at sudo. This one stopped with the block and left nothing in $HOME. An admin ran the block as printed, and the user's next run installed without a single sudo call. A microVM then booted with its monitor running as that user. Signed-off-by: Anastassios Nanos <ananos@nofire.ai>
ananos
force-pushed
the
fix/install-stop-without-sudo
branch
from
September 25, 2026 22:40
d783015 to
7c6443c
Compare
ananos
marked this pull request as ready for review
September 25, 2026 22:44
5 tasks
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.
Stacked on #6: the commands this prints write the per-user rule file that #6
introduces, and the setup reads the grant back from the devices the way #6
does. Review #6 first. Once it merges, this retargets to
main.Summary
For a user install on a host that is not prepared,
install.shprinted themissing host settings as a warning and went on. It downloaded and unpacked the
bundle, about 488 MB, and only then did
brig-rootless-setup.shask for sudo. Auser without sudo was left at
[sudo] password for <user>:with a half-doneinstall, or, without a terminal, with a failed one. brig's install guide says
the user path "asks for sudo at no point".
Now, when something needs root and
sudo -n truefails, the installer stopsbefore the download. It prints what is missing, and one block of root commands
for this user and this prefix. An admin runs that block once, and the next run
of the installer needs no sudo at all. With sudo that runs without a password,
nothing changes: the setup makes the settings at the end, as before.
Changes
loading
kvmandvhost_vsock, loadingvhost_vsockat boot, the AppArmorprofile for this prefix's rootlesskit, and home directories an earlier sudo
run left root-owned.
sudo sh -eu <<'BRIG_ROOT'heredoc with the udev rule, theAppArmor profile and whatever else is missing, in dependency order. Its udev
rule is the setup's own text, so the file an admin writes and the file the
setup writes are identical (same sha256 on the live host below).
uidmaporacl, or a missing subuid range, stop the install asbefore, since the setup never made them. The block now covers those too. The
subuid range it offers starts past every range already in
/etc/subuidand/etc/subgid, so it cannot overlap another user's.sudo -vand then the installeragain, which makes these itself.
which was a password prompt for nothing.
docs/rootless.mdshows the stop and the block.tests/install-preflight.sh.Testing
tests/install-preflight.shrunsinstall.shas a user install against a stubsudo,getfacl,stat,sysctlandmodinfo, pointed at a bundle that doesnot exist. A run that gets past the preflight fails on the fetch and says so.
The same test against the previous
install.sh:sh -n(dash) andshellcheck -s shpass overinstall.sh,build-bundle.sh, the three generated scripts and both tests.Live, on an Ubuntu 24.04 host
A fresh user,
brigtest2, with a subuid range and no sudo(
sudo -n truesays "a password is required"), installed from a local copy ofthe v0.1.0-rc8 rootless bundle. For the branch run, the bundle's setup and
brig-ctlwere regenerated from these branches, andsysctlwas stubbed toreport the AppArmor restriction so the profile shows up in the block. This host
does not set it.
The previous installer, on the release bundle, unpacked and then failed:
This branch stopped before anything was unpacked:
Before the admin step,
brigtest2could not open either device from a usernamespace (
unshare --user --map-root-user):Permission deniedon both. Anadmin fed the block, as printed, to
sudo sh -eu. After it, the same probeopened both, the profile was loaded, and the other two users' rule files kept
their hashes (
998f808f...,982b3773...) and their ACLs.The next run of the installer as
brigtest2, with a sudo shim that logs andrefuses every call first on
PATH, installed to the end with an empty shimlog. So did a re-run of
brig-ctl rootless.brig doctorwas green, andbrig run -d ubuntu ~/projbooted a guest with qemu running asbrigtest2.Afterwards
brigtest2and everything made for it were removed.🤖 Generated with Claude Code