Cool Things :: Auto mounter script.



True. I plan it 'optimeze' my script when I can get jEdit. ;)
I made a new feature to my script.
It searches for .mount.exec file from $PARTITION. If found then sources it.
This is handy when you have some programs on your hd that you want to run automatically on startup.
I run my eggdrop that way. =) Yes. There's then a big security hole, but I managed to avoid it by then moving .mount.exec and .mount.conf files to another directory and make it accesible only by root. Of course script will move those files back on shutdown/reboot.

Anyway this script still needs optimizing and features. For example (un)mounting only one partition.
I'll be posting more later...

The autorun is, or at least can be, a useful idea.

You might be able to avoid moving and replacing files by mounting the drive without executable permission and running a copy of the file instead of the original.  This way you won't need to bother moving the files back....it will allow the file to continue working after a crash, or on a cdrom.
Just some thought food.

I think too that moving and/or copying those files is unnecessary.

I think script should look if modes of the file are 500 and owner is root, then if both are true then source it.
Any suggestios how to read permissions and owner of a file? I can't (at least at the moment) figure out anything expect `ls -l` and it would need some "dirty" parsing.

Correction to previous post: mode should be 600.

Anyway I managed to do a neat function to check root priviliges:
Code Sample
function crootp () {

 # crootp: short for check root priviliges
 # user and group must be root and permissions must be 600
 [ -f $1 ] && [ -G $1 ] && [ -O $1 ] && [ `stat -c %a $1` -eq "600" ]

}


It's usage is quite simple:
Code Sample
if crootp $FILE
then
 echo FIle is only accessible by root
else
 echo File does not exist or permissions are incorrect
fi

Next Page...
original here.