From: <rsbecker@nexbridge.com>
To: "'Marcos Del Sol Vives'" <marcos@orca.pet>,
"'git'" <git@vger.kernel.org>
Subject: RE: Permission issue in Git in DrvFs-mounted network drives
Date: Wed, 18 Sep 2024 12:30:05 -0400 [thread overview]
Message-ID: <03ed01db09e8$080cf090$1826d1b0$@nexbridge.com> (raw)
In-Reply-To: <19205ebb4b9.c2a2da5a2387912.3559118454287459572@orca.pet>
On September 18, 2024 12:16 PM, Marcos Del Sol Vives wrote:
>Under WSL1 (Windows Subsystem for Linux), when using a network share
>mounted via DrvFs, Git fails to add any files to a new or an existing repository.
>
>The reason is that Git tries to open a temporary file as with RW permissions but
>mode 0444, which causes WSL1 (or Samba, unsure who's here to blame) to create
>first an file empty with the read-only DOS attribute set that prevents any writes,
>and then actually trying to opening it in write mode, which of course fails.
>
>Seems to be a pretty common issue that nobody has yet reported officially, judging
>by the amount of posts on Stackoverflow, impacting not only WSL but also CIFS
>under Linux (hence why sending to this mailing list and not the Windows-specific
>one):
>
> - https://superuser.com/questions/681196/debugging-git-repo-permissions-on-
>samba-share
> - https://superuser.com/questions/1450094/git-on-wsl-commands-fail-despite-
>permissions-seeming-fine
> - https://superuser.com/questions/1491499/use-git-on-a-shared-drive-within-
>wsl
>
>As a workaround, opening the file with permissions 0600 and then using a fchmod
>with the final desired mode works, which is a very small change that should cause
>no issues under neither real Linux nor WSL:
>
>--- git-2.39.5.orig/wrapper.c
>+++ git-2.39.5/wrapper.c
>@@ -484,9 +484,11 @@ int git_mkstemps_mode(char *pattern, int
> v /= num_letters;
> }
>
>- fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
>- if (fd >= 0)
>+ fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, 0600);
>+ if (fd >= 0) {
>+ fchmod(fd, mode);
> return fd;
>+ }
I am not certain this is either necessary or important to platforms other than Windows.
The /tmp directory is often, and properly set with the sticky bit +t. This ensures that only
The creating user has access to the temp file regardless of create ownership or security.
I would prefer that this be put into a compat layer rather than made general change.
> /*
> * Fatal error (EPERM, ENOSPC etc).
> * It doesn't make sense to loop.
>
>The WSL team at Microsoft has been already informed as well:
>https://github.com/microsoft/WSL/issues/12051
next prev parent reply other threads:[~2024-09-18 16:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-18 16:16 Permission issue in Git in DrvFs-mounted network drives Marcos Del Sol Vives
2024-09-18 16:30 ` rsbecker [this message]
2024-09-18 16:38 ` Marcos Del Sol Vives
2024-09-20 15:51 ` brian m. carlson
2024-09-20 18:15 ` Junio C Hamano
2024-09-20 18:36 ` Marcos Del Sol Vives
2024-09-20 20:43 ` brian m. carlson
2024-09-20 22:39 ` Marcos Del Sol Vives
2024-09-21 11:20 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='03ed01db09e8$080cf090$1826d1b0$@nexbridge.com' \
--to=rsbecker@nexbridge.com \
--cc=git@vger.kernel.org \
--cc=marcos@orca.pet \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).