cmd/drover: UAC re-launch helper for non-admin invocations
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user