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

Re: [PATCH] Fix git init --shared=all on FreeBSD 4.11

From
Alex Riesen <raa.lkml@gmail.com>
Date
Mar 4, 2008, 07:25 UTC
Message-ID
<20080304072519.GA3070@steel.home>
In-Reply-To
<7v1w6rfhyn.fsf@gitster.siamese.dyndns.org>
Junio C Hamano, Tue, Mar 04, 2008 01:31:12 +0100:
Show 7 quoted lines
> Alex Riesen <raa.lkml@gmail.com> writes:
> 
> > At least FreeBSD 4.11p2 does not allow changing SUID/GUID bits to
> > a non-root user.
> 
> Sorry, but I do not understand this change.
> 

Now that I look at it again, I admint I don't understand what I was thinking either. I see the problem in t1301-shared-repo.sh: it fails to chmod(042775, ".git/refs") with EPERM.

Will re-investigate.
Show 26 quoted lines
> > diff --git a/path.c b/path.c
> > index af27161..4865e98 100644
> > --- a/path.c
> > +++ b/path.c
> > @@ -265,6 +265,7 @@ int adjust_shared_perm(const char *path)
> >  		return 0;
> >  	if (lstat(path, &st) < 0)
> >  		return -1;
> > +	st.st_mode &= 07777 & ~(S_ISUID|S_ISGID);
> >  	mode = st.st_mode;
> 
> If the thing is a directory, we say later in the code that we want to see
> S_ISGID set, like this:
> 
> 	...
> 	if (S_ISDIR(mode))
> 		mode |= S_ISGID;
> 	if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
> 		return -2;
> 	return 0;
> 
> and then we compare with st.st_mode so that we do not chmod() what's
> already good  Your change means we will always try to chmod all the
> directories, and your explanation suggests that such a chmod to do g+s on
> directories would also fail (and your patch does not fix it -- we actively
> try to make sure directories have g+s set).
The change is very bogus. Dunno how it happened...
> 	Side note. the wording in your message, "does not allow changing",
> 	is very unclear.  Do you mean "non-root cannot do u+s,g+s"?  Or do
> 	you mean "non-root cannot do u+s,g+s, non-root cannot do u-s,g-s
> 	either"?

chmod(2), as it was, just fails. It seemed like the ordinary users could not do g+s (which is what the function is actually supposed to do).

> I do not mind a change to make sure we do u-s,g-s on regular files, but I
> do not think it is necessary, and I am curious why you had files with such
> perm bits to begin with.

It is a directory. The bit 02000 is S_ISGID on FreeBSD too. It just does not work (now I am just observing, no coding).

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 10 in “Fix git init --shared=all on FreeBSD 4.11”
  1. Fix git init --shared=all on FreeBSD 4.11Alex Riesen, Mar 3, 2008
  2. Junio C HamanoMar 4, 2008
  3. Alex RiesenMar 4, 2008
  4. Junio C HamanoMar 4, 2008
  5. Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2Alex Riesen, Mar 4, 2008
  6. Junio C HamanoMar 4, 2008
  7. Alex RiesenMar 4, 2008
  8. Do not use GUID on dir in git init --shared=all on FreeBSDAlex Riesen, Mar 4, 2008
  9. Johannes SchindelinMar 4, 2008
  10. Alex RiesenMar 4, 2008

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.