Skip to content
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

Offer more details to users about the ownership check on FAT32 #3887

Merged
merged 2 commits into from
Jun 23, 2022

Conversation

dscho
Copy link
Member

@dscho dscho commented Jun 8, 2022

Since FAT cannot store ownership information, users cannot do anything about "unsafe ownership" there. Except exempt the directory via the safe.directory mechanism. Inform the users about this (rather than the bogus "World owns this" message).

Since we cannot know at the time the ownership check is performed whether Git will require a valid repository or not, we keep mum in the general case, and only say something if the GIT_TEST_DEBUG_UNSAFE_DIRECTORIES knob is on.

Speaking of that knob, we now hint to the users that they can use this knob to find out more, in case that the ownership fails (and Git absolutely requires a valid repository).

This addresses #3886

@dscho dscho self-assigned this Jun 8, 2022
@dscho dscho force-pushed the skip-ownership-test-on-fat branch from 543f9dc to a6d7d31 Compare June 8, 2022 10:02
@rimrul
Copy link
Member

rimrul commented Jun 8, 2022

This feels like reintroducing the vulnerability that the whole ownership check is supposed to fix.

Are you sure this shouldn't at least produce a big warning?

@dscho
Copy link
Member Author

dscho commented Jun 8, 2022

Hmm. You're right: just because the user can't fix the issue doesn't mean that they're not vulnerable.

Let me mull this over for a bit.

@dscho dscho force-pushed the skip-ownership-test-on-fat branch from a6d7d31 to c246ed6 Compare June 21, 2022 21:13
@dscho
Copy link
Member Author

dscho commented Jun 21, 2022

Let me mull this over for a bit.

So I mulled over this and agree with @rimrul that we cannot relax the ownership check. If the user runs Git on a file system that does not record ownership information, the safest option is to require an explicit exception (via that safe.directory config setting). We can be more helpful, though, and this is what this PR now does.

@dscho dscho changed the title Skip the ownership check on FAT32 Offer more details to users about the ownership check on FAT32 Jun 21, 2022
Let's also hint to the user in the error message that they can debug
this further.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the skip-ownership-test-on-fat branch from c246ed6 to 815a1bc Compare June 21, 2022 21:59
@dscho dscho requested a review from derrickstolee June 22, 2022 09:12
compat/mingw.c Outdated
/*
* On FAT32 volumes, ownership is not actually recorded.
*/
warning("'%s' is on a file system that cannot represent ownership", path);
Copy link
Member Author

Choose a reason for hiding this comment

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

@derrickstolee do you think "that does not record ownership" would be more accurate/elegant?

Choose a reason for hiding this comment

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

I agree that "does not record" is the most accurate. I read "cannot represent" as "cannot tell me" which is different than "doesn't even keep track of".

Copy link

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

Do we have any CI that tests FAT32? How did you validate this on that platform?

The FAT file system has no concept of ACLs. Therefore, it cannot store
any ownership information anyway, and the `GetNamedSecurityInfoW()` call
pretends that everything is owned "by the world".

Let's special-case that scenario and tell the user what's going on, at
least when they set `GIT_TEST_DEBUG_UNSAFE_DIRECTORIES`.

This addresses git-for-windows#3886

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the skip-ownership-test-on-fat branch from 815a1bc to 75f23a9 Compare June 23, 2022 18:36
@dscho dscho merged commit 45a475a into git-for-windows:main Jun 23, 2022
@dscho dscho deleted the skip-ownership-test-on-fat branch June 23, 2022 19:15
@dscho dscho added this to the Next release milestone Jun 23, 2022
dscho added a commit to git-for-windows/build-extra that referenced this pull request Jun 23, 2022
When Git indicates an unsafe directory due to the file system
(e.g. FAT32) being unable to record ownership, Git [now gives better
hints](git-for-windows/git#3887).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this pull request Jun 24, 2022
Offer more details to users about the ownership check on FAT32
dscho added a commit that referenced this pull request Jun 25, 2022
Offer more details to users about the ownership check on FAT32
dscho added a commit that referenced this pull request Jun 25, 2022
Offer more details to users about the ownership check on FAT32
dscho added a commit that referenced this pull request Jun 25, 2022
Offer more details to users about the ownership check on FAT32
@dscho
Copy link
Member Author

dscho commented Jun 27, 2022

Do we have any CI that tests FAT32?

We don't.

How did you validate this on that platform?

I simulated it, but @clzls confirmed that it works.

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.

3 participants