fix: add parent-dir permission checks to symlink() and link()#341
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: add parent-dir permission checks to symlink() and link()#341toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
Both symlink() and link() were missing write+execute permission checks on the parent directory of the destination, unlike mkdir/rmdir/unlink/rename which all enforce this. With set_user() active, these operations would succeed in restricted directories where they should return EACCES. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Add missing parent-directory permission checks to
symlink()andlink().Why
With
set_user()active,symlink()andlink()would succeed in restricted directories (e.g., mode 0555) where they should return EACCES. Every other directory-modifying operation —mkdir,rmdir,unlink,rename— already checks write+execute permission on the parent directory. This gap meant permission-checking tests could pass incorrectly when using symlinks or hard links.How
Added
_check_parent_perms($path, 2|1)calls to both__symlinkand__link, following the same pattern used by__mkdir,__rmdir, and__unlink.Testing
t/perms.t: verify both operations fail with EACCES on read-only parent dir and succeed on writable parent dirfh-ref-leak.tfailure)🤖 Generated with Claude Code