Bug 156225 - test -x under root in bash shell returns incorrect results
Summary: test -x under root in bash shell returns incorrect results
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 8.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-06 15:50 UTC by Cmyker
Modified: 2011-04-10 15:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cmyker 2011-04-06 15:50:14 UTC
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
Comment 1 Remko Lodder freebsd_committer 2011-04-06 18:17:51 UTC
State Changed
From-To: open->feedback

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
Comment 2 Yuri Pankov 2011-04-06 19:26:57 UTC
Still the bug is in bash, as `test' is builtin, and I'm seeing the same
behaviour on at least OpenSolaris.


Yuri
Comment 3 Remko Lodder freebsd_committer 2011-04-06 21:40:41 UTC
State Changed
From-To: feedback->closed

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).
Comment 4 Mikolaj Golub freebsd_committer 2011-04-10 15:33:29 UTC
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