Kemp@DOCKMASTER.NCSC.MIL (05/06/89)
I have run across a bug in either csh or my understanding of it (almost certainly the latter). I have a directory of files that were read from a tape with no world permissions: -rw-r----- root a.c -rw-r----- root b.c -rwxr-x--- root a.out I want to change all the files to have world read permission, and all the executables to have world execute. I tried the following in csh as root: # 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. Obviously ls knows what the permissions are, and so does exec; if I try to run a.c, I get "Permission denied". What is wrong with my use of csh? (I am using SunOS 4.0.1, if it matters.) I finally had to solve the problem by using ls, grep, and colrm to generate the list of files to modify. Dave Kemp <Kemp@dockmaster.ncsc.mil>
pvo@uther.CS.ORST.EDU (Paul V O'Neill) (05/06/89)
In article <19486@adm.BRL.MIL> Kemp@DOCKMASTER.NCSC.MIL writes: > >I want to change all the files to have world read permission, and all >the executables to have world execute. I tried the following in csh as >root: > > # foreach f (*) > ? if -x $f chmod o+x $f > ? end > > (I am using SunOS 4.0.1, if it matters.) > Why test? From the 4.0 man pages: X Give execute permission if the file is a directory or if there is execute permission for one of the other user classes. Try # chmod o+X * Paul O'Neill pvo@oce.orst.edu Coastal Imaging Lab OSU--Oceanography Corvallis, OR 97331 503-754-3251
graham%ee.surrey.ac.uk@nsfnet-relay.ac.uk (Graham J Carpenter) (05/08/89)
> >I want to change all the files to have world read permission, and all >the executables to have world execute. I tried the following in csh as >root: > I usually use octal to set patterns with chmod, but the one time I use letters is in exactly this situation. chmod o+rX would have done the job for you. -- Graham Carpenter - graham@ee.surrey.ac.uk Dept of Electronic and Electrical Engineering University of Surrey, Guildford, Surrey, GU2 5XH.
morrell@hpsal2.HP.COM (Michael Morrell) (05/09/89)
/ hpsal2:comp.unix.questions / Kemp@DOCKMASTER.NCSC.MIL / 6:33 pm May 5, 1989 / I have run across a bug in either csh or my understanding of it (almost certainly the latter). I have a directory of files that were read from a tape with no world permissions: -rw-r----- root a.c -rw-r----- root b.c -rwxr-x--- root a.out I want to change all the files to have world read permission, and all the executables to have world execute. I tried the following in csh as root: # 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, 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". Michael
abcscnge@csuna.csun.edu (Scott "The Pseudo-Hacker" Neugroschl) (05/10/89)
In article <19486@adm.BRL.MIL> Kemp@DOCKMASTER.NCSC.MIL writes: } } # foreach f (*) } ? if -x $f chmod o+x $f } ? end } How about: # find . -perm 0100 -exec chmod o+x {} \; -print Note: I may have remembered the syntax of -perm incorrectly... no RTFMs to me, please. find(1) allows one to look for a specific mask or specific perms. Check the manual. -- Scott "The Pseudo-Hacker" Neugroschl UUCP: ...!sm.unisys.com!csun!csuna.csun.edu!abcscnge -- unless explicitly stated above, this article not for use by rec.humor.funny -- Disclaimers? We don't need no stinking disclaimers!!!