php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1527 Apache module, safe mode enabled, touch() function
Submitted: 1999-06-11 10:45 UTC Modified: 1999-06-20 21:00 UTC
From: webmaster at abdn dot ac dot uk Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.9 OS: Solaris 2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at abdn dot ac dot uk
New email:
PHP Version: OS:

 

 [1999-06-11 10:45 UTC] webmaster at abdn dot ac dot uk
Problem: Running Apache 1.3.6 with php module compiled in, safe mode is enabled (httpd.conf contains line: php3_safe_mode On). 

The .php3 file reads thus (plus some HTML lines):

<?php
   echo touch("/home/users/myid/testfiles/junk.txt"); 
?>

When executed via Apache php3 module, the above script prints "1" and CREATES the file junk.txt. Apache is running as userid "myid" but the script belongs to another login. Attempts to use functions such as "file()" correctly (as I understand the documentation of safe mode) report:
===
Warning: SAFE MODE Restriction in effect. The script whose uid is 7921 is not allowed to access
 /home/users/myid/testfiles/files.txt owned by uid 7917 in /home/users/otherid/public_html/php/test.php3 on line 9
===
when the script is:

<?php
$file = file("/home/users/myid/testfiles/files.txt");
for ($i = 1; $i <= count($file); $i++) {
     echo $file[$i];
}
?>                                                    

I understood that all file i/o functions in safe mode disallowed access to files other than those owned by the same login as the script being executed. The touch() function appears to disobey this rule.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-20 21:00 UTC] jim at cvs dot php dot net
php can only create files owned by the user that Apache
is running as (usually 'nobody'), which means that when
safe mode is enabled, you can't use files that you can
create. You need to use something like cgiwrap or suexec
to get around this.
 [2022-04-19 12:13 UTC] git@php.net
Automatic comment on behalf of saundefined
Revision: https://github.com/php/doc-en/commit/f646d66e39908c69b50ade8c3a593b013de5cd0b
Log: Fix omitted colon
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 14:01:30 2024 UTC