Re: [PATCH v2] t4129: don't fail if setgid is set in the test directory

2 messages, 2 authors, 2021-01-09 · open the first message on its own page

Re: [PATCH v2] t4129: don't fail if setgid is set in the test directory

From: Junio C Hamano <hidden>
Date: 2021-01-07 00:00:14

Matheus Tavares [off-list ref] writes:
+# Get the modebits from a file or directory, ignoring the setgid bit (g+s).
+# This bit is inherited by subdirectories at their creation. So we remove it
+# from the returning string to prevent callers from having to worry about the
+# state of the bit in the test directory.
+#
We probably do not use "chmod g+s" manually on regular files, so I
may be being overly "correct", but shouldn't these be done only for
directories?
 test_modebits () {
-	ls -ld "$1" | sed -e 's|^\(..........\).*|\1|'
+	ls -ld "$1" | sed -e 's|^\(..........\).*|\1|' \
+			  -e 's|^\(......\)S|\1-|' -e 's|^\(......\)s|\1x|'
That is, 

			  -e 's|^\(d.....\)S|\1-|' -e 's|^\(d.....\)s|\1x|'

instead of applying the rule to any filetype.

Will queue as-is, as the distinction probably would not matter in
practice.

Thanks.

Re: [PATCH v2] t4129: don't fail if setgid is set in the test directory

From: Matheus Tavares Bernardino <hidden>
Date: 2021-01-09 14:20:15

On Wed, Jan 6, 2021 at 8:59 PM Junio C Hamano [off-list ref] wrote:
Matheus Tavares [off-list ref] writes:
quoted
+# Get the modebits from a file or directory, ignoring the setgid bit (g+s).
+# This bit is inherited by subdirectories at their creation. So we remove it
+# from the returning string to prevent callers from having to worry about the
+# state of the bit in the test directory.
+#
We probably do not use "chmod g+s" manually on regular files, so I
may be being overly "correct", but shouldn't these be done only for
directories?
quoted
 test_modebits () {
-     ls -ld "$1" | sed -e 's|^\(..........\).*|\1|'
+     ls -ld "$1" | sed -e 's|^\(..........\).*|\1|' \
+                       -e 's|^\(......\)S|\1-|' -e 's|^\(......\)s|\1x|'
That is,

                          -e 's|^\(d.....\)S|\1-|' -e 's|^\(d.....\)s|\1x|'

instead of applying the rule to any filetype.
Yeah, you're right. I ended up applying the rule on regular files as
well just for standardization. That is, if some day, for some reason,
a test script decides to use "chmod g+s" on a regular file and a
directory, test_modebits would treat them equally to avoid any
confusion. But I guess it's very unlikely that we will ever need to
set the setgid bit on a test, anyway...
Will queue as-is, as the distinction probably would not matter in
practice.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help