bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: access(2) shouldn't be used with test(1)


From: Chet Ramey
Subject: Re: access(2) shouldn't be used with test(1)
Date: Tue, 20 Jul 2010 20:16:09 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 7/20/10 2:00 PM, Garrett Cooper wrote:
>     According to the POSIX spec, using access(2) is implementation
> dependent when running as superuser [1]. FreeBSD intentionally returns
> true whenever euid/uid = 0 [2]. FreeBSD's /bin/sh doesn't have this
> `issue' with test(1). Example:

Bash-4.1 doesn't use access for `test -x' (or -e, -r, or -w, for that
matter) on FreeBSD.  If eaccess is available and configure detects its
presence, bash uses that, otherwise it either uses access or checks the
permissions returned by stat.

Bash-4.2 will prefer the use of faccessat if available, falling back to
eaccess and then access/stat.  On FreeBSD, bash-4.2 will use stat to
verify X_OK when euid == 0 even if eaccess returns true, since eaccess
lies also (the FreeBSD test does the same thing).

The relevant code is in lib/sh/eaccess.c:sh_eaccess().  This was
discussed extensively back in March.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]