NEWS.stable: log cherry-pick [e446f25]->[c092018] relocatable-shell: Update suggested...
[gnulib.git] / lib / euidaccess.c
index 44e0ea1..363e6fe 100644 (file)
@@ -1,6 +1,6 @@
 /* euidaccess -- check if effective user id can access file
 
-   Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2012 Free
+   Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2014 Free
    Software Foundation, Inc.
 
    This file is part of the GNU C Library.
@@ -30,6 +30,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "root-uid.h"
+
 #if HAVE_LIBGEN_H
 # include <libgen.h>
 #endif
@@ -82,7 +84,7 @@ euidaccess (const char *file, int mode)
   return accessx (file, mode, ACC_SELF);
 #elif HAVE_EACCESS                      /* FreeBSD */
   return eaccess (file, mode);
-#else       /* MacOS X, NetBSD, OpenBSD, HP-UX, Solaris, Cygwin, mingw, BeOS */
+#else       /* Mac OS X, NetBSD, OpenBSD, HP-UX, Solaris, Cygwin, mingw, BeOS */
 
   uid_t uid = getuid ();
   gid_t gid = getgid ();
@@ -140,8 +142,9 @@ euidaccess (const char *file, int mode)
 
   /* The super-user can read and write any file, and execute any file
      that anyone can execute.  */
-  if (euid == 0 && ((mode & X_OK) == 0
-                    || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
+  if (euid == ROOT_UID
+      && ((mode & X_OK) == 0
+          || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
     return 0;
 
   /* Convert the mode to traditional form, clearing any bogus bits.  */