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 c...@case.edu http://cnswww.cns.cwru.edu/~chet/