threads / discuss / 18658

bsd group semantics

Subject: bsd group semantics

## tl;dr

9 messages between Mar 31, 2009 and Mar 31, 2009.

replies: 8people: 2as markdown or json

Jeff King· Mar 31, 2009, 11:26 UTC · lore

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
Junio C Hamano· Mar 31, 2009, 15:55 UTC · re: Jeff King · lore

Re: bsd group semantics

Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> 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.
Jeff King· Mar 31, 2009, 16:08 UTC · re: Junio C Hamano · lore

Re: bsd group semantics

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.
Show 5 quoted lines
> 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
Junio C Hamano· Mar 31, 2009, 17:32 UTC · re: Jeff King · lore

Re: bsd group semantics

Jeff King <peff@peff.net> writes:
Show 15 quoted lines
> 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.

Jeff King· Mar 31, 2009, 18:46 UTC · re: Junio C Hamano · lore

Re: bsd group semantics

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
Junio C Hamano· Mar 31, 2009, 20:26 UTC · re: Jeff King · lore

Re: bsd group semantics

Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> 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.

Jeff King· Mar 31, 2009, 20:36 UTC · re: Junio C Hamano · lore

Re: bsd group semantics

On Tue, Mar 31, 2009 at 01:26:01PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> 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
Junio C Hamano· Mar 31, 2009, 21:33 UTC · re: Jeff King · lore

Re: bsd group semantics

Jeff King <peff@peff.net> writes:
Show 41 quoted lines
> 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)" &&

Show 6 quoted lines
> -
>  	# post-update hook must be 0770
>  	test -z "$(sed -n -e "/post-update/{
>  		/^-rwxrwx---/d
> -- 
> 1.6.2.1.591.geb450
Jeff King· Mar 31, 2009, 22:25 UTC · re: Junio C Hamano · lore

Re: bsd group semantics

On Tue, Mar 31, 2009 at 02:33:26PM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> > -	# 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

← back to recent threads