aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sh/eaccess.c
diff options
context:
space:
mode:
authorSebastian Schmidt <yath@yath.de>2012-04-17 11:23:35 +0200
committerSebastian Schmidt <yath@yath.de>2012-04-17 11:24:20 +0200
commitf4b417c62a4f272c4cf9a074d0f7a3a97201f9db (patch)
treee2196f3b6361e2377c43ab47a3abf17d8f6afd77 /lib/sh/eaccess.c
parent791237e44695d2ee123c8a6f665ef074f5fadfbb (diff)
downloadexternal_bash-f4b417c62a4f272c4cf9a074d0f7a3a97201f9db.zip
external_bash-f4b417c62a4f272c4cf9a074d0f7a3a97201f9db.tar.gz
external_bash-f4b417c62a4f272c4cf9a074d0f7a3a97201f9db.tar.bz2
Update to upstream bash 4.2
This upgrades bash to from 4.1-rc to 4.2-release. See CWRU/changelog for changes. Change-Id: I926269c300cf44fa25964b5b375a148fcf11c4b7
Diffstat (limited to 'lib/sh/eaccess.c')
-rw-r--r--lib/sh/eaccess.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/sh/eaccess.c b/lib/sh/eaccess.c
index 989bc22..d9bca8c 100644
--- a/lib/sh/eaccess.c
+++ b/lib/sh/eaccess.c
@@ -1,6 +1,6 @@
/* eaccess.c - eaccess replacement for the shell, plus other access functions. */
-/* Copyright (C) 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2010 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -198,11 +198,20 @@ sh_eaccess (path, mode)
char *path;
int mode;
{
+ int ret;
+
if (path_is_devfd (path))
return (sh_stataccess (path, mode));
-#if defined (HAVE_EACCESS) /* FreeBSD */
- return (eaccess (path, mode));
+#if defined (HAVE_FACCESSAT) && defined (AT_EACCESS)
+ return (faccessat (AT_FDCWD, path, mode, AT_EACCESS));
+#elif defined (HAVE_EACCESS) /* FreeBSD */
+ ret = eaccess (path, mode); /* XXX -- not always correct for X_OK */
+# if defined (__FreeBSD__)
+ if (ret == 0 && current_user.euid == 0 && mode == X_OK)
+ return (sh_stataccess (path, mode));
+# endif
+ return ret;
#elif defined (EFF_ONLY_OK) /* SVR4(?), SVR4.2 */
return access (path, mode|EFF_ONLY_OK);
#else
@@ -215,7 +224,15 @@ sh_eaccess (path, mode)
# endif
if (current_user.uid == current_user.euid && current_user.gid == current_user.egid)
- return (access (path, mode));
+ {
+ ret = access (path, mode);
+#if defined (__FreeBSD__) || defined (SOLARIS)
+ if (ret == 0 && current_user.euid == 0 && mode == X_OK)
+ return (sh_stataccess (path, mode));
+#endif
+ return ret;
+
+ }
return (sh_stataccess (path, mode));
#endif