X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Feuidaccess.c;h=ca2ceca5d229aa831647e507139c3a1272e42e4e;hb=e16561484b19d960cbb07bd82033155b2979c4f0;hp=53574a650e6fb8f87a01de8f8755c1c622ad86ea;hpb=3030c5b5e0a5199e16b05927da72c43c42f211c3;p=gnulib.git diff --git a/lib/euidaccess.c b/lib/euidaccess.c index 53574a650..ca2ceca5d 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-2009 Free + Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2012 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. */