Monday, January 23, 2006

Permission trick

In case a daemon (dae) and a user (joe) have concurrent access to a directory (refered as dir) and both want to get read/write, here's a trick that can do:
  1. Create a group (shared in this document).
  2. chown -R dae:shared dir or chown -R joe:shared dir
  3. chmod -R 2775 (resp. 2770) dir
Then make sure to use umask 002 as a user or have the daemon or program operate with group-writeability. The setgid properties allow for inheritage of the group when creating folders/files within. (Test & FIX: setgid gets inherited or is it only in case of 2760 mode - appears then with a capital 'S').

The directory tree should be read/write for all and only the user will change, depending on if it is the user or the program that created the file/directory.