Skip to content

ccache: create the compiler shims without sudo - #18

Open
presto8 wants to merge 1 commit into
mainfrom
fix/ccache-symlinks-ownership
Open

presto8 wants to merge 1 commit into
mainfrom
fix/ccache-symlinks-ownership

Conversation

@presto8

@presto8 presto8 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

'sudo ln -s' left ~/.local/bin/{gcc,g++,cc,c++} owned by root inside
the user's own home directory, so they could not be inspected or
cleaned up without escalating again. The directory is user-writable and
needs no privilege.

Replace 'sudo rm -f' + 'sudo ln -s' with a plain 'ln -sf' (which also
makes the function re-runnable), declare the loop variable local, and
use 'command -v' rather than the external 'which'.

Existing root-owned links are replaced on the next run, since removal
depends on write permission to the directory rather than file
ownership.


🤖 Generated with Claude Code

'sudo ln -s' left ~/.local/bin/{gcc,g++,cc,c++} owned by root inside
the user's own home directory, so they could not be inspected or
cleaned up without escalating again. The directory is user-writable and
needs no privilege.

Replace 'sudo rm -f' + 'sudo ln -s' with a plain 'ln -sf' (which also
makes the function re-runnable), declare the loop variable local, and
use 'command -v' rather than the external 'which'.

Existing root-owned links are replaced on the next run, since removal
depends on write permission to the directory rather than file
ownership.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI 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.

🟢 Approval recommended

The change is narrowly scoped, aligns with the PR rationale, and improves correctness by avoiding root-owned files in the user’s home directory.

Pull request overview

This PR updates the install_ccache portion of the setup script to create compiler shim symlinks in ~/.local/bin without using sudo, preventing root-owned symlinks inside a user’s home directory and making the operation safely re-runnable.

Changes:

  • Replace sudo rm + sudo ln -s with ln -sf for idempotent symlink creation in a user-writable directory.
  • Resolve the ccache executable path once via command -v and reuse it across the shim creation loop.
  • Scope loop variables locally within install_ccache to avoid leaking shell variables.
File summaries
File Description
setup Removes unnecessary sudo from ccache compiler-shim symlink creation and makes the operation idempotent.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants