LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-21-2005, 10:19 PM   #1
Influx
LQ Newbie
 
Registered: Sep 2005
Location: Canada
Distribution: Slackware 10.2
Posts: 27

Rep: Reputation: 15
Apache/PHP - can't write file


Not sure if i'm asking in the right place, but I just installed apache and php (from linuxpackages.net), everything is running fine as I can tell, but my scripts I made and ran in windows no problem, in linux it's not writing to file. Do I have to set up permission somewhere? Can someone help a newb. Thanks :|

Here's an example script that I'm playing with:

Code:
<?
$redirect = $_SERVER['PHP_SELF'];
echo "ready..";

if (isset($_POST['thetxt'])) {
	$da = "test.php";
	touch($da);
	$wr = fopen($da, "w");
	fwrite($wr, $_POST['thetxt']);
	fclose($wr);
	echo "wrote to <a href=$da>$da</a><br>";
}
?>
<form name="write" method="post" action="<? echo $_SERVER['PHP_SELF'] ?>">
<textarea name="thetxt" rows="30" cols="50"></textarea><br>
<input type="submit" name="go" value="Go">
</form>
<?
?>
Just so you get the idea of what the problem is.
 
Old 10-22-2005, 01:08 AM   #2
tedfordgif
Member
 
Registered: Dec 2003
Posts: 43

Rep: Reputation: 15
The most trivial way to get this to work (and be sure it's a privilege issue) is do just what the php code does (almost):
su -
touch $file
chmod a+w $file
chown nobody:nobody $file

The last line is optional. It's not smart, but it should eliminate any permissions issues. Then you will want to delete that file.
 
Old 10-22-2005, 05:50 AM   #3
Influx
LQ Newbie
 
Registered: Sep 2005
Location: Canada
Distribution: Slackware 10.2
Posts: 27

Original Poster
Rep: Reputation: 15
so I changed the group of the file to nobody, and allowed write access for group, and it seems to work. Now my question is, is this a security concern now that I have a text that will be read from/written to? What should I be worried about here?
 
Old 10-23-2005, 10:50 PM   #4
tedfordgif
Member
 
Registered: Dec 2003
Posts: 43

Rep: Reputation: 15
Yes, there are security concerns. At the very least, an attacker may be able to execute arbitrary PHP code, allowing them to probe for other weaknesses on your system, perform an exploit against your application, etc.

What need are you trying to fill?
 
  


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/PHP can't write to /tmp dir. Niels@debian Linux - Software 2 05-25-2005 03:10 PM
Red Hat 9 server can't write PHP script, problem in httpd.conf file? x_menno_x Linux - Newbie 27 06-29-2004 04:44 PM
Apache 1.3.28/PHP 4.3.3 can't write temp file tm_burningdog Linux - Software 0 06-10-2004 01:49 PM
php script can not write text file lemotion Linux - Newbie 5 04-20-2004 10:14 PM
file permissions w/apache php caguru Linux - Newbie 3 04-26-2001 07:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:58 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