init: check for filesystem where write bit cannot be removed

This fixes a reversion caused by a99a84f342,
when git-annex init is run as root on a FAT filesystem mounted with
hdiutil on OSX. Such a mount point has file mode 777 for everything and
it cannot be changed. The existing crippled filesystem test tried to
write to a file after removing write bit, but that test does not run as
root (since root can write to unwritable files). So added a check of the
write permissions of the file, after attempting to remove them.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2021-09-01 10:27:28 -04:00
parent 9a0eab9b0e
commit 6329997ac4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 65 additions and 21 deletions

View file

@ -38,3 +38,6 @@ Both look like
[[!meta author=yoh]]
[[!tag projects/datalad]]
> [[fixed|done]] (provisionally; can't test running git-annex as root on
> OSX) --[[Joey]]

View file

@ -0,0 +1,34 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2021-09-01T13:48:57Z"
content="""
Seems that mounting that way on OSX results in a FS where files are always mode
777 and the permissions cannot be changed.
When I tried using git-annex on such a FS, I saw:
datalads-imac:x joey$ git annex init
init
Detected a filesystem without fifo support.
Disabling ssh connection caching.
Filesystem allows writing to files whose write bit is not set.
Detected a crippled filesystem.
And it skips the new permissions check when on a crippled filesystem.
But in that that test run, it seems it is failing to detect a crippled
filesystem. Both because of the failure and also the test suite does
not even run the "v8 unlocked" tests when it detects a crippled filesystem.
Is the test suite running as root? Looks like probably yes. Running as
root prevents detecting the issue that made it use a crippled FS above. And it
seems that, when a FAT fs is mounted on OSX that way, symlinks actually work
(!!!) so the other crippled FS tests also don't notice a problem.
So, the fix should be for init to also test if it can remove the write
bits from a file, and it should try that test even when root.
"""]]