X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Feuidaccess.c;h=f73438e6f4787124b532911128a3ce43114a2661;hb=533101a268dc5015a140ff4695d8eeb04fbe57b6;hp=101f975d294b6d577ce3631a47b09c508011089f;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/euidaccess.c b/lib/euidaccess.c index 101f975d2..f73438e6f 100644 --- a/lib/euidaccess.c +++ b/lib/euidaccess.c @@ -1,6 +1,6 @@ /* 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-2013 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -30,6 +30,8 @@ #include #include +#include "root-uid.h" + #if HAVE_LIBGEN_H # include #endif @@ -63,14 +65,10 @@ # undef stat # define stat stat64 -#else - -# include "group-member.h" - #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. */ @@ -78,7 +76,7 @@ int euidaccess (const char *file, int mode) { -#if HAVE_FACCESSAT /* glibc */ +#if HAVE_FACCESSAT /* glibc, AIX 7, Solaris 11, Cygwin 1.7 */ return faccessat (AT_FDCWD, file, mode, AT_EACCESS); #elif defined EFF_ONLY_OK /* IRIX, OSF/1, Interix */ return access (file, mode | EFF_ONLY_OK); @@ -86,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 (); @@ -144,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. */