Machine Type: i686-gentoo-freebsd7.2
Bash Version: 4.1
Patch Level: 2
Release Status: release
Description:
The bash built-in test command fails to correctly report executable
status for non-executable files when run by root on FreeBSD. On
FreeBSD, bash calls eaccess(2) to find the executable status, but
according to the man page "even if a process's real or effective user
has appropriate privileges and indicates success for X_OK, the file
may
not actually have execute permission bits set". The attached patch is
based on source from FreeBSD's stand-alone test,
http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/test/test.c.
Repeat-By:
su -
bash
test -x /etc/passwd && echo "is executable"
Fix:
--- lib/sh/eaccess.c.orig 2010-02-03 21:26:08 -0600
+++ lib/sh/eaccess.c 2010-02-03 21:56:32 -0600
@@ -198,11 +198,19 @@
char *path;
int mode;
{
+ struct stat s;
+ int ret;
+
if (path_is_devfd (path))
return (sh_stataccess (path, mode));
#if defined (HAVE_EACCESS) /* FreeBSD */
- return (eaccess (path, mode));
+ if (stat (path, &s) != 0)
+ return (-1);
+ ret = eaccess (path, mode);
+ if (mode == X_OK && ret == 0 && !S_ISDIR(s.st_mode) && geteuid() ==
0)