From nobody@FreeBSD.org  Wed Apr  6 14:49:16 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F1382106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  6 Apr 2011 14:49:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E2F788FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  6 Apr 2011 14:49:16 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p36EnGra040123
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 6 Apr 2011 14:49:16 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p36EnGF7040122;
	Wed, 6 Apr 2011 14:49:16 GMT
	(envelope-from nobody)
Message-Id: <201104061449.p36EnGF7040122@red.freebsd.org>
Date: Wed, 6 Apr 2011 14:49:16 GMT
From: Cmyker <cmyk777@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: test -x under root in bash shell returns incorrect results
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         156225
>Category:       misc
>Synopsis:       test -x under root in bash shell returns incorrect results
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 06 14:50:14 UTC 2011
>Closed-Date:    Wed Apr 06 20:40:42 UTC 2011
>Last-Modified:  Sun Apr 10 14:40:10 UTC 2011
>Originator:     Cmyker
>Release:        8.1-RELEASE
>Organization:
>Environment:
FreeBSD www3 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
test -x under root in bash shell returns incorrect results

clone60# bash --version
GNU bash, version 4.1.7(0)-release (amd64-portbld-freebsd8.1)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
>How-To-Repeat:
Run under root:

www3# sh -c 'test -x ~/.cshrc && echo yes'
www3# bash -c 'test -x ~/.cshrc && echo yes'
yes
>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: remko 
State-Changed-When: Wed Apr 6 17:17:51 UTC 2011 
State-Changed-Why:  
Hello, 

Bash is a third party application which is not in our base system. 
Are you suggesting that bash should behave differently? If so you 
should poke the upstream maintainers so that it can be updated/changed, 
if not can you please clarify what you mean? 

Thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156225 

From: Yuri Pankov <yuri.pankov@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: misc/156225: test -x under root in bash shell returns incorrect
 results
Date: Wed, 6 Apr 2011 22:26:57 +0400

 Still the bug is in bash, as `test' is builtin, and I'm seeing the same
 behaviour on at least OpenSolaris.
 
 
 Yuri
State-Changed-From-To: feedback->closed 
State-Changed-By: remko 
State-Changed-When: Wed Apr 6 20:40:41 UTC 2011 
State-Changed-Why:  
Hello, I would like to ask you to talk to the bash maintainer and/or the 
upstream bash people to get this sorted out. This is not something that 
FreeBSD as OS can do to resolve this (since we import external sources 
for this one). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156225 

From: Mikolaj Golub <trociny@freebsd.org>
To: remko@FreeBSD.org, cmyk777@gmail.com, bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/156225: test -x under root in bash shell returns incorrect results
Date: Sun, 10 Apr 2011 17:33:29 +0300

 Bash checks permission calling eaccess(2). The issue is that it returns
 success for root:
 
  19632 bash     CALL  eaccess(0x28417600,X_OK)
  19632 bash     NAMI  "/root/.cshrc"
  19632 bash     RET   eaccess 0
 
 sh's test has a workaround for this:
 
         case FILEX:
                 /* XXX work around eaccess(2) false positives for superuser */
                 if (eaccess(nm, X_OK) != 0)
                         return 0;
                 if (S_ISDIR(s.st_mode) || geteuid() != 0)
                         return 1;
  
 The eaccess(2) behaviour has been changed in CURRENT. See kern/125009 for
 details. I think this ticket can be set as a duplicate of kern/125009.
 
 -- 
 Mikolaj Golub
>Unformatted:
