2

Does it exist?

I create a folder with, let's say, all permissions set, and some services (i.e. Apache web server) create subfolders and put files there (uploaded media files from website users). Such subfolders have permissions set so that only www-data (Apache user) can write to them.

My problem arises because I have a script which has to be able to create subfolders and files, the same way as Apache does. But when it tries to write a new file to an existing folder created by Apache, it can't because of the permissions.

Is there any way in Linux (Ubuntu distro) to set so that a newly created subfolder inherits same permissions as parent folder?

I have been reading a while about guid, sticky bits and so, but I am not very savvy in sysadmin, and, in the middle of a rush of work, this whole thing overwhelmes me...

I am using python and mod-wsgi, if this information is useful in any way.

Thanks!

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
  • 1
    Have a look at this similar question: http://unix.stackexchange.com/questions/18729/permissions-of-webservers-root-directory – Stéphane Gimenez Nov 18 '11 at 21:11
  • Why would you want to do this? If you chmod a directory to 0700, other users won't be able to get at anything below it, regardless of their permissions. – amphetamachine Nov 19 '11 at 00:01
  • Is your script running also from the web, as in a webpage or something, or are you running it from CLI? – reiche Aug 15 '12 at 07:05

1 Answers1

1

I don't know whether this is the best ownership and permission policy for your setup. Here's how to implement it.

From what I understand, you want several system users to be able to access and write to a set of files, and you want newly created files to automatically have the correct permissions. This is possible with access control lists, and not really feasible without.

This answer explains how to set up your system for ACLs and what permissions to give to the shared directory.