Skip to content

feat(installer): self-elevate an un-elevated PowerShell run + cmd-safe docs (#421) - #489

Merged
shujaatTracebloc merged 4 commits into
developfrom
fix/421-self-elevate
Jul 30, 2026
Merged

feat(installer): self-elevate an un-elevated PowerShell run + cmd-safe docs (#421)#489
shujaatTracebloc merged 4 commits into
developfrom
fix/421-self-elevate

Conversation

@shujaatTracebloc

@shujaatTracebloc shujaatTracebloc commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What & why

Real users paste the one-liner into a normal PowerShell (or cmd.exe), where the install either dies later on the admin requirement or fails syntactically. #386 added elevation instructions; this automates the common case so a hospital user doesn't need to know "Terminal (Admin)" is a separate thing.

Changes (scripts/install-k8s.ps1, docs/INSTALL.md)

  • Self-elevate: on an un-elevated interactive run, offer to relaunch elevated — one consent → Start-Process -Verb RunAs (one UAC prompt) → install proceeds. Get-ElevationCommand builds the relaunch args: re-run the on-disk .ps1 when present, else re-fetch the documented one-liner (irm … | iex), forwarding -NoReboot / -Diagnose.
  • Graceful fallback: non-interactive, declined, or a failed launch → the followable Win+X → Terminal (Admin) steps (Installer (Windows): admin-gate says "right-click > Run as Administrator" — impossible to follow in the irm|iex flow #386 behavior preserved).
  • cmd-safe docs: docs/INSTALL.md now shows the Command-Prompt form powershell -ExecutionPolicy Bypass -Command "irm … | iex" so a paste into cmd.exe runs instead of erroring, plus the exact Win11 admin steps.

Acceptance (from #421)

  • Detect un-elevated PowerShell → offer to relaunch elevated (RunAs), one-line consent, forwarding switches
  • Document a cmd-safe variant on the install snippet
  • docs/INSTALL.md aligned with exact Win11 steps (Win+X → Terminal (Admin))
  • Paste into un-elevated PowerShell → one UAC consent → install proceeds; paste into cmd → working guidance

Scope notes

  • Env-var config (TRACEBLOC_*) is intentionally not forwarded across RunAs: ShellExecute doesn't inherit the caller's process env, and putting secrets on a command line is unsafe. Documented — env-driven runs should be launched elevated.
  • The website install snippet + screenshot live in tracebloc-website (separate repo), so they're out of scope here; the cmd-safe form is captured in docs/INSTALL.md.

Tests

Get-ElevationCommand (on-disk -File vs one-liner re-fetch, switch forwarding) + gate source guards (offers RunAs before instructions; only prompts when interactive).

Local verification

Pester 294/0/9 · check-style pass · drift clean · manifest regenerated · PS parse OK. (No bash changes — bats unaffected.)

Closes #421


Note

Low Risk
Installer UX and documentation only; elevation logic is gated on interactivity with tested fallbacks and does not change cluster or credential handling.

Overview
Windows installer no longer exits immediately when run without Administrator rights. In an interactive session it warns, asks to relaunch elevated, and uses Start-Process -Verb RunAs (one UAC prompt). Get-ElevationCommand / Invoke-SelfElevate build the relaunch: durable on-disk .ps1 paths use quoted -File and forward -NoReboot / -Diagnose; the documented irm | iex path and bootstrap temp scripts re-fetch the one-liner (switches not forwarded to the paramless shim). Declined, non-interactive, or failed elevation still shows the Win+X → Terminal (Admin) steps from #386.

docs/INSTALL.md splits PowerShell vs Command Prompt install lines, adds the powershell -ExecutionPolicy Bypass -Command "irm … | iex" form for cmd.exe, and documents admin requirements plus optional self-elevation.

Tests cover Get-ElevationCommand quoting and paths; manifest hash updated for install-k8s.ps1.

Reviewed by Cursor Bugbot for commit 09eb02a. Bugbot is set up for automated code reviews on this repo. Configure here.

Real users paste the one-liner into a normal PowerShell (or cmd) and the install
either dies on the admin requirement or errors syntactically. #386 added
elevation instructions; this automates the common case.

- On an un-elevated interactive run, offer to relaunch elevated: one consent ->
  Start-Process -Verb RunAs (UAC) -> install proceeds. Get-ElevationCommand builds
  the relaunch args -- re-run the on-disk .ps1 when present, else re-fetch the
  one-liner (irm|iex) -- forwarding -NoReboot/-Diagnose. Non-interactive/declined/
  failed falls back to the followable Win+X -> Terminal (Admin) steps (#386).
- docs/INSTALL.md: add the cmd-safe form
  (powershell -ExecutionPolicy Bypass -Command "irm ... | iex") so a paste into
  cmd.exe runs instead of a syntax error, plus the exact Win11 admin steps.

Env-var config (TRACEBLOC_*) is intentionally not forwarded across RunAs (no env
inheritance; secrets on a command line are unsafe) -- documented; env-driven runs
should be launched elevated.

Tests: Get-ElevationCommand (file vs one-liner, switch forwarding) + gate source
guards. Website snippet + screenshot are a separate repo (noted in the PR).

Closes #421

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shujaatTracebloc shujaatTracebloc self-assigned this Jul 30, 2026
@shujaatTracebloc
shujaatTracebloc marked this pull request as ready for review July 30, 2026 09:48
@LukasWodka

Copy link
Copy Markdown
Contributor

👋 Heads-up — Code review queue is at 31 / 30

Above the WIP limit. The team convention is to review existing PRs before opening new work.

Open PRs currently in Code review (oldest first):

Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.)

Comment thread scripts/install-k8s.ps1
Comment thread scripts/install-k8s.ps1 Outdated
…wards switches (Bugbot)

Two elevation-relaunch defects:
- The documented irm|iex flow runs install-k8s.ps1 from a bootstrap TEMP dir the
  un-elevated process deletes on exit, so -File <tempfile> in the elevated window
  hit a missing script. Only use -File for a DURABLE (non-temp) path; otherwise
  re-fetch the one-liner.
- The one-liner branch dropped -NoReboot/-Diagnose. iex can't take args, so when
  switches must be forwarded, invoke the fetched shim as a scriptblock with them;
  keep the plain irm|iex form when there are none.

Adds temp-dir and switch-forwarding tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 07f6df3. Configure here.

Comment thread scripts/install-k8s.ps1 Outdated
Comment thread scripts/install-k8s.ps1 Outdated
shujaatTracebloc and others added 2 commits July 30, 2026 12:04
…switches (Bugbot)

Two elevation follow-ups:
- Get-ElevationCommand now returns a single command-line STRING and quotes the
  -File path, so a script path with spaces survives PS 5.1's Start-Process
  -ArgumentList (which doesn't quote array elements; same class as #419).
- The one-liner path no longer tries to forward switches via a scriptblock: the
  shim (i.ps1) has no param block, so & ([scriptblock]) -Diagnose fails on an
  unknown named parameter; and an irm|iex launch can't have set a switch anyway.
  Keep the exact documented irm|iex form.

Tests updated for the string contract + the no-scriptblock one-liner path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants