fix(updater): scope the installer for every machine install, not just unelevated ones - #42
Merged
Merged
Conversation
… unelevated ones The scope switch rode on the elevation gate, so an already-elevated machine install — launched "as administrator", or an admin account with UAC consent off — fell through to the plugin's own `/P /UPDATE /R /ARGS` with no `/allusers` and updated the per-user copy again. What the plugin omits is the scope, not the elevation, so the install path now keys on `running_machine_install` alone; `machine_install_needs_elevation` stays as the Settings hint's predicate. The verb follows suit: `runas` only when there is something to raise, `open` when already elevated. Also corrects the mechanism this rests on, from the re-review's reading of MultiUser.nsh: NSIS reads the default-mode value from HKLM *first*, not HKCU. It works because the value name is `CurrentUser` and an all-users install writes `AllUsers`, so the HKLM read is always empty here and only the HKCU read can decide — a stronger guarantee than the one the comment claimed. The ordering test's comment was wrong for the same kind of reason: MultiUser would still see a trailing switch, but NSIS `GetOptions` would truncate the relaunch arguments at it. Co-Authored-By: Claude Opus 5 <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
Re-review follow-up on #41, caught before 0.13.3 shipped (tag and draft were withdrawn).
/alluserswas attached to the elevation gate, so it only reached installers we launched ourselves. A machine install that is already elevated — started "as administrator", or an admin account with UAC consent disabled — fell through to the plugin's own/P /UPDATE /R /ARGS, no scope switch, and MultiUser took the path #41 proved broken: per-user key wins,Program Filesskipped.What the plugin omits is the scope, not the elevation. So:
running_machine_install()alone;machine_install_needs_elevation()survives as the predicate behind the Settings hint, which is genuinely about whether a prompt appears;runasonly when something needs raising,openwhen already elevated (a second hop would be pointless and can re-prompt).Mechanism correction
The re-review read the real
MultiUser.nsh, and my explanation was wrong in a load-bearing way. NSIS reads the default-mode value from HKLM first, HKCU second — not the other way round. The fix works for a better reason than I gave: the value name isCurrentUserand an all-users install writes one namedAllUsers, so the HKLM read is always empty for this template. Only the HKCU read can decide, and it can only ever flip the mode to per-user. The command-line check then runs last and unconditionally, so the switch always wins.The ordering test's comment was wrong the same way: MultiUser would still see a trailing
/allusers(it scans the whole command line), but NSISGetOptionsstops at the next unquoted switch, so the switch would truncate the relaunch arguments and lose a file opened from the command line.Test plan
cargo test --lib app_update13/13,cargo clippy -- -D warningscleannpm test2100/2100,npm run buildclean🤖 Generated with Claude Code