[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Built-in "test -x" fails for root on FreeBSD
From: |
Johan Hattne |
Subject: |
Built-in "test -x" fails for root on FreeBSD |
Date: |
Fri, 29 Apr 2011 11:25:51 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110328 Lightning/1.0b3pre Thunderbird/3.1.9 |
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: freebsd8.0
Compiler: i686-gentoo-freebsd8.0-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='freebsd8.0' -DCONF_MACHTYPE='i686-gentoo-freebsd8.0'
-DCONF_VENDOR='gentoo' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
-DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin'
-DSYS_BASHRC='/etc/bash/bashrc'
-DSYS_BASH_LOGOUT='/etc/bash/bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
-DSSH_SOURCE_BASHRC -march=pentium4 -O2 -pipe -fomit-frame-pointer
uname output: FreeBSD life 8.0-RELEASE FreeBSD Gentoo 8.0 #3: Fri Jun 25
14:48:40 CDT 2010 hattne@life:/usr/src/sys-8.0-r0/i386/compile/LIFE
i386
Machine Type: i686-gentoo-freebsd8.0
Bash Version: 4.2
Patch Level: 8
Release Status: release
Description:
Following a report about a year ago, the determination of the
executable status used by bash's built-in test command was changed.
The original issue was that the access(2) family of functions may
indicate success for X_OK, even if the file does not actually have
any execute permission bits set. This is allowed by the
specification for historical reasons, even though discouraged for new
implementations
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html).
On FreeBSD which provides faccessat(2) as well as eaccass(2), this
causes test -x to report false positives.
Repeat-By:
bash# test -x /etc/passwd && echo "SUCCESS"
SUCCESS
Fix:
--- lib/sh/eaccess.c.orig 2011-04-15 08:34:35.458519500 -0500
+++ lib/sh/eaccess.c 2011-04-15 09:11:35.698844210 -0500
@@ -203,14 +203,14 @@
if (path_is_devfd (path))
return (sh_stataccess (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 defined (HAVE_FACCESSAT) && defined (AT_EACCESS) || defined
(HAVE_EACCESS)
+# if defined (HAVE_FACCESSAT) && defined (AT_EACCESS)
+ ret = faccessat (AT_FDCWD, path, mode, AT_EACCESS);
+# else
+ ret = eaccess (path, mode);
+# endif
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);
- Built-in "test -x" fails for root on FreeBSD,
Johan Hattne <=