X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Feuidaccess.c;h=f73438e6f4787124b532911128a3ce43114a2661;hb=5191b3546cfb6c163228c23f214e325ddf60d46f;hp=ba744d5cf7e23afb247eeed0989ef362a4a24e87;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/lib/euidaccess.c b/lib/euidaccess.c index ba744d5cf..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-2010 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,15 +76,15 @@ int euidaccess (const char *file, int mode) { -#if HAVE_FACCESSAT +#if HAVE_FACCESSAT /* glibc, AIX 7, Solaris 11, Cygwin 1.7 */ return faccessat (AT_FDCWD, file, mode, AT_EACCESS); -#elif defined EFF_ONLY_OK +#elif defined EFF_ONLY_OK /* IRIX, OSF/1, Interix */ return access (file, mode | EFF_ONLY_OK); -#elif defined ACC_SELF +#elif defined ACC_SELF /* AIX */ return accessx (file, mode, ACC_SELF); -#elif HAVE_EACCESS +#elif HAVE_EACCESS /* FreeBSD */ return eaccess (file, mode); -#else +#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. */