1

I have a script that allows public to upload small jpg's to a gallery. Works well but occasionally unwanted files are uploaded.

How do I make all files inherit public unreadable permissions in that single directory until I change it's permission to readable?

As some jpg's will have readable permissions and be live - making the folder unreadable is not an option.

1

If you can't use a folder to wrap permissions then you quite rightly say that this needs to be done for each file. Since the permissions on a file are an attribute of the file itself, it is the responsibility of the file creator to set the permissions (as opposed to the OS). On this basis, if you are receiving files uploaded through a web app, it is the responsibility of that application to set the file permissions before writing to disk.

1

This should do it after the fact (from man chmod):

chmod --recursive o-r /path

To make it happen as the files are saved, you need to use a umask. Since you don't mention which language you're using take a look at How to set umask for a specific folder for some tips.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.