#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    165
    Rep Power
    11

    File's group changing when replaced via scp


    Hello,

    on my Fedora test server, there is a webdev group for all developers and the files under /var/www are owned by apache:webdev. Each developer is set up per normal, with each getting his/her own entry in /etc/group, then I add them to the webdev group (all from the command line). Things seemed OK, but when I edited a file as me the other day and updated it via scp, the ownership and group changed to that of my user, preventing a second dev from updating it later. How can I make sure that the file remains editable by all in the webdev group regardless of who updates it? Since it's a test server, the permissions are fairly loose at 775.

    Thanks,
    Mike
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Minneapolis, MN
    Posts
    356
    Rep Power
    12
    What you want to do is a combination of things.

    First, make sure all existing files/dirs have the correct ownership:
    Code:
    # chgrp -R webdev /var/www
    Next, make sure all the files are group writable:
    Code:
    # find /var/www -type f -exec chmod 664 {} \;
    Now, set the group id bit on all the directories under /var/www and make them group writable at the same time:
    Code:
    # find /var/www -type d -exec chmod 2775 {} \;
    The last thing to do is either have everyone modify their umask in the ~/.bash_profile or ~/.bashrc file (recommended) or change the global umask in /etc/profile (not the best idea). They both accomplish the same thing, but having people do this themselves makes them a little more aware of what it does. In the user's ~/.bash(rc|_profile) file, set the umask to all writing by group by default by adding this line:
    Code:
    umask 002
    That should do it. Now, when someone creates a file or directory anywhere it will be set to 664 for files or 775 for directories. Beyond that, with the setgid bit set on all the directories under /var/www, anytime a file or directory is created it, will inherit the parent directory's group.
    badger badger badger badger
    badger badger badger badger
    MUSHROOM MUSHROOM
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    165
    Rep Power
    11
    Thanks Crusty. I got lazy and just added the other users to my regular user group in /etc/group. I'll revisit your solution down the road.

    Mike

IMN logo majestic logo threadwatch logo seochat tools logo