git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bsd group semantics
@ 2009-03-31 11:26 Jeff King
  2009-03-31 15:55 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2009-03-31 11:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, git

The recently added test t1301.17 is failing for me on FreeBSD; the
created directories don't have the GID bit set.

I traced this back to the fact that FORCE_DIR_SET_GID is a no-op on
FreeBSD due to the DIR_HAS_BSD_GROUP_SEMANTICS flag being set. I am not
sure I understand the original reasoning for this flag at all; GID seems
to work just fine on my FreeBSD 6.1 test system.

The original thread is here:

  http://article.gmane.org/gmane.comp.version-control.git/75999

It looks like Alex was having the problem on FreeBSD 4. I'm not sure if
this flag can go away with the new set_shared_perm, or if I need to just
enable on FreeBSD <= 4.

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 11:26 bsd group semantics Jeff King
@ 2009-03-31 15:55 ` Junio C Hamano
  2009-03-31 16:08   ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2009-03-31 15:55 UTC (permalink / raw)
  To: Jeff King; +Cc: Alex Riesen, git

Jeff King <peff@peff.net> writes:

> The recently added test t1301.17 is failing for me on FreeBSD; the
> created directories don't have the GID bit set.
>
> I traced this back to the fact that FORCE_DIR_SET_GID is a no-op on
> FreeBSD due to the DIR_HAS_BSD_GROUP_SEMANTICS flag being set. I am not
> sure I understand the original reasoning for this flag at all; GID seems
> to work just fine on my FreeBSD 6.1 test system.

IIRC, DIR_HAS_BSD_GROUP_SEMANTICS means you do not have to ask explicitly
with g+s to the filesystem to use the "subdirectory is owned by the same
group as its parent" semantics.  On SysV you have to ask; on BSD you do
not have to (and do not need FORCE_DIR_SET_GID).

> The original thread is here:
>
>   http://article.gmane.org/gmane.comp.version-control.git/75999

That one was not about "you do not have to ask", but "you are not allowed
to ask because the request will fail".  Perhaps between FBSD4 and FBSD6
things changed, and you can now make g+s request (which I presume is still
a no-op other than setting the bit on)?

Ideally the test should be checking if the subdirectory is owned by the
same group as the toplevel, but that is rather hard to correctly arrange,
as it depends on the set of groups the user who runs the test belongs to,
how the git work tree is set up (if it is owned by his primary group or a
secondary), etc.

For now, I'd suggest teaching the test not to care about g+s bit.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 15:55 ` Junio C Hamano
@ 2009-03-31 16:08   ` Jeff King
  2009-03-31 17:32     ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2009-03-31 16:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, git

On Tue, Mar 31, 2009 at 08:55:00AM -0700, Junio C Hamano wrote:

> IIRC, DIR_HAS_BSD_GROUP_SEMANTICS means you do not have to ask explicitly
> with g+s to the filesystem to use the "subdirectory is owned by the same
> group as its parent" semantics.  On SysV you have to ask; on BSD you do
> not have to (and do not need FORCE_DIR_SET_GID).

OK, I see. Thanks for the explanation. So the test is wrong, since it
explicitly checks for g+s, and we only need it sometimes.

> That one was not about "you do not have to ask", but "you are not allowed
> to ask because the request will fail".  Perhaps between FBSD4 and FBSD6
> things changed, and you can now make g+s request (which I presume is still
> a no-op other than setting the bit on)?

Yes, you can ask just fine now:

  $ uname -sr
  FreeBSD 6.1-RELEASE-p17-jc1
  $ mkdir foo
  $ ls -ld foo
  drwxr-xr-x  2 peff  peff  512 Mar 31 09:04 foo/
  $ chmod g+s foo
  $ ls -ld foo
  drwxr-sr-x  2 peff  peff  512 Mar 31 09:04 foo/

But it isn't necessary.

> Ideally the test should be checking if the subdirectory is owned by the
> same group as the toplevel, but that is rather hard to correctly arrange,
> as it depends on the set of groups the user who runs the test belongs to,
> how the git work tree is set up (if it is owned by his primary group or a
> secondary), etc.

Shouldn't that just be:

  perl -e 'sub group { return (stat(shift))[5] }' \
       -e 'exit group($ARGV[0]) == group($ARGV[1]) ? 0 : 1' \
       a b

?

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 16:08   ` Jeff King
@ 2009-03-31 17:32     ` Junio C Hamano
  2009-03-31 18:46       ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2009-03-31 17:32 UTC (permalink / raw)
  To: Jeff King; +Cc: Alex Riesen, git

Jeff King <peff@peff.net> writes:

> On Tue, Mar 31, 2009 at 08:55:00AM -0700, Junio C Hamano wrote:
> ...
>> Ideally the test should be checking if the subdirectory is owned by the
>> same group as the toplevel, but that is rather hard to correctly arrange,
>> as it depends on the set of groups the user who runs the test belongs to,
>> how the git work tree is set up (if it is owned by his primary group or a
>> secondary), etc.
>
> Shouldn't that just be:
>
>   perl -e 'sub group { return (stat(shift))[5] }' \
>        -e 'exit group($ARGV[0]) == group($ARGV[1]) ? 0 : 1' \
>        a b
>
> ?

My point was if I belong only to my personal group and git.git work tree
is owned by junio.junio to begin with, you would never be able to notice
any breakage with such a test.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 17:32     ` Junio C Hamano
@ 2009-03-31 18:46       ` Jeff King
  2009-03-31 20:26         ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2009-03-31 18:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, git

On Tue, Mar 31, 2009 at 10:32:14AM -0700, Junio C Hamano wrote:

> My point was if I belong only to my personal group and git.git work tree
> is owned by junio.junio to begin with, you would never be able to notice
> any breakage with such a test.

Ah, I see. Yes, you would need to belong to at least two groups to make
such a test feasible.

Such a requirement is generally outside the scope of running the
test suite; do you want to just ditch the g+s test, then, or do you want
me to work up something conditional based on the Makefile flag?

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 18:46       ` Jeff King
@ 2009-03-31 20:26         ` Junio C Hamano
  2009-03-31 20:36           ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2009-03-31 20:26 UTC (permalink / raw)
  To: Jeff King; +Cc: Alex Riesen, git

Jeff King <peff@peff.net> writes:

> On Tue, Mar 31, 2009 at 10:32:14AM -0700, Junio C Hamano wrote:
>
>> My point was if I belong only to my personal group and git.git work tree
>> is owned by junio.junio to begin with, you would never be able to notice
>> any breakage with such a test.
>
> Ah, I see. Yes, you would need to belong to at least two groups to make
> such a test feasible.
>
> Such a requirement is generally outside the scope of running the
> test suite; do you want to just ditch the g+s test, then, or do you want
> me to work up something conditional based on the Makefile flag?

For now, I'd suggest teaching the test not to care about g+s bit.
After all, they are about giving correct mode bits to files and
directories.  Correct mode bits for group do not mean anything if you make
them owned by a wrong group, but that is not something we have tested so
far, and can be a separate test anyway.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 20:26         ` Junio C Hamano
@ 2009-03-31 20:36           ` Jeff King
  2009-03-31 21:33             ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2009-03-31 20:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, git

On Tue, Mar 31, 2009 at 01:26:01PM -0700, Junio C Hamano wrote:

> For now, I'd suggest teaching the test not to care about g+s bit.
> After all, they are about giving correct mode bits to files and
> directories.  Correct mode bits for group do not mean anything if you make
> them owned by a wrong group, but that is not something we have tested so
> far, and can be a separate test anyway.

Makes sense. How about this?

-- >8 --
Subject: [PATCH] t1301: loosen test for forced modes

One of the aspects of the test checked explicitly for the
g+s bit to be set on created directories. However, this is
only the means to an end (the "end" being having the correct
group set). And in fact, on systems where
DIR_HAS_BSD_GROUP_SEMANTICS is set, we do not even need to
use this "means" at all, causing the test to fail.

This patch removes that part of the test. In an ideal world
it would be replaced by a test to check that the group was
properly assigned, but that is difficult to automate because
it requires the user running the test suite be a member of
multiple groups.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t1301-shared-repo.sh |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
index 11ef302..9b18507 100755
--- a/t/t1301-shared-repo.sh
+++ b/t/t1301-shared-repo.sh
@@ -147,9 +147,6 @@ test_expect_success 'forced modes' '
 	# Everything must be unaccessible to others
 	test -z "$(sed -n -e "/^.......---/d" actual)" &&
 
-	# All directories must have 2770
-	test -z "$(sed -n -e "/^drwxrws---/d" -e "/^d/p" actual)" &&
-
 	# post-update hook must be 0770
 	test -z "$(sed -n -e "/post-update/{
 		/^-rwxrwx---/d
-- 
1.6.2.1.591.geb450

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 20:36           ` Jeff King
@ 2009-03-31 21:33             ` Junio C Hamano
  2009-03-31 22:25               ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2009-03-31 21:33 UTC (permalink / raw)
  To: Jeff King; +Cc: Alex Riesen, git

Jeff King <peff@peff.net> writes:

> On Tue, Mar 31, 2009 at 01:26:01PM -0700, Junio C Hamano wrote:
>
>> For now, I'd suggest teaching the test not to care about g+s bit.
>> After all, they are about giving correct mode bits to files and
>> directories.  Correct mode bits for group do not mean anything if you make
>> them owned by a wrong group, but that is not something we have tested so
>> far, and can be a separate test anyway.
>
> Makes sense. How about this?
>
> -- >8 --
> Subject: [PATCH] t1301: loosen test for forced modes
>
> One of the aspects of the test checked explicitly for the
> g+s bit to be set on created directories. However, this is
> only the means to an end (the "end" being having the correct
> group set). And in fact, on systems where
> DIR_HAS_BSD_GROUP_SEMANTICS is set, we do not even need to
> use this "means" at all, causing the test to fail.
>
> This patch removes that part of the test. In an ideal world
> it would be replaced by a test to check that the group was
> properly assigned, but that is difficult to automate because
> it requires the user running the test suite be a member of
> multiple groups.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/t1301-shared-repo.sh |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
>
> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
> index 11ef302..9b18507 100755
> --- a/t/t1301-shared-repo.sh
> +++ b/t/t1301-shared-repo.sh
> @@ -147,9 +147,6 @@ test_expect_success 'forced modes' '
>  	# Everything must be unaccessible to others
>  	test -z "$(sed -n -e "/^.......---/d" actual)" &&
>  
> -	# All directories must have 2770
> -	test -z "$(sed -n -e "/^drwxrws---/d" -e "/^d/p" actual)" &&

Did you mean 

-	# All directories must have 2770
-	test -z "$(sed -n -e "/^drwxrws---/d" -e "/^d/p" actual)" &&
+	# All directories must have either 2770 or 770
+	test -z "$(sed -n -e "/^drwxrw[sx]---/d" -e "/^d/p" actual)" &&


> -
>  	# post-update hook must be 0770
>  	test -z "$(sed -n -e "/post-update/{
>  		/^-rwxrwx---/d
> -- 
> 1.6.2.1.591.geb450

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: bsd group semantics
  2009-03-31 21:33             ` Junio C Hamano
@ 2009-03-31 22:25               ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2009-03-31 22:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, git

On Tue, Mar 31, 2009 at 02:33:26PM -0700, Junio C Hamano wrote:

> > -	# All directories must have 2770
> > -	test -z "$(sed -n -e "/^drwxrws---/d" -e "/^d/p" actual)" &&
> 
> Did you mean 
> 
> -	# All directories must have 2770
> -	test -z "$(sed -n -e "/^drwxrws---/d" -e "/^d/p" actual)" &&
> +	# All directories must have either 2770 or 770
> +	test -z "$(sed -n -e "/^drwxrw[sx]---/d" -e "/^d/p" actual)" &&

No, I meant what I said, but I was wrong. ;) I was thinking that bit
only tested for one thing, but it was actually testing for two. Sorry.

Can you fix it up when you apply, then?

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-03-31 22:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-31 11:26 bsd group semantics Jeff King
2009-03-31 15:55 ` Junio C Hamano
2009-03-31 16:08   ` Jeff King
2009-03-31 17:32     ` Junio C Hamano
2009-03-31 18:46       ` Jeff King
2009-03-31 20:26         ` Junio C Hamano
2009-03-31 20:36           ` Jeff King
2009-03-31 21:33             ` Junio C Hamano
2009-03-31 22:25               ` Jeff King

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