Repository navigation
Fix install.sh escalating to sudo for user-writable $HOME/.local/bin - #12836
Conversation
needsSudo() only checked the install dir and its immediate parent. When the default install dir is $HOME/.local/bin and neither .local/bin nor .local exists yet (common on fresh GitHub-hosted runners), both checks fail and the installer escalates to sudo, creating the whole ~/.local tree root-owned even though $HOME is writable and no elevation was needed. A later user-owned install into the same dir (e.g. make install-yq via build/scripts/install-yq.sh) then fails with 'Permission denied' at the 'Load Radius contrib catalog' step of the extension deploy/delete workflows. Walk up to the nearest existing ancestor and only escalate when that ancestor is not writable, so $HOME/.local/bin is created as the current user and stays user-owned. Fixes #12835 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR fixes deploy/install.sh’s needsSudo() decision logic so the installer doesn’t unnecessarily escalate to sudo when installing into a user-writable nested directory (notably $HOME/.local/bin when .local/ doesn’t exist yet). This prevents creating a root-owned ~/.local tree that later breaks subsequent user-owned tool installs into the same location.
Changes:
- Updates
needsSudo()to walk up the directory tree to the nearest existing ancestor and only requiresudowhen that ancestor isn’t writable.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12836 +/- ##
=======================================
Coverage 59.97% 59.98%
=======================================
Files 776 776
Lines 46410 46410
=======================================
+ Hits 27836 27837 +1
+ Misses 18574 18573 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
If the install dir exists but is not writable (e.g. a pre-created root-owned dir) while its parent is writable, the previous walk starting at dirname(install_dir) incorrectly decided no sudo was needed, causing later cp/mkdir to fail with Permission denied. Start the walk at install_dir so an existing non-writable target correctly triggers sudo. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
Update the pinned install.sh tag in setup-control-plane from v0.59.0 to the latest stable release v0.60.1. The script is byte-identical between these tags, so RADIUS_INSTALL_SHA256 is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
The v0.60.1 bump did not carry the install.sh sudo fix (its install.sh is byte-identical to v0.59.0). The pin will instead be updated to the merge commit on main once the install.sh fix lands, so keep this PR scoped to the install.sh change only. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
getLatestRelease() called the GitHub releases API unauthenticated, which is rate-limited to 60 requests/hour per IP. On shared CI runners this limit is easily exhausted, causing the Validate Bash Installer job to fail when resolving the latest release. Add a githubApiGet() helper that sends an Authorization header when GITHUB_TOKEN is set, and pass github.token to the installer test steps in validate-installers.yaml. install.ps1 already supports GITHUB_USER/GITHUB_TOKEN Basic auth, so the PowerShell test step now passes those too. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
…ate limits" This reverts commit 09c8a4f. The bash installer CI failure was caused by GitHub API rate limiting, which is an edge case not worth addressing here. Keep this PR scoped to the sudo fix. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
Address review feedback: - test_default_dir_nonroot no longer pre-creates $HOME/.local/bin, so it reproduces #12835 and fails without the needsSudo() ancestor-walk logic. - test_nonwritable_dir_no_sudo_fails now chmods only the install dir (not its parent), pinning the 3fd9e2a fix that starts the walk at install_dir; drops the now-stale 'it checks both' comment. - Generalize the needsSudo() comment: all build/scripts/install-*.sh tools default to $HOME/.local/bin, not just yq. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
test_default_dir_nonroot only checked -f/-x/runnable, which pass even when the installer sudo-creates the tree root-owned on runners with passwordless sudo - so it still passed on main. Add a bash -O (owned by effective UID) assertion on both $HOME/.local and $HOME/.local/bin to pin the #12835 fix; -O avoids the GNU/BSD stat split for contributors on macOS. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Point the setup-control-plane install-script pin at the immutable commit carrying the install.sh sudo fix (#12836) so the ai-extensions workflows pick it up without waiting for a patch release. The ref is a full commit SHA (immutable) and the fetched script is still checksum-verified, preserving the existing security posture. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: sk593 <shruthikumar@microsoft.com>
## Purpose Unblock the extensions workflows on the `install.sh` sudo fix (#12836) **without waiting for a patch release**. `setup-control-plane` fetches `install.sh` from a pinned Radius ref and checksum-verifies it. This repoints that pin from the released tag to the **immutable commit** that carries the sudo fix, so consumers get the fixed script immediately. A full commit SHA is immutable and the script is still checksum-verified, so the existing security posture is preserved. - `RADIUS_INSTALL_REF`: `f4b44130e6cc` - `RADIUS_INSTALL_SHA256`: `d12f6e1101dea7911c491de14a0f0aef57518aaf573d46e225b29d6f103c2e86` Verified locally that the workflow's fetch + `sha256sum -c` succeeds against this ref. ## Before merging - [ ] Merge #12836 first. - [ ] Repoint `RADIUS_INSTALL_REF` to the **squash-merge commit of #12836 on `main`** (the fixed `install.sh` content is unchanged, so `RADIUS_INSTALL_SHA256` stays `6a00f7b8…`). This avoids depending on a PR-branch commit that could be GC'd after the branch is deleted. ## Notes Depends on #12836. --------- Signed-off-by: sk593 <shruthikumar@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…12836) ## Description `deploy/install.sh` could install the `rad` CLI into a **root-owned** `$HOME/.local/bin`, which then broke any later user-owned tool install into the same directory (e.g. `make install-yq`) with `Permission denied`. `needsSudo()` only checked the install dir and its **immediate** parent. When the default install dir is `$HOME/.local/bin` and neither `.local/bin` nor `.local` exists yet (common on a fresh GitHub-hosted runner), both checks fail, so the installer escalates to `sudo` and `sudo mkdir -p` creates the whole `~/.local` tree **root-owned** — even though `$HOME` is writable and no elevation was actually needed. The next user-owned install into that dir (`build/scripts/install-yq.sh`) then does `mkdir -p` (silently succeeds, dir exists) and `mv` into the root-owned dir, failing with `Permission denied` at the **Load Radius contrib catalog** step of the extension deploy/delete workflows. ### Fix Make `needsSudo()` walk up to the nearest **existing** ancestor and only escalate to `sudo` when that ancestor is not writable. For `$HOME/.local/bin` under a writable `$HOME`, the tree is created as the current user (no sudo) and stays user-owned, so later installs into it succeed. ## Type of change - Bugfix ## Fixes Fixes #12835 ## Testing Extracted the patched `needsSudo()` and exercised it against a temp filesystem: | Case | install dir | before | after | |------|-------------|--------|-------| | Fresh writable `$HOME`, nested `.local/bin` missing | `$HOME/.local/bin` | needs sudo ❌ | **no sudo** ✅ | | Existing writable install dir | `$HOME/.local/bin` | no sudo | no sudo ✅ | | `/usr/local/bin` (not writable) | `/usr/local/bin` | sudo | sudo ✅ | | Nearest existing ancestor not writable | `<ro>/sub/bin` | sudo | sudo ✅ | `bash -n` passes; behavior is unchanged for the root, already-writable, and genuinely-needs-root cases. ## Why it was intermittent `install-yq.sh` early-returns when a matching `yq` is already on `PATH`. Runners with a pre-baked `yq` skipped the failing `mv` entirely; runners without it hit it. Same workflow, different runner image contents. --------- Signed-off-by: sk593 <shruthikumar@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> (cherry picked from commit f4b4413)
…taller (radius-project#12852) ## Description `rad bicep download` (invoked by `deploy/install.ps1`) streams a large (~110MB) binary with no client-side timeout, so a stalled network transfer hangs the installer indefinitely. This surfaced during radius-project#12836 as the **Validate PowerShell Installer** CI job burning its full 10-minute budget at `Installing bicep...` and being cancelled, with no application error in the logs. Since bicep is optional (its failure is already non-fatal in the installer), this bounds the download: `rad bicep download` now runs as a child process with a 300s timeout. On timeout the process is stopped and the installer warns and continues instead of hanging. This is a **script-level mitigation**. The underlying root cause — the missing HTTP timeout in the rad CLI's shared bicep download code (`pkg/cli/bicep/tools/download_tools.go` uses `http.Get` + `io.Copy` with no deadline) — is tracked in radius-project#12851. ## Type of change This pull request fixes a bug in Radius and has an approved issue (radius-project#12851). ## Notes - Surfaced during radius-project#12836. - Verified the timeout/kill and success paths locally with `pwsh` (parse check + simulated hang). - No unit-test framework exists for the installer shell scripts; validated via the `Validate PowerShell Installer` job. --------- Signed-off-by: sk593 <shruthikumar@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description
deploy/install.shcould install theradCLI into a root-owned$HOME/.local/bin, which then broke any later user-owned tool install into the same directory (e.g.make install-yq) withPermission denied.needsSudo()only checked the install dir and its immediate parent. When the default install dir is$HOME/.local/binand neither.local/binnor.localexists yet (common on a fresh GitHub-hosted runner), both checks fail, so the installer escalates tosudoandsudo mkdir -pcreates the whole~/.localtree root-owned — even though$HOMEis writable and no elevation was actually needed.The next user-owned install into that dir (
build/scripts/install-yq.sh) then doesmkdir -p(silently succeeds, dir exists) andmvinto the root-owned dir, failing withPermission deniedat the Load Radius contrib catalog step of the extension deploy/delete workflows.Fix
Make
needsSudo()walk up to the nearest existing ancestor and only escalate tosudowhen that ancestor is not writable. For$HOME/.local/binunder a writable$HOME, the tree is created as the current user (no sudo) and stays user-owned, so later installs into it succeed.Type of change
Fixes
Fixes #12835
Testing
Extracted the patched
needsSudo()and exercised it against a temp filesystem:$HOME, nested.local/binmissing$HOME/.local/bin$HOME/.local/bin/usr/local/bin(not writable)/usr/local/bin<ro>/sub/binbash -npasses; behavior is unchanged for the root, already-writable, and genuinely-needs-root cases.Why it was intermittent
install-yq.shearly-returns when a matchingyqis already onPATH. Runners with a pre-bakedyqskipped the failingmventirely; runners without it hit it. Same workflow, different runner image contents.