Switch groups in mid-session
my regular login is a member of 2 groups. My default group is 'users' whereas the other is 'apache' which I created a while ago. All files under my webserver doc root have been chgrp-ed to apache and chown-ed to root. Although it doesnt matter, root also happens to be a member of apache. The httpd daemon runs as 'nobody' and accesses the doc root using the 'world' permissions r-x. All is well and good.
As you can see from below, the only logins who have write access to this folder are members of the group 'apache' apart from root. When I create a new file ( touch test.file ) it goes under 'users' instead of 'apache' as I had expected. This defeats the purpose for which the group 'apache' was created in the first place. Is there a way that I can switch over to apache (and thereby assume a web-admin personality ) when I am modifying the doc-root contents? I dont mind doing this via a command ( since I dont want to change my default group ) . The idea is to avoid having to chown, chmod etc for another non-root-apache-member to modify the files I have messed around with.
$ls -al /var/www/html/
-rwxrwxr-x 1 root apache 14k Sep 29 11:19 cimap.html*
drwxrwxr-x 2 root apache 4.0k Oct 21 02:31 css/
drwxrwxr-x 5 root apache 4.0k Oct 21 14:53 dvb/
drwxrwxr-x 2 root apache 4.0k Jul 21 18:03 errors/
drwxrwxr-x 2 root apache 4.0k Oct 21 10:30 images/
-rw-rw-r-- 1 root apache 1.1k Oct 21 02:23 index.php
drwxrwxr-x 3 root apache 4.0k Sep 30 01:06 manual/
drwxrwxr-x 2 root apache 4.0k Oct 21 01:46 php/
drwxrwxr-x 2 root apache 4.0k Oct 21 14:53 ramu/
-rw-rw-r-- 1 root apache 1.7k Sep 26 00:09 sysInfo.html
-rw-rw-r-- 1 root apache 346 Sep 29 09:08 thud2.html
-rw-rw-r-- 1 root apache 1.9k Sep 28 22:36 thud.html
drwxrwxr-x 2 root apache 4.0k Sep 30 01:09 wordtrans/
Try using "chmod g+s" on the docroot and any other subdirectories. This should force new files to pickup the group id of the parent directory.
Thanks stickman. That worked. Just out of curiosity.. is there a way that I can switch gid's in mid session?
Thanks moses. Just what I was looking for.
|All times are GMT -5. The time now is 02:00 AM.|