-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MkdirTask behaves the same as "mkdir" Linux command and respects POSIX ACL #591
Conversation
I might rewrite the test-cases as proper PHPUnit tests if you agree with the changes in the PR. |
I like the idea, but this is indeed a BC break - which makes it a nice candidate for the 3.0 release. So, could you:
Thanks! |
Hi @mrook . I did not have much time to write the tests lately but I would like to finish the PR now. |
@sustmi that would be great, please rebase against |
a6b4356
to
4affafd
Compare
@mrook: I added tests and rebased the PR on |
34f30dc
to
fb3ff04
Compare
Ok, I managed to enable ACL support in |
@siad007 could you review this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we schould add the whole acl stuff to the documentation.
Yeah you're probably right. @sustmi can you make that happen? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had recent activity. Thank you for your contributions. |
I reopen this ticket. Related to #1088 - but we should think of windows support here. |
Sorry for leaving this PR stale. Are you still interested in getting this merged? @siad007 : Do you have any idea what should be documented? Should I add some info to the documentation of MkdirTask or some general documentation of ACL too? |
I updated the |
Well, it looks like Windows may not even support |
Ok, the <?php
function chmodTest($file, $mode) {
chmod($file, $mode);
clearstatcache();
var_dump(sprintf('expected: %03o, actual: %03o', $mode, fileperms($file)));
}
$file = __DIR__ . '/test.txt';
touch($file);
chmodTest($file, 0000);
chmodTest($file, 0777);
chmodTest($file, 0707);
chmodTest($file, 0700);
chmodTest($file, 0070);
chmodTest($file, 0007);
/*
Output on Windows 10, NTFS patition, php-7.3.10-Win32-VC15-x64:
string(29) "expected: 000, actual: 100444"
string(29) "expected: 777, actual: 100666"
string(29) "expected: 707, actual: 100666"
string(29) "expected: 700, actual: 100666"
string(29) "expected: 070, actual: 100444"
string(29) "expected: 007, actual: 100444"
*/ |
I guess all the current tests in |
Hooray! Tests pass both on Linux and Windows. |
Codecov Report
@@ Coverage Diff @@
## master #591 +/- ##
============================================
+ Coverage 52.42% 52.48% +0.05%
- Complexity 9306 9307 +1
============================================
Files 476 476
Lines 22705 22704 -1
============================================
+ Hits 11903 11916 +13
+ Misses 10802 10788 -14
Continue to review full report at Codecov.
|
@sustmi did you find some breaking stuff? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@sustmi finaly merged - thx for your commits and patience 👍 |
Thank you for finishing it. |
This PR makes
MkdirTask
create directories with the same permissions as Linuxmkdir
command. Also, it sets correct permissions when using POSIX Access Control Lists.It is possibly a BC break, but I think that it is worth it as the new behaviour is more intuitive.
Test-cases explaining the old and the new behaviour for ACL:
1. a) Linux shell (ACL enabled):
Notice that umask is completely ignored when ACL is enabled. Directory
dir1
hasrwxrwxr-x
permissions because that is the default setting of the parent directory.1. b) MkdirTask before this PR (ACL enabled):
build.xml:
shell:
Notice that
dir1
has wrong permissions. OldMkdirTask
callsmkdir('dir1', 0700)
because it masks 0777 with the original umask (see the originalMkdirTask::__construct()
).Also, you can see that in this case old
MkdirTask
incorrectly sets ACL mask to---
because ACL mask equals to group permissions when ACL is enabled.1. c) MkdirTask after this PR (ACL enabled):
build.xml:
shell:
You can see that the new
MkdirTask
creates all permissions the same as Linuxmkdir
command.Test-cases explaining the old and the new behaviour when creating parent directories:
2. a) Linux shell (no ACL):
Notice that
dir2
is created with0777
permissions even though umask is set to0077
. That is because umask is ignored when--mode
option is used.Also notice that
dir3
has default permissions and not0777
as specified in--mode
option.2. b) MkdirTask before this PR (no ACL):
build.xml:
shell:
Notice that
dir3
is not created with default permissions but with those specified inmode
attribute which is not the same behaviour as in case of Linuxmkdir
command.2. c) MkdirTask after this PR (no ACL):
build.xml:
shell:
MkdirTask
now behaves the same as Linuxmkdir
command (ie. only last child directory has the permissions specified inmode
attribute).