[comp.unix.questions] Re^2: Testing execute permission from csh

maart@cs.vu.nl (Maarten Litmaath) (05/11/89)

morrell@hpsal2.HP.COM (Michael Morrell) writes:
\/ hpsal2:comp.unix.questions / Kemp@DOCKMASTER.NCSC.MIL /
\6:33 pm  May  5, 1989 /
\...
\ -rw-r-----  root   a.c
\ -rw-r-----  root   b.c
\ -rwxr-x---  root   a.out
\...
\ # foreach f (*)
\ ? if -x $f chmod o+x $f
\ ? end
\
\and it selected EVERY file, not just those with execute permission.  (I
\actually used echo instead of chmod while testing).  If I do the same
\thing as a normal user, it works properly.
\
\----------
\
\  I think since the superuser can execute any file even if it has mode 000,

Wrong! The superuser needs AT LEAST ONE x-bit turned on.

\csh tries to do you a favor and always returns true for "-x" if you are root
\(same goes for "-r" and "-w").  I don't know if I like this "feature".

It's a bad feature, but this time it's NOT csh's fault! (Unbelievable :-)
Esteemed members of the Jury, the guilty is...

	access(2)!

Something like:
        /*
         * If you're the super-user,
         * you always get access.
         */
        if (cred->cr_uid == 0)
                return (0);
:-(
-- 
 "`Goto considered harmful' considered |Maarten Litmaath @ VU Amsterdam:
      harmful" considered harmful!     |maart@cs.vu.nl, mcvax!botter!maart