2

3 users, 1 folder. Users: vsftpd (FTP server), bobmarley (normal user), www-data (Apache user)

How to unite them and make so that each user can modify any of these user's data, without doing CHMOD 777?

Ex.: bobmarley created a file 'settings.inc.php' www-data tries to access the file, and succeeds. vsftpd user accesses the file and can modify it, too.

alryaz
  • 21
  • 1

4 Answers4

4

Create a group (groupadd)... chgrp of the directory to that new group... and then add each user to that group. That's the easiest way. You may also want to chmod g+s on the directory to make sure that new files are created with the same group as the parent directory.

tadaa!

TheCompWiz
  • 7,409
  • 17
  • 23
2
groupadd webapp
usermod -a -G webapp vsftpd (but I think it should be nobody)
usermod -a -G webapp bobmarley
usermod -a -G webapp www-data
chgrp -R webapp /path/to/folder
chmod -R g+w /path/to/folder

If you have existing data in this folder, you can set SGID for all sub-folders with:

find /path/to/folder -type d -print0 | xargs -0 chmod g+s /path/to/folder

Remember to set the umask for vsftpd, Apache and bobmarley to 002. With this config, all files created by any user will has 664 permission, owned by webapp group, and other users can modify.

quanta
  • 51,413
  • 19
  • 159
  • 217
1

Put them all in a common group. chgrp the files to that group. chmod the files/dirs to 664/775.

Ingmar Hupp
  • 606
  • 1
  • 6
  • 13
0

Group them. This is why there are groups in POSIX. Create a group xyz and put vsftpd, bobmarley and www-data into it.

And then assign the group to the folder/files with chgrp.

mailq
  • 17,023
  • 2
  • 37
  • 69