From:             ksvee at usit dot uio dot no
Operating system: Solaris 8
PHP version:      4.3.8
PHP Bug Type:     *Directory/Filesystem functions
Bug description:  Wrong script uid with safe_mode

Description:
------------
This is really an old bug that seems to be coming and going, but I cannot
find an open bug on it. 

References: bugs #18500, #12683 and #7744

The latest version that this bug is not alive and well is 4.2.3 which is
the one we still use. I've tested (just about) every (release) version
since, and reproduced the bug in all of them. That includes the latest
(4.3.8) tested today, 2004-07-16. I use PHP with Apache 1.3.x (1.3.31
latest).


Description:

When using SAFE_MODE = ON, php reports uid=1 on the running php-script as
well as its proper uid:

-----
[datetag] [error] PHP Warning:  Unknown(): SAFE MODE Restriction in
effect.  The script whose uid is 1 is not
 allowed to access /path/to/script.php owned by uid 26658 in Unknown on
line 0
-----

If I chown the script to another user, e.g. root, the report looks like
this:

-----
[datetag] [error] PHP Warning:  Unknown(): SAFE MODE Restriction in
effect.  The script whose uid is 1 is not allowed to access
/path/to/script.php owned by uid 0 in Unknown on line 0
-----

If i chown it to uid=1 ('daemon' on my systems) then it seems to work,
except that the file I intend to include also needs to be owned by daemon.
This included file at least seems to have its owner reported correctly, the
full report being:

-----
[datetag] [error] PHP Warning:  main(): SAFE MODE Restriction in effect. 
The script whose uid is 1 is not allowed to access ./filename.inc owned by
uid 26658 in /a/b/c/include.php on line 2
[datetag] [error] PHP Warning:  main(filename.inc): failed to open stream:
Error 0 in /a/b/c/include.php on line 2
[datetag] [error] PHP Warning:  main(): Failed opening 'filename.inc' for
inclusion (include_path='.') in /a/b/c/include.php on line 2
-----

We usually use a non-standard config, compiling Apache, PHP, OpenSSL etc
under a specific prefix, but dumbing this to default paths has no impact.


Using "--with-apxs=/path/to/apxs --prefix=/path/to/installprefix" as the
only config parameters to PHP too has no impact on the results.

As for php.ini, I've tried using a clean copy of both
"php.ini-recommended" and "php.ini-dist" with no other modifications than
setting "safe_mode = On". No significant changes.


Rgds,
Kenneth Svee


Reproduce code:
---------------
# Content of include.php:
<?php
include("filename.inc");
?>

# (filename.inc is in same dir as include.php, and
# contains just an arbitrary string, e.g.:
"I've been included!"

Expected result:
----------------
# I expected the string in filename.inc:
"I've been included!"

Actual result:
--------------
Just the empty page, and the errormessages in Apaches error_log.

-- 
Edit bug report at http://bugs.php.net/?id=29207&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29207&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29207&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29207&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29207&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29207&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29207&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29207&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29207&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29207&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29207&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29207&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29207&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29207&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29207&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29207&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29207&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29207&r=float

Reply via email to