This is an archive of the discontinued LLVM Phabricator instance.

[Clang] In tests, do not always assume others permissions are set
ClosedPublic

Authored by aganea on Nov 29 2019, 6:31 AM.

Details

Summary

On my Linux Ubuntu 18.04, because of default ACL settings, permissions for "others" are always unset/empty. The tests below used to fail without this patch.

Diff Detail

Event Timeline

aganea created this revision.Nov 29 2019, 6:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2019, 6:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aganea retitled this revision from [Clang] Do not always assume others permissions are set to [Clang] In tests, do not always assume others permissions are set.Nov 29 2019, 6:32 AM
rnk added inline comments.Dec 2 2019, 1:55 PM
clang/test/Misc/permissions.cpp
0

If you change this to umask 022, does that result in rw-r-----? That would make the test meaningful on your system.

aganea marked 3 inline comments as done.Dec 3 2019, 2:53 PM
aganea added inline comments.
clang/test/Misc/permissions.cpp
0

No, using umask 022 has no effect, still yields 'rw':

$ umask
0000
$ umask 0077
$ touch test
$ ls -l
-rw-rw---- 1 aganea sudosgroup    0 Dec  3 11:02 test

So this seems to be related to the interaction between ACL and umask. The umask doc says they should interact, but that doesn't seem to work on my Ubuntu 18.04.01. No matter what I set in the umask mode, creating a new file inherits the default ACL.
All my folders have ACL enabled:

$ ls -l /mnt/
drwxrws--x+ 8 root sudosgroup 4096 Dec  3 17:07 f       <-- note the + which indicates ACL is being used

I could give 'rw' permissions to others:

$ setfacl -R -d -m o::rw /mnt/f

However even with that, the test fails (because umask has no effect).
I'm not sure what the right fix would be here. I can investigate other things. Any suggestions?

rnk accepted this revision.Dec 3 2019, 2:58 PM

lgtm

clang/test/Misc/permissions.cpp
0

I'm not sure what the right fix would be here. I can investigate other things. Any suggestions?

I don't think it's worth it. Let's go with your fix and make the test pass.

This revision is now accepted and ready to land.Dec 3 2019, 2:58 PM
aganea marked 3 inline comments as done.Dec 3 2019, 3:07 PM
aganea added inline comments.
clang/test/Misc/permissions.cpp
0

Good. I'll add a comment above in the test to explain the situation.

aganea updated this revision to Diff 232100.Dec 4 2019, 5:55 AM
aganea marked an inline comment as done.
aganea added subscribers: tstellar, Meinersbur.

Just after I hit Submit last night, I found a better way, by disabling ACL for that folder.
Ping @tstellar @Meinersbur in case they have an opinion.
Please let me know which solution you think is better.

aganea updated this revision to Diff 233402.Dec 11 2019, 10:11 AM

Ensure the access-rights commands (setfacl and chmod) won't fail the tests if the user doesn't have the appropriate rights to change permissions.
Added llvm/test/Other/umask.ll because it was also failing.

Herald added a project: Restricted Project. · View Herald TranscriptDec 11 2019, 10:11 AM
aganea requested review of this revision.Dec 11 2019, 10:11 AM
aganea edited the summary of this revision. (Show Details)
rnk added a comment.Dec 11 2019, 11:22 AM

I see there is no setfacl on Mac. Personally, I feel like this test doesn't have much value. Rafael added it long ago when we changed how we opened files in some way that I guess affected umask. I'm not sure we really need this regression test given how unportable it seems to be.

Yes this was added in rG18627115f4d2db5dc73207e0b5312f52536be7dd and rGe08b59f81d950bd5c8b8528fcb3ac4230c7b736c. It looks like it was only there to validate that specific refactoring.
Should I remove these two files, or simply commit the previous diff? (ie. -rw-rw----)

rnk added a comment.Dec 11 2019, 2:04 PM

I think we should remove it.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 10 2020, 6:09 PM
Closed by commit rGde0a22471157: Remove umask tests (authored by aganea). · Explain Why
This revision was automatically updated to reflect the committed changes.