Is it possible we can run some command on some particular folder so that we can't file type except image in that folder ?
-
The easy solution would be to have a daemon check periodicaly the output of file(1) and erase anythng not of the desired file type.
dunxd : A cron job would be easier to implement than a daemon.From adamo -
No, this is not easy to do. You can restrict permissions so that only files of certain ownership or execute/read/write permissions can be written, but discriminating on file type is not something most unix file systems do.
I suggest you will need to implement this at the programmatic level. Either in the software that you allow access with (for example FTP often has restrictions based on mime types) or in some type of control daemon that checks your users input for validity you can check out the contents.
If you post your exact case scenario we might be able to suggest and appropriate way of handling this, but for now all we can say is that this is not a standard way of adding restrictions. There probably is an appropriate tool for the job, but we need to know the job first.
Amit Aggarwal : I know that we can handle it during the development... but just want to be extra safe... by making the folder restricted to accept only say .jpg, .png etcCaleb : Wanting to be extra safe is a good thing, keep thinking like that. I would just suggest that the best way to be safe is to understand and follow conventions on a given platform. Unix doesn't make any particular distinction about file type, and unlike in windows file names are NOT indicative of what they contain or do. A png of puppies could be called spam_people.exe and an exactable binary file that sends emails could be called puppy_photo.png. The important part is what unix DOES do, set very exact permissions at the user, group and system levels.From Caleb
0 comments:
Post a Comment