/* euidaccess -- check if effective user id can access file
- Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2011 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.
#include <sys/stat.h>
#include <unistd.h>
+#include "root-uid.h"
+
#if HAVE_LIBGEN_H
# include <libgen.h>
#endif
#endif
/* Return 0 if the user has permission of type MODE on FILE;
- otherwise, return -1 and set `errno'.
+ otherwise, return -1 and set 'errno'.
Like access, except that it uses the effective user and group
id's instead of the real ones, and it does not always check for read-only
file system, text busy, etc. */
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 ();
/* 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. */