Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Jan 19, 2011 10:56 am 
Offline
Newbie

Joined: Thu Jan 13, 2011 10:59 am
Posts: 3
We have a Linux box running Ubuntu 10.04. It's primary function is a web server and it is configured with (I think) a conventional LAMP stack.

Developers have access to a common directory "dev" which contains a sub directory which serves as the web root. All developers have individual SSH access.

When developers create files in the "dev" directory tree, or pull files into "dev" from a repository we want the file permissions to be rwxrwxr-x. Instead newly created files have permissions of rw-r--r--. By modifying ACLs and setting group and user id on "dev" with sticky bits etc. I have managed to get newly created files with permissions of rw-rw-r--.

I assume the problem is down to the umask configuration which is currently set using the global value of 022 in /etc/profile. I don't want to change the umask globally or for each developer to allow more relaxed default permissions.

I can't see a way of achieving what we want with ACLs and umask unless I am missing something. Surely this is a fairly common requirement for web developers working on shared projects.

Is there a preferred or recommended approach?


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 11:49 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
The Unix permissions model relies on the creator of a file being cognizant of others in their group, and setting the permissions and ownership on their files accordingly, within the group structure promulgated by the omnipresent and benevolent root and his wheel oligarchy. This, of course, is hilariously naive, almost to the point of being adorable, but we get what we get.

To effect this on newly-created files, I run a script somewhat like the following, via cron.hourly:

Code:
for sitedir in "${groupsitedirs}"
do
    if [ -d "/srv/www/${sitedir}" ]; then
        find /srv/www/${sitedir} \
            \( -path /srv/www/${sitedir}/bin -prune \) -o \
            \( -type f \! -perm 664 -exec chmod 664 "{}" \; \) , \
            \( -type d \! -perm 775 -exec chmod 775 "{}" \; \) , \
            \( \! -group $GROUPNAME -exec chgrp $GROUPNAME "{}" \; \)
    else
        echo "Directory ${sitedir} doesn't exist!"
        EXITSTATE=1
    fi
done


Hourly seems good enough, but this could be fired more often if required. If you feel led to adjust the find conditions, be very mindful of the punctuation and order of operations. I usually break it every time I try to adjust something.

(... ok, hoopycat; put the dictionary down, stfu, and gbtw...)

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 12:42 pm 
Offline
Newbie

Joined: Thu Jan 13, 2011 10:59 am
Posts: 3
Thank you hoopycat for your eloquent and articulate reply.

I had read elsewhere about setting up a cron job to modify file permissions but was hoping to avoid this. We will be pulling files into a live web root, so incorrect file permissions would break the site until the next time the cron job executed the script.

Having given this some more thought I'm not sure whether file actually need rwxrwxr-x permissions. It may be that rw-r--r-- are enough.

I will do some testing and report back.


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 4:39 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
Quote:
(... ok, hoopycat; put the dictionary down, stfu, and gbtw...)


I thought it was very well written.


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 9:51 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
dunc wrote:
Having given this some more thought I'm not sure whether file actually need rwxrwxr-x permissions. It may be that rw-r--r-- are enough.


It depends on the language, but 0644 or 0664 (-rw-r?-r---) should work fine for most files. The trick is that the actual program being executed by the system needs to be executable, but for Apache+mod_php, that's just /usr/sbin/apache2. Everything else gets read and interpreted, not "executed."

You might notice my find command prunes out a bin/ directory... I end up running a lot of Python-based apps within virtualenv containers, and each virtualenv container has its own copy of the python executable. That needs to be executable, as I found out very quickly. :-) Everything else is fine, however.

jzimmerlin: Never assign a paper to me without a firm time and word/page limit. Never. I'm a very weird student.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Thu Jan 20, 2011 12:25 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
Quote:
jzimmerlin: Never assign a paper to me without a firm time and word/page limit. Never. I'm a very weird student.


I rarely give out homework assignments these days, but now I will be extra careful not to when it comes to you :)


Top
   
 Post subject:
PostPosted: Fri Jan 21, 2011 6:32 pm 
Offline
Newbie

Joined: Thu Jan 13, 2011 10:59 am
Posts: 3
Turns out permissions of 664 are adequate. Thanks for the help and advice.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group