Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ func ParseWithUmask(s string, umask uint) (Set, error) {
case 'w':
perm |= iWUser | iWGroup | iWOther
case 'X':
if op == '+' {
if op != '-' {
permX = iXUser | iXGroup | iXOther
} else {
perm |= iXUser | iXGroup | iXOther
}
case 'x':
perm |= iXUser | iXGroup | iXOther
Expand Down
17 changes: 13 additions & 4 deletions mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func TestApply(t *testing.T) {
{0777, 0333, 0000, "-r"},
{0777, 0555, 0000, "-w"},
{0777, 0666, 0000, "-x"},
{0777, 0777, 0000, "-X"},
{os.ModeDir | 0777, os.ModeDir | 0777, 0000, "-X"},
{0777, 0666, 0000, "-X"},
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear if these -X cases were intentional but I've tested new expected values against Linux.

Copy link

Copilot AI Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected permission value for the "-X" test case was changed from 0777 to 0666; please confirm that this update accurately reflects the intended Linux/POSIX behavior.

Suggested change
{0777, 0666, 0000, "-X"},
{0666, 0666, 0000, "-X"},

Copilot uses AI. Check for mistakes.
{os.ModeDir | 0777, os.ModeDir | 0666, 0000, "-X"},
{os.ModeSetuid | os.ModeSetgid | 0777, 0777, 0000, "-s"},
{0777, 0337, 0037, "-r"},
{0777, 0557, 0057, "-w"},
Expand All @@ -129,8 +129,8 @@ func TestApply(t *testing.T) {
{0777, 0377, 0000, "u-r"},
{0777, 0577, 0000, "u-w"},
{0777, 0677, 0000, "u-x"},
{0777, 0777, 0000, "u-X"},
{os.ModeDir | 0777, os.ModeDir | 0777, 0000, "u-X"},
{0777, 0677, 0000, "u-X"},
{os.ModeDir | 0777, os.ModeDir | 0677, 0000, "u-X"},
{os.ModeSetuid | 0777, 0777, 0000, "u-s"},

{0000, 0600, 0000, "u=rw"},
Expand Down Expand Up @@ -179,6 +179,15 @@ func TestApply(t *testing.T) {
{0670, 0644, 0000, "go=u-w"},
{0570, 0555, 0000, "go=u-w"},
{0370, 0311, 0000, "go=u-w"},

// Linux compatible X
{0444, 0644, 0000, "u=rwX,go=rX"},
{os.ModeDir | 0442, os.ModeDir | 0755, 0000, "u=rwX,go=rX"},
{0641, 0755, 0000, "u=rwX,go=rX"},
{0777, 0766, 0000, "go-X"},
{0424, 0000, 0000, "=X"},
{0421, 0111, 0000, "=X"},
{0421, 0555, 0000, "=rX"},
}
var lastSet Set
var lastStr string
Expand Down