cmd/drover: UAC re-launch helper for non-admin invocations
Build / test (push) Failing after 32s
Build / build-windows (push) Has been skipped

CLI subcommands (check/version/update) don't need driver access and
run as user. Bare drover.exe (GUI/engine mode) requires admin for
WinDivertOpen — re-launches via ShellExecute("runas") and exits.

Per spec decision B1: prompt at every launch, no scheduled-task
trampoline.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-01 19:33:10 +03:00
parent c647c09c20
commit 8e83260123
3 changed files with 130 additions and 0 deletions
+11
View File
@@ -29,6 +29,17 @@ func main() {
// AttachConsole(ATTACH_PARENT_PROCESS) wires that up. No-op elsewhere.
attachToParentConsole()
// Detect if we need admin for the command in os.Args[1:]. If we do and
// we're not admin, re-launch via ShellExecute("runas", ...) and exit.
// CLI subcommands like "check", "version", "update" don't need admin
// and will run without UAC prompt.
if CmdNeedsAdmin(os.Args[1:]) && !IsAdmin() {
if err := ReElevate(os.Args[1:]); err != nil {
fmt.Fprintf(os.Stderr, "failed to re-elevate: %v\n", err)
}
os.Exit(0)
}
// Inject our build version so the updater package can stamp it on the
// User-Agent header it sends to git.okcu.io.
updater.SetVersion(Version)