Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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