fix: set ownership to mock user on file/dir creation#367
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: set ownership to mock user on file/dir creation#367toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
When set_user() is active, newly created files, directories, and symlinks now get uid/gid from the mock user identity instead of keeping the real process uid/gid. This matches POSIX behavior where open(O_CREAT), mkdir(2), and symlink(2) set ownership to the effective uid/gid. Affected operations: open (write-create), sysopen (O_CREAT), mkdir, symlink. Existing files opened for read/write are not affected. 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
Newly created files, directories, and symlinks now inherit uid/gid from the mock user when
set_user()is active.Why
POSIX mandates that
open(O_CREAT),mkdir(2), andsymlink(2)set the new object's ownership to the effective uid/gid. Previously, mock objects retained the real process uid/gid regardless of the mock user identity, making permission-sensitive tests unreliable.How
Added
_apply_ownership($mock)helper that sets uid/gid from$_mock_uid/@_mock_gidswhen a mock user is active (no-op otherwise). Called at file creation points in__open,__sysopen(O_CREAT),__mkdir, and__symlink. Opening or truncating existing files is unaffected.Testing
New test file
t/ownership_on_create.tcovers:open(">")/open(">>")creating filessysopen(O_CREAT)creating filesmkdir()creating directoriessymlink()creating symlinksset_user()is not activeFull suite passes (1594 tests, only pre-existing
fh-ref-leak.tfailure on this Perl).🤖 Generated with Claude Code