Behaviour of access(x, X_OK) in 2.2 vs. 2.4

Peter Backes
2003-07-02T22:27:20Z

Hi,

I'm still using linux 2.2 and I noticed today that the behaviour of
the access() system call concerning the execution permission (X_OK),
if invoked by uid 0, has been changed in 2.4. In 2.4 it seems to
take the execute permission bit into account while in 2.2, for uid 0,
it returns success (0) independent from it, although execve fails if
invoked on a file without x bit. The difference can be demonstrated
quite easily using the bash builtin test command on a file without x
bit, which (like /usr/bin/access from tetex and unlike /usr/bin/test
from sh-utils) seems to use access():

On 2.2:
bash# cd /tmp && touch xx && test -x xx && echo x || echo y
x

although

bash# cd /tmp && cp /bin/echo . && chmod 0 echo && ./echo
bash: ./echo: Permission denied

On 2.4:
bash# cd /tmp && touch xx && test -x xx && echo x || echo y
y

(Note this assumes an umask of 0022.)

I searched the web, newsgroups and mailing list archives about this
problem, to no avail. Is there some backport, workaround or patch
for 2.2 to get the same (and obsiously more sane) behaviour as in
2.4?

Please make sure you CC me if you reply as I'm not subscribed.
-- Peter 'Rattacresh' Backes, rtc@helen.PLASMA.Xg8.DE