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.

Simple permissions question.

I want the www user to have read write access to a subfolder in my home folder. Obviously, I want to be able to use it too!

I know I can execute:

sudo chown -R www:www /Users/myusername/subfolder

But I fear that that will mean that www owns it, rather than me. How do I make this work?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Set an access control list on that directory tree, granting www the right to access and modify the files and directories in that tree. You'll also need to make sure that www can traverse the directories down to the specified subfolder.

chmod +a 'user:www allow search /Users/myusername'
chmod -R +a 'user:www allow delete,list,search,add_file,add_subdirectory,read,write' /Users/myusername/subfolder

See the chmod(1) manual page for more information. You may want to tweak the access control list to give different permissions.

share|improve this answer

Change only group to www, and grant write permissions to group, I mean:

sudo chgrp -R www /Users/myusername/subfolder
sudo chmod -R g+w /Users/myusername/subfolder
share|improve this answer

As others have said, there are a few approaches. You are right to worry about ownership, you probably don't want that. You're better off with the group approach,

chgrp -R www /Users/myusername/subfolder
find /Users/myusername/subfolder -type d | xargs chmod g+rwxs     
find /Users/myusername/subfolder -type f | xargs chmod g+rw 

The setuid bit is to force the group to be www on anything created under it. Remember because of the way that UNIX does searches, www group needs r-x on /Users/myusername as well

I question write access. Its usually not good to let it have write access. If this is internal only, ok, but if your webserver gets compromised, normal security is to have it not be able to write anywhere but /tmp/.

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.