LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-12-2005, 12:03 PM   #1
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Apache and File Permissions


On most systems, Apache is installed to run as user nobody and group nobody. Or user httpd and group httpd. Or something along those lines. This prohibits us from leaving files for our website with 700 permissions, correct? (Apache must be able to read those files) However, this means that all users on the system can also read those files. What can be done to mitigate this risk? For example, php scripts often have mysql usernames and passwords in them. How can I allow apache access without destroying security? Are ACLs the only effective option?
 
Old 08-12-2005, 03:01 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
You could change the group of the files to the group of the httpd user (i.e. nobody or httpd); and then give 750 (or 640) permissions. Hopefully, no regular users will be in that group.

Alternately (but less good), you can create a group that all users are in (e.g. "users") and change the group of the files to that group and then give 705 (or 604) permissions.

Also, for security, when Apache doesn't need to list a directory (e.g. to create an index when there is no index.html), you should not give it read permission to that directory. Execute permission is sufficient for it to access the files underneath without allowing it to list the directory.
 
Old 08-12-2005, 03:14 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Original Poster
Rep: Reputation: 128Reputation: 128
I think your description of read/execute on directories is backwards, but I may be wrong. I'll double check later.

Additionally, I think 705 would still give all users permission to read, through the "other" value. Again, I could be wrong, but it would be logical.

chgrp returns "Permission denied" when chgrpping to nobody, so I'm not sure that avenue is possible.

This isn't critical, but just a matter of curiousity that one would think would've been more explored before now with the ubiquity of the apache server.
 
Old 08-12-2005, 03:29 PM   #4
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
"chgrp" only allows you to change to a group of which you are a member (and I wouldn't think you are in nobody), so you probably have to do it as root.

As an alternative, you can create another group (e.g. "www") and put "nobody" and you in it and use that. The advantage of this is that you can allow other people to access the files by putting them in this group.
 
Old 08-12-2005, 03:34 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Original Poster
Rep: Reputation: 128Reputation: 128
Yes, but if all web users are in that group, wouldn't that defeat the purpose of chgrouping them? Then all webusers could read it again.
 
Old 08-12-2005, 08:55 PM   #6
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
By web users I just meant the people who need to adminstrate your PHP scripts and stuff (which is probably just you). Other users don't need access to it.
 
Old 08-13-2005, 12:22 AM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Original Poster
Rep: Reputation: 128Reputation: 128
Yes, but my original question was regarding a shared server?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache file permissions tntcoder Linux - Newbie 2 08-23-2005 06:50 PM
File Permissions with Apache Herbalist Linux - Networking 5 06-17-2005 01:39 PM
File permissions with apache deee Linux - Newbie 3 03-31-2004 02:24 PM
Apache and File Permissions notstrider Linux - Networking 1 03-14-2003 11:44 AM
Apache permissions and file locations yesyes125 Linux - Software 1 05-10-2002 11:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration