LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-20-2007, 06:25 PM   #1
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Rep: Reputation: 15
Possible to include /etc/folder/file.usr


I made a PHP script to edit a config file for my server, so I don't have to login to the console every time I need to edit it. The only problem I'm having is I can't get my script to open this file. I have added the /etc/folder to my open_basedir and all I get is Permission Denied.

This is what I get:

Quote:
Warning: main(/etc/folder/file.usr) [function.main]: failed to open stream: Permission denied in /var/www/sites/bla/file.php on line 11

Warning: main() [function.include]: Failed opening '/etc/folder/file.usr' for inclusion (include_path='/etc/folder') in /var/www/sites/bla/file.php on line 11
I have tried to CHMOD and CHOWN and it still don't seem to work. Is this maybe because it's the system folder? If I moved the files to /home would it be able to include?
 
Old 06-20-2007, 06:40 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I'm not an expert in web servers, but maybe it is running in a webroot (jail) and can't reach the system's /etc/folder file. Or does this /etc/ folder exist in the jail?
 
Old 06-20-2007, 06:43 PM   #3
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Original Poster
Rep: Reputation: 15
It should be able to reach it just fine as I added /etc/folder to my open_basedir (meaning it has access to /etc/folder) I'm just confused as to why it won't read
 
Old 06-20-2007, 06:53 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I had to google a bit.
Quote:
In httpd.conf, open_basedir can be turned off (e.g. for some virtual hosts) the same way as any other configuration directive with "php_admin_value open_basedir none"
What are the permissions and ownership of the file?
Quote:
Originally Posted by http://us2.php.net/features.safe-mode
When safe_mode is on, PHP checks to see if the owner of the current script matches the owner of the file to be operated on by a file function or its directory. For example:

-rw-rw-r-- 1 rasmus rasmus 33 Jul 1 19:20 script.php
-rw-r--r-- 1 root root 1116 May 26 18:01 /etc/passwd



Running script.php:
<?php
readfile('/etc/passwd');
?>
results in this error when safe mode is enabled:

Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not
allowed to access /etc/passwd owned by uid 0 in /docroot/script.php on line 2

 
Old 06-20-2007, 07:27 PM   #5
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Original Poster
Rep: Reputation: 15
Hey thanks for your help..My whole problem was /etc/folder wasnt CHMODed to 777, but only file.usr was. I did a CHMOD /etc/folder and now it works! Thanks for your help though!
 
Old 06-21-2007, 02:55 AM   #6
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
HEY!! Don't chmod your folder to 777... That is not a good thing. (especially if you say you're running a web server).
 
Old 06-21-2007, 02:58 AM   #7
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Original Poster
Rep: Reputation: 15
I could take it off if I knew how to get rid of the Permission Denied error
 
Old 06-21-2007, 04:59 AM   #8
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
Apache runs with some UID. I am not sure which UID php uses, but my best guess is that it uses the same UID as the server it runs under. So, chown the folder to this uid, and chmod it to 755, or to 555, if the script doesn't need to modify it's contents.
 
Old 06-22-2007, 12:16 AM   #9
ballistic509
Member
 
Registered: Feb 2006
Distribution: CentOS
Posts: 114

Original Poster
Rep: Reputation: 15
Thank you! That works just as well and more secure since it's not 777 anymore. I attempted this before (with apache UID) but I still got permission denied. It worked this time though. Thanks much!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
which headers usr/include/ or /usr/include/nptl/? Chris.Rector Linux - Enterprise 0 02-02-2007 01:40 PM
/usr/include/rpm: No such file or directory powah Red Hat 3 10-31-2006 10:27 AM
how do I chown a PHP file on /usr/ to allow EVERYONE to include it? cpanelskindepot Programming 2 07-16-2004 03:36 PM
/usr/include/netdb.h on RH 8.0 nxny Red Hat 2 12-09-2003 05:16 PM
Clarifiacation on header file "/usr/include/a.out.h" swathisat Linux - Software 0 09-05-2003 12:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 AM.

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