All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix git init --shared=all on FreeBSD 4.11
Date: Mon, 03 Mar 2008 16:31:12 -0800	[thread overview]
Message-ID: <7v1w6rfhyn.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080303234406.GA28158@steel.home> (Alex Riesen's message of "Tue, 4 Mar 2008 00:44:06 +0100")

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.

> 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).

	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"?

For regular files, I do not think we have any reason to set u+s or g+s
ourselves, and we do not try to do so either.  As long as the original
st.st_mode does not have such bits set, the mode we will pass to chmod for
regular would not try to set them.  If you already had u+s,g+s when you
read st.st_mode that's a different story, but then I do not know why you
had such a file to begin with.

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.

  reply	other threads:[~2008-03-04  0:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-03 23:44 [PATCH] Fix git init --shared=all on FreeBSD 4.11 Alex Riesen
2008-03-04  0:31 ` Junio C Hamano [this message]
2008-03-04  7:25   ` Alex Riesen
2008-03-04  8:08     ` Junio C Hamano
2008-03-04 20:20       ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Alex Riesen
2008-03-04 20:44         ` Junio C Hamano
2008-03-04 21:46           ` Alex Riesen
2008-03-04 23:15           ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD Alex Riesen
2008-03-04 20:50         ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Johannes Schindelin
2008-03-04 21:46           ` Alex Riesen

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=7v1w6rfhyn.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=raa.lkml@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.