git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: FORCE_DIR_SET_GID denied inside nix's build sandbox

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 25, 2022, 16:54 UTC
Message-ID
<xmqq7d0nonbw.fsf@gitster.g>
In-Reply-To
<20221025163024.uutqv7w24yi4eo5i@sourcephile.fr>
Julien Moutinho <julm+git@sourcephile.fr> writes:
Show 8 quoted lines
> While running public-inbox's tests inside nix's build sandbox
> I've noticed that when core.sharedRepository is set to 0600
> git still tries in adjust_shared_perm()
> to set the g+s bit on directories.
> https://github.com/git/git/blob/1fc3c0ad407008c2f71dd9ae1241d8b75f8ef886/path.c#L901-L905
> ...
> So, on meta@public-inbox.org we were wondering whether
> git should maybe strip S_ISGID and retry to chmod() if it hits EPERM?

But that can leave the repository unusable when the files and directories has to be owned by the same group as its containing directory.

It does sound like we are bit too aggressive when setting the g+s bit.

Is g+s only necessary if the directory is group writable? Not necessarily. When I am the only writer (and owner) with memberships in multiple groups, a shared repository that I intend to give read (but not write) permission bit to members of a specific group must be owned by that group, and setting g+s is how we ensure it. So it is insufficient to give when new_mode says it is group writable. We also should do g+s if it is readable by the group.

But if you use 0600, then the group ownership should not matter, so
    /* Copy read bits to execute bits */
    new_mode |= (new_mode & 0444) >> 2;
    if (new_mode & 060)
	new_mode |= FORCE_DIR_SET_GID;
might be what you want?
Previous: Julien MoutinhoNext: Julien Moutinho
Message 2 of 3 in “FORCE_DIR_SET_GID denied inside nix's build sandbox”
  1. Julien MoutinhoOct 25, 2022
  2. Junio C HamanoOct 25, 2022
  3. Julien MoutinhoOct 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.