PDA

View Full Version : A file permissions puzzle



kpfuser
11-02-2007, 05:28 PM
Just as I thought that I was getting a bit familiar with bash, there came the following perplexing puzzle:

knoppix@1[my-scripts]$ su
root@1[my-scripts]# ls -l
total 32
-rwxr-xr-x 1 knoppix knoppix 1090 Nov 27 2006 my-html-script
root@1[my-scripts]# my-html-script > my-file.html
bash: my-html-script: command not found
root@1[my-scripts]# gedit my-html-script
root@1[my-scripts]# gedit my-html-script
root@1[my-scripts]# exit
exit
knoppix@1[my-scripts]$ my-html-script > my-file.html
knoppix@1[my-scripts]$

As it can be seen from the above, although su has permission to run my-html-script, the latter does not run. The same script runs normally for user knoppix. Furthermore, although su is not permitted to write to my-html-script I was able to modify the latter while logged in as su. How come?

OErjan
11-02-2007, 07:27 PM
the first I suspect you need to give full path
/home/knoppix/my-html-script > my-file.html

on the second, su=root=GOD!
root can do ANYTHING, even destroy the computer hardware that is, if you know how, perhaps in some extreme case, by sheer bad luck.

by destroy I mean something like, hmm, hard to choose one from list of bad things.
i think this will ilustrate,
it is quite possible to wipe proms and thus permanently trash DVD, CD, BIOS, HDD...
by permanently I mean it requires sending back to manufacturer to repair hardware (or having preprogrammed replacement parts and a good electronic background), and likley professional help on recovering the data in the HDD.

kpfuser
11-03-2007, 10:37 AM
the first I suspect you need to give full path
Well, perhaps. However, with the full path being
KNOPPIX.IMG/home/knoppix/my-scripts/my-html.script > my-file.html
this is not a particularly attractive option. A better option I stumbled upon accidentally after I posted originally is
./my-html-script > my-file.html
which worked for me but probably requires adding beforehand (already done in my case) the full path to my-html-script to the collection of standard paths the shell goes to when it has to execute a script.


on the second, su=root=GOD!
root can do ANYTHING, even destroy the computer.....
Fine! This is indeed what everyone associates with root except perhaps the destruction part. But with this in mind, what is the reason for having the last three characters in a string like - rwx r-x r-x? Shouldn't it read - rwx r-x instead? Furthermore what about running chmod to change file permissions to, say, 755 when what you really get is 757? Isn't the whole idea of file permissions utterly inconsistent and indeed deceiving?