Repository navigation
config: preserve execute bit when self-protection locks a file - #172
Merged
Merged
Conversation
lockFile's Linux fallback chmod'd every protected target to 0400 whenever chattr +i failed (no CAP_LINUX_IMMUTABLE, e.g. containers and rootless installs), which is the common case. protectedTargets() includes the guard binary, so every such install silently produced a non-executable guard. The launcher found the file but could not exec it, and the guard fail-closed on every tool call. Use 0500 instead, matching the windows branch, which already grants RX, and protectpaths.go's LockPath, which uses 0500 on directories for the same reason. Write access is what self-protection needs to deny, not execute. Signed-off-by: codeyevsky <cinaryildirim2006@outlook.com>
|
qarademir
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Self-protection locked the guard binary down to 0400 on Linux whenever chattr +i failed, which is the common case in containers and rootless installs. That strips the execute bit, so the launcher finds the binary but cannot exec it, and the guard fail-closes on every tool call until someone manually chmods it back.
Root cause
protectedTargets() (packages/core/install/paths.go) includes the guard binary path alongside config/settings files. lockFile() (packages/core/config/protect.go) runs chattr +i first, then unconditionally chmods to 0400 regardless of whether chattr succeeded. When chattr fails, that chmod is the one that actually applies, and it removes execute along with write.
Fix
Chmod to 0500 instead of 0400. This matches the windows branch of the same function, which already grants RX, and protectpaths.go's LockPath, which already uses 0500 on directories for exactly this reason. Write access is what self-protection needs to deny, not execute.
Test plan