From: Junio C Hamano <hidden> Date: 2016-06-15 23:03:36
Jeff King [off-list ref] writes:
Exactly. I am happy to submit a patch, but I cannot think of any
mechanisms besides:
1. Calling `id`, which I suspect is very not portable.
2. Writing a C program to check getuid(). That's portable for most
Unixes. It looks like we already have a hacky wrapper on mingw that
will always return "1".
Is (2) too gross?
Not overly gross compared to some existing test-*.c files, I would
say.
I wondered what 'perl -e 'print $>' would say in mingw, and if that
is portable enough, though.
From: Jeff King <hidden> Date: 2016-06-15 23:03:36
On Thu, Jan 15, 2015 at 04:04:24PM -0800, Junio C Hamano wrote:
I wondered what 'perl -e 'print $>' would say in mingw, and if that
is portable enough, though.
Good thinking. I guess the best way to find out is to convince somebody
from msysgit to try this patch. :)
We may simply find that nobody there even has apache installed on their
box, and they do not run the http tests at all.
-- >8 --
The SANITY prerequisite is really about whether the
filesystem will respect the permissions we set, and being
root is only one part of that. But the httpd tests really
just care about not being root, as they are trying to avoid
weirdness in apache (see a1a3011 for details).
Let's switch out SANITY for a new NOT_ROOT prerequisite,
which will let us tweak SANITY more freely.
We implement NOT_ROOT by checking perl's "$>" variable,
since we cannot rely on the "id" program being available
everywhere (and we would rather avoid writing a custom C
program to run geteuid if we can).
Note that we cannot just call this "ROOT" and ask for
"!ROOT". The possible outcomes are:
1. we know we are root
2. we know we are not root
3. we could not tell, because perl was not installed or
barfed showing us $>
We should conservatively treat (3) as "does not have the
prerequisite", which means that a naive negation would not
work.
Signed-off-by: Jeff King <redacted>
---
t/lib-httpd.sh | 2 +-
t/test-lib.sh | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -37,7 +37,7 @@ thentest_donefi-if!test_have_prereqSANITY;then+if!test_have_prereqNOT_ROOT;thentest_skip_or_die$GIT_TEST_HTTPD\"Cannot run httpd tests as root"fi
--
2.2.1.425.g441bb3c
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From: Kyle J. McKay <hidden> Date: 2016-06-15 23:03:36
On Jan 15, 2015, at 17:32, Jeff King wrote:
On Thu, Jan 15, 2015 at 04:04:24PM -0800, Junio C Hamano wrote:
quoted
I wondered what 'perl -e 'print $>' would say in mingw, and if that
is portable enough, though.
Good thinking. I guess the best way to find out is to convince
somebody
from msysgit to try this patch. :)
We may simply find that nobody there even has apache installed on
their
box, and they do not run the http tests at all.
[...]
We implement NOT_ROOT by checking perl's "$>" variable,
since we cannot rely on the "id" program being available
everywhere (and we would rather avoid writing a custom C
program to run geteuid if we can).
Does it make a difference that id is POSIX [1]?
So the test "if [ $(id -u) = 0 ]" or similar ought to work.
"id -u" works for me in MSYS and cygwin (each appears to have it's own
id.exe).
Does NO_PERL affect this? Or is Perl always required to run the tests.
Also "$<" is real user id. Don't you want effective user id ("$>"),
that's what the comment says...
Both "$<" and "$>" work for me in MSYS and cygwin although if I run it
from cmd.exe using strawberry perl, both "$<" and "$>" give 0.
(There's no id.exe for cmd.exe unless it finds the cygwin/msys one.)
As long as NO_PERL is not also intended to affect "make test" either
the perl or id version seems fine to me (as long as it's Perl's "$>")
since I doubt the tests would run with just cmd.exe. :)
-Kyle
[1] http://pubs.opengroup.org/onlinepubs/009604499/utilities/id.html
From: Jeff King <hidden> Date: 2016-06-15 23:03:36
On Thu, Jan 15, 2015 at 07:27:34PM -0800, Kyle J. McKay wrote:
quoted
We implement NOT_ROOT by checking perl's "$>" variable,
since we cannot rely on the "id" program being available
everywhere (and we would rather avoid writing a custom C
program to run geteuid if we can).
Does it make a difference that id is POSIX [1]?
I don't know. Do all of the platforms where we run http tests have it
(and conforming to POSIX-ish options or output)? It may be OK to guess
yes and see if anybody complains (the worst case is skipping http
tests).
"id -u" works for me in MSYS and cygwin (each appears to have it's own
id.exe).
That's comforting. MSYS was the one I was most worried about. What UID
do they report? I.e., do they correctly tell us if we are root (or
more accurately, if we are not root)?
Does NO_PERL affect this? Or is Perl always required to run the tests.
No, we use a very limited subset of perl in our tests when necessary
(basic enough that any perl5 will do), regardless of the NO_PERL
setting.
Also "$<" is real user id. Don't you want effective user id ("$>"), that's
what the comment says...
Yeah, I bungled this initially and thought I fixed it, but clearly not.
:-/
I'll re-roll, but if we can get away with "id -u" I think that's
preferable.
-Peff
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From: Jeff King <hidden> Date: 2016-06-15 23:03:36
On Thu, Jan 15, 2015 at 10:34:46PM -0500, Jeff King wrote:
quoted
"id -u" works for me in MSYS and cygwin (each appears to have it's own
id.exe).
That's comforting. MSYS was the one I was most worried about. What UID
do they report? I.e., do they correctly tell us if we are root (or
more accurately, if we are not root)?
So here's a re-roll with `id -u`, as that may be the simplest way to get
people to test (with the patch applied, running t5550 as a normal user
should work, and as root should skip the tests).
-- >8 --
Subject: [PATCH] t/lib-httpd: switch SANITY check for NOT_ROOT
The SANITY prerequisite is really about whether the
filesystem will respect the permissions we set, and being
root is only one part of that. But the httpd tests really
just care about not being root, as they are trying to avoid
weirdness in apache (see a1a3011 for details).
Let's switch out SANITY for a new NOT_ROOT prerequisite,
which will let us tweak SANITY more freely.
We implement NOT_ROOT by checking `id -u`, which is in POSIX
and seems to be available even on MSYS. Note that we cannot
just call this "ROOT" and ask for "!ROOT". The possible
outcomes are:
1. we know we are root
2. we know we are not root
3. we could not tell, because `id` was not available
We should conservatively treat (3) as "does not have the
prerequisite", which means that a naive negation would not
work.
Helped-by: Kyle J. McKay [off-list ref]
Signed-off-by: Jeff King <redacted>
---
t/lib-httpd.sh | 2 +-
t/test-lib.sh | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -37,7 +37,7 @@ thentest_donefi-if!test_have_prereqSANITY;then+if!test_have_prereqNOT_ROOT;thentest_skip_or_die$GIT_TEST_HTTPD\"Cannot run httpd tests as root"fi
--
2.2.1.425.g441bb3c
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From: Kyle J. McKay <hidden> Date: 2016-06-15 23:03:36
On Jan 16, 2015, at 01:16, Jeff King wrote:
Subject: [PATCH] t/lib-httpd: switch SANITY check for NOT_ROOT
[...]
We implement NOT_ROOT by checking `id -u`, which is in POSIX
and seems to be available even on MSYS. Note that we cannot
just call this "ROOT" and ask for "!ROOT". The possible
outcomes are:
1. we know we are root
2. we know we are not root
3. we could not tell, because `id` was not available
We should conservatively treat (3) as "does not have the
prerequisite", which means that a naive negation would not
work.
That looks good to me and worked as expected when I tried it.
-Kyle
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From: Kyle J. McKay <hidden> Date: 2016-06-15 23:03:36
On Jan 15, 2015, at 19:34, Jeff King wrote:
On Thu, Jan 15, 2015 at 07:27:34PM -0800, Kyle J. McKay wrote:
quoted
"id -u" works for me in MSYS and cygwin (each appears to have it's
own
id.exe).
That's comforting. MSYS was the one I was most worried about. What UID
do they report? I.e., do they correctly tell us if we are root (or
more accurately, if we are not root)?
It's funny, really. The MSYS version gives a different answer than
the cygwin version although both are non-zero. The MSYS perl gives
the same answer as the MSYS id and the cygwin perl gives the same
answer as the cygwin id.
I'm not even sure what it would mean to "be root" on one of those
systems.
The closest I can think of would be to run as the "SYSTEM" user. And
that's not nearly as simple as just "sudo -s". [1].
I haven't tested that. I will try to remember to give that a try next
time I'm feeling the need for some frustration. ;)
-Kyle
[1] http://cygwin.com/ml/cygwin/2010-04/msg00651.html
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
"id -u" works for me in MSYS and cygwin (each appears to have it's
own id.exe).
That's comforting. MSYS was the one I was most worried about. What UID
do they report? I.e., do they correctly tell us if we are root (or
more accurately, if we are not root)?
Checking for UID 0 won't work on Cygwin in the general case. That fools
literally dozens of Perl module tests that find out the user can
actually do something they think (s)he should be unable to.
It's funny, really. The MSYS version gives a different answer than
the cygwin version although both are non-zero. The MSYS perl gives
the same answer as the MSYS id and the cygwin perl gives the same
answer as the cygwin id.
That result changes depending on the content /etc/passwd (which arguably
is a either a bug or a feature depending on which way you look at it).
But Windows itself doesn't have the notion of a root user at all, so
looking for one isn't going to be helpful.
I'm not even sure what it would mean to "be root" on one of those
systems.
It means you have the capabilities that a root user would be expected to
have. For most intents and purposes on Windows this would mean the user
running the command is in group 544 ("Administrators" in an english
version of Windows).
The closest I can think of would be to run as the "SYSTEM" user. And
that's not nearly as simple as just "sudo -s". [1].
The SYSTEM user isn't a good approximation of root under UN*X for
reasonably modern Windows versions.
http://support.microsoft.com/kb/120929
For more discussion on the UID 0 topic from a Cygwin perspective, see
http://thread.gmane.org/gmane.os.cygwin.applications/28129http://thread.gmane.org/gmane.os.cygwin.applications/28203
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From: Erik Faye-Lund <hidden> Date: 2016-06-15 23:03:41
On Fri, Jan 16, 2015 at 1:04 AM, Junio C Hamano [off-list ref] wrote:
Jeff King [off-list ref] writes:
quoted
Exactly. I am happy to submit a patch, but I cannot think of any
mechanisms besides:
1. Calling `id`, which I suspect is very not portable.
2. Writing a C program to check getuid(). That's portable for most
Unixes. It looks like we already have a hacky wrapper on mingw that
will always return "1".
Is (2) too gross?
Not overly gross compared to some existing test-*.c files, I would
say.
I wondered what 'perl -e 'print $>' would say in mingw, and if that
is portable enough, though.