Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-10-2006, 09:31 PM
|
#1
|
Member
Registered: Aug 2003
Distribution: Debian
Posts: 53
Rep:
|
Apache user directories permissions
I have been trying to find out about security in users public_html directories. I am running Debian 3.1 as a test web host. I use my /home/oliver/public_html directory for my php scripts etc. For them to run, everybody needs to have at least read permitions, and I am guessing 'write' too if I want my php scripts to be able to write to that folder. Then what is stopping other users on the system from reading and editing my files? If they can, how can I stop them from doing so?
|
|
|
07-11-2006, 02:14 PM
|
#2
|
LQ Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094
|
I would say that you should probably put the php scripts in a separate directory if possible. I don't remember if you can use symbolic links to point them. If not, you can mount that folder on loopback for each user and point all users to the same directory. Your fstab line would look something like this if I remember correctly
Code:
/var/www/html/phpdir /home/oliver/public_html/phpdir ext3 defaults,rw,loop 0 0
/var/www/html/phpdir /home/joeblow/public_html/phpdir ext3 defaults,loop 0 0
Then make sure everyone is a member of that group and give rw permissiont to /var/www/html/phpdir.
|
|
|
07-11-2006, 07:17 PM
|
#3
|
Senior Member
Registered: Aug 2005
Posts: 1,755
Rep:
|
I don't know about PHPs, but I know for CGIs there is suEXEC which runs them under the user's UID, so it can do exactly the things the user can do.
|
|
|
07-14-2006, 10:30 AM
|
#4
|
Member
Registered: Aug 2003
Distribution: Debian
Posts: 53
Original Poster
Rep:
|
Thanks
I don't understand the fstab file, I'll have to look into that. But if I understand what you're suggesting, everybody will still be able to edit each others scripts?
I read about FastCGI with suEXEC which sounds good but setting that up is beyond my abilities, and I am wondering how ISP's do it. Where my ISP seams to have a folder for each user under /home and we can run PHP scrips. I always though they used mod_php for apache. I used to think mod_php or mod_userdir had some security features built in for this, but I can't seam to find them
Last edited by Wordan; 07-14-2006 at 10:34 AM.
|
|
|
07-14-2006, 11:28 AM
|
#5
|
Member
Registered: Jun 2005
Location: Chicago, IL, USA
Distribution: Fedora Core, CentOS
Posts: 188
Rep:
|
Sounds complicated. Setting up PHP scripts for all of the users to see will be quite difficult given the fact that a user's folder is supposed to be accessible only to her and root. Try to placing the script files somewhere that is globally accessible by users like /scripts and make sure that the intended users and apache has read and/or write access to it.
How does that sound?
|
|
|
07-14-2006, 01:19 PM
|
#6
|
Member
Registered: Aug 2003
Distribution: Debian
Posts: 53
Original Poster
Rep:
|
Thinking of a multiuser server, where everybody has a public_html directory and can host php scripts.
For example: A user creates a php script that needs to write and edit files (under their public_html directory)
That directory and the files in it would need read and writable permitions so the webserver can see and edit them. You'd acheive that by setting the 'other' permitions to writable, or 'group' if the files belongs to a group the webserver belongs to.
Either way everybody else can now write and modify these files one way or another, either through the shell or making a php script that runs with the webservers permitions. I think?
Also, what about scripts or files which have MySQL database password in them etc. Now they can be read by everyone.
The only way I can see this working is if the webserver restricts php scripts from doing things outside of its owner's directory, and each user gives permitions for their files only to the webserver for their files using a group the webserver belongs to.
Not sure where I'm going with this, I'm just trying to understand how it works, and how I'd set up that multiuser server.
Last edited by Wordan; 07-14-2006 at 01:20 PM.
|
|
|
07-14-2006, 02:15 PM
|
#7
|
Member
Registered: Jun 2005
Location: Chicago, IL, USA
Distribution: Fedora Core, CentOS
Posts: 188
Rep:
|
Quote:
Thinking of a multiuser server, where everybody has a public_html directory and can host php scripts.
|
I'm assuming that's already completed.
Quote:
For example: A user creates a php script that needs to write and edit files (under their public_html directory)
|
I'm assuming that evey administrator who sets up Apache can manage that
Quote:
That directory and the files in it would need read and writable permitions so the webserver can see and edit them.
|
1.Apache has read capabilities on the /home/*/public_html/ folder
2.Write permissions for apache can be acheived by making the apache group the owning group for the file and giving write access to that folder.
[code]
chown -R ug+rwx /home/*/public_html/scripts/
Quote:
You'd acheive that by setting the 'other' permitions to writable, or 'group' if the files belongs to a group the webserver belongs to.
|
I don't know what this means.
[QUOTE]
Quote:
Either way everybody else can now write and modify these files one way or another, either through the shell or making a php script that runs with the webservers permitions. I think?
|
If you aren't sure then you should make sure. You are the administrator so know your territory.
Quote:
Also, what about scripts or files which have MySQL database password in them etc. Now they can be read by everyone.
|
That's true.
Quote:
The only way I can see this working is if the webserver restricts php scripts from doing things outside of its owner's directory, and each user gives permitions for their files only to the webserver for their files using a group the webserver belongs to.
|
1.If the script wasnt written to make files outside of the /home/*/public_html folder then it won't. If it tries then it can only attempt to write where Apache has write access.
2.The latter occurs by default.
Quote:
Not sure where I'm going with this, I'm just trying to understand how it works, and how I'd set up that multiuser server.
|
If you don't know where you are going how can you ask for help and effectively participate in the solution finding process? There are plenty of manuals available at libraries and bookstores. Pick one up!
|
|
|
07-14-2006, 02:49 PM
|
#8
|
Member
Registered: Aug 2003
Distribution: Debian
Posts: 53
Original Poster
Rep:
|
Not sure what you're getting with all you're comments to each of my sentences... I think you read my post out of context... I was just elaborating on my first post because I wasn't sure I made sence. Besides this is a 'discussion' forum and if you're not interested in what I am trying to discuss or figure out, then don't bother writing in this thread.
I want to know how to run php scripts in users directories with out users being able to interfear with each others files.
at the moment, on debian sarge, my public_html files need to be world readable
|
|
|
07-14-2006, 03:40 PM
|
#9
|
Member
Registered: Jun 2005
Location: Chicago, IL, USA
Distribution: Fedora Core, CentOS
Posts: 188
Rep:
|
Why the defense? I broke your comment down because I coudln't understand what was what was being requested in the clarification. If one wants to discuss but doesn't understand one's topic then there's a major problem that needs to be addresses. That was the form in which I addressed it.
I also apologize for posting to your "discussion" forum. I didn't mean to walk next to the tree you pissed on.
Have fun with your Apache setup. I'm sure that your foundation in Apache will benefit from "discussion."
|
|
|
07-14-2006, 04:42 PM
|
#10
|
Member
Registered: Aug 2003
Distribution: Debian
Posts: 53
Original Poster
Rep:
|
Because it looked like you attacked my post. What's wrong with a bit of discussion anyway? I'm not discussing my foundation in Apache.
Last edited by Wordan; 07-14-2006 at 04:51 PM.
|
|
|
All times are GMT -5. The time now is 05:44 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|