This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH - ping] Don't unlink /dev/null on darwin


"Peter O'Gorman" <peter@pogma.com> writes:

> Trying again.
>
> I like my /dev/null, not having one causes all kinds of mysterious failures.
>
> <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00439.html>

While this is clearly a real problem, I don't think your proposed
patch is the right fix.  We shouldn't be running the compiler at all
under 'make install'.

There are two patches attached to this message.  I'd like you to apply
the first one to your source tree and see if it solves the instant
problem.

The second patch is a possible general stopgap to prevent this sort of
scenario from causing damage in the future.  It is a very big hammer,
and I recognize that it may break stuff, but I am nonetheless deadly
serious about proposing it.  It is not ready for inclusion as is - it
may well be in the wrong place (Peter, if you feel like it, I'd
appreciate your experimenting to see whether or not it prevents the
Darwin assembler from unlinking /dev/null if you run the problem
command by hand as root) and it certainly needs autoconf goo.  Right
now, though, what I want to hear about is not these minor details, but
rather compelling reasons why we should *not* do this, because I can't
think of any.

zw

        * mklibgcc.in: Do not invoke compiler to determine $(vis_hide)
        if MAKECMDGOALS is "install".

===================================================================
Index: mklibgcc.in
--- mklibgcc.in	12 Feb 2005 00:26:52 -0000	1.82
+++ mklibgcc.in	14 Feb 2005 17:56:55 -0000
@@ -100,12 +100,16 @@ if [ "$SHLIB_LINK" ]; then
   # the command line, and a #define to prevent libgcc2.h etc from
   # overriding that with #pragmas.  The dance with @ is to prevent
   # echo from seeing anything it might take for an option.
+  echo "ifneq (install,\$(MAKECMDGOALS))"
   echo "vis_hide := \$(strip \$(subst @,-,\\"
   echo "    \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
   echo "          $gcc_compile -fvisibility=hidden -Werror \\"
   echo "          -c -xc - -o /dev/null 2> /dev/null; \\"
   echo "          then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
   echo "          fi)))"
+  echo "else"
+  echo "vis_hide := makefile_bug_should_not_run_compiler_during_installation"
+  echo "endif"
   echo
 
   # If we have -fvisibility=hidden, then we need to generate hide
        * toplev.c (toplev_main): Error out if real or effective UID
        is zero.

===================================================================
Index: toplev.c
--- toplev.c	12 Feb 2005 00:26:52 -0000	1.942
+++ toplev.c	14 Feb 2005 17:56:55 -0000
@@ -2119,6 +2119,12 @@ toplev_main (unsigned int argc, const ch
 {
   save_argv = argv;
 
+  if (geteuid() == 0 || getuid() == 0)
+    {
+      fprintf (stderr, "%s: do not run as root\n", argv[0]);
+      return FATAL_EXIT_CODE;
+    }
+
   /* Initialization of GCC's environment, and diagnostics.  */
   general_init (argv[0]);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]