feat: add permission checking via set_user/clear_user#281
Merged
toddr merged 2 commits intocpanel:masterfrom Mar 20, 2026
Merged
feat: add permission checking via set_user/clear_user#281toddr merged 2 commits intocpanel:masterfrom
toddr merged 2 commits intocpanel:masterfrom
Conversation
Member
|
@Koan-Bot rebase |
de522ec to
7c69fc0
Compare
Koan-Bot
added a commit
to atoomic/Test-MockFile
that referenced
this pull request
Mar 19, 2026
Contributor
Author
Rebase: feat: add permission checking via set_user/clear_userBranch Diff: 33 files changed, 752 insertions(+), 3373 deletions(-) Review feedback was analyzed and applied. Actions
CICI still failing after 2 fix attempts. Last failure logsAutomated by Kōan |
Member
|
@Koan-Bot rebase |
When Test::MockFile->set_user($uid, @Gids) is called, all mocked file operations check Unix permission bits (owner/group/other) against the mock identity. This is opt-in and backward compatible — without set_user(), no permission checks occur. Checks added to: open, sysopen, opendir, unlink, mkdir, rmdir, chmod, chown. Parent directory write+execute checks for directory-modifying ops and file creation. Root (uid 0) bypasses read/write checks; execute still requires at least one x bit set on the file. Closes cpanel#3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51ae08e to
256d3bc
Compare
Contributor
Author
Rebase: feat: add permission checking via set_user/clear_userBranch Diff: 3 files changed, 557 insertions(+), 8 deletions(-) Review feedback was analyzed and applied. Actions
CICI passed. Automated by Kōan |
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
set_user($uid, @gids)/clear_user()Why
Without permission checks, Test::MockFile always allows all operations regardless of file mode bits. This makes it impossible to test code that depends on permission-based behavior (e.g., read-only files, restricted directories, privilege checks).
How
_check_perms($mock, $access)checks permission bits using the standard Unix model (owner/group/other triads)_check_parent_perms($path, $access)checks parent directory permissions for ops that modify directory contentsopen,sysopen,opendir,unlink,mkdir,rmdir,chmod,chownchownuses mock identity instead of$>/$)when set_user is activeset_user(), no checks occurTesting
t/perms.tcovering: basic set/clear lifecycle, owner/group/other read/write, root bypass, sysopen, opendir, parent dir checks (unlink/mkdir/rmdir), chmod ownership, chown identity, non-existent files, multiple groups, file creation parent checksCloses #3
🤖 Generated with Claude Code