Skip to content

Added permission tests for "other" access - #214

Merged
bizurkur merged 3 commits into
bovigo:masterfrom
bizurkur:add-permission-test
Feb 20, 2020
Merged

bizurkur merged 3 commits into
bovigo:masterfrom
bizurkur:add-permission-test

Conversation

@bizurkur

Copy link
Copy Markdown
Contributor

Issue #167 noted a permission difference. The issue seems to have gone away and is working as expected. Adding tests to prevent regression.

Closes #167

@bizurkur
bizurkur requested a review from a team February 18, 2020 13:20

@mikey179 mikey179 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

- After some manual testing on real files, it doesn't seem like Windows honors the group/other permissions.
- Could only get is_readable to fail by manually opening file properties, going to Security tab, and editing the permissions for the user.
@bizurkur

Copy link
Copy Markdown
Contributor Author

OK, I noticed the build was failing only for Windows so I loaded up a Windows VM and got git and everything else installed in there and did some testing in the Windows environment.

I tested against this branch and the 1.6.5 release with just the basic test outlined in #167. In both cases, the is_readable check failed (it always saw the file as readable). Even using a real file it saw it as readable. Windows does not seem to honor the group/other permissions as expected. I could only get the is_readable check to fail by going to the file Properties, Security tab, and manually setting the Read permission to Deny.

On all *nix systems, everything seems to work as expected.

@allejo

allejo commented Feb 19, 2020 •

Copy link
Copy Markdown
Member

In both cases, the is_readable check failed (it always saw the file as readable). Even using a real file it saw it as readable.

If this happens with a real file, does that mean this is a PHP bug on Windows or am I misunderstanding things? Or does PHP not handle file permissions on Windows the same way as *nix? I'm not familiar with the Windows filesystem so do we need to handle the group permissions differently?

@mikey179

Copy link
Copy Markdown
Member

I tested against this branch and the 1.6.5 release with just the basic test outlined in #167. In both cases, the is_readable check failed (it always saw the file as readable). Even using a real file it saw it as readable. Windows does not seem to honor the group/other permissions as expected.

Have you tested if vfsStream is called at all? I have the suspicion that PHP on Windows might short circuit here and not even call the stream wrapper. If that's the case it should be added to the list of known issues.

@bizurkur

Copy link
Copy Markdown
Contributor Author

It does goes through the vfsStream::url_stat() as expected for the is_readable() call. The permissions ("mode") in the stat matched the same as my test on Mac. Everything looked correct to me... except it never honored the group/other permissions. If owner had read, php always returned is_readable as true even when the "owner" was different.

I'm more curious if this is because Windows doesn't use the UID/GID like *nix does. Windows always sets those values to 0. The stream wrapper does correctly fake those values to 1 in the chown/chgrp calls in the test, but maybe something at php level ignores it when the OS is Windows?

I also thought it might be an issue with clearstatcache() needing to be called, but that didn't seem to be the case.

I'm honestly not sure if it's a possible bug or if it's just because Windows does permissions differently. My real file test I don't think was sufficient enough to call anything a bug, as I don't know of a good way to do a real chown on Windows. Most of my testing was through the stream wrapper. I can't rule out that it's a bug at the stream wrapper level, though.

We could definitely add it as a known issue if that's the way we want to go. I poked at this for hours last night and couldn't get anything to work.

The only good thing that came out of it is that I couldn't prove a difference between 1.6.5 (and 1.6.8) and 2.x, like the issue suggested was the case. On Windows, both branches failed on the same is_readable test and passed on everything else. Behavior seems to have stayed the same, so the issue can be closed.

@mikey179

Copy link
Copy Markdown
Member

Thanks for trying to find out what's happening! I guess it needs someone who wants to dig into the PHP source itself to understand and find out what's going on. For the time being my suggestion would be to merge the PR as is, and to add it as a known issue.

@bizurkur

Copy link
Copy Markdown
Contributor Author

Updated known issues list

@bizurkur bizurkur closed this Feb 19, 2020
@bizurkur
bizurkur deleted the add-permission-test branch February 20, 2020 00:52
@bizurkur
bizurkur restored the add-permission-test branch February 20, 2020 00:56
@bizurkur bizurkur reopened this Feb 20, 2020
@bizurkur
bizurkur merged commit e9bd1db into bovigo:master Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Different behaviour for is_readable() between 1.6.5 and 2.0.0-dev

3 participants