From:             rusxakep at gmail dot com
Operating system: Linux 2.6.29
PHP version:      5.2.10
PHP Bug Type:     Filesystem function related
Bug description:  file_exists under unprivileged user with set user ID on 
execution fails

Description:
------------
1. Create and save to /home/user this next short program:
#define REAL_PATH "/home/user/test.php"
main(ac, av)
     char **av;
{
  execv(REAL_PATH, av);
}

2. Compile cc -o test test.c
3. chown root.root test and chmod 6755 test
5. Create test.php
#!/usr/bin/php-cgi -q
<?php
if (!file_exists("/home/user/2/3")) mkdir ("/home/user/2/3",0700,true);
?>
6. chown root.root test.php and chmod 0755 test.php
7. chmod 1777 /home/user
7. run with any unprivileged user:
su - user -c "/home/user/test"

First run ok, creating directory with root access
Second run failed with next error message:

Warning: mkdir(): File exists in /home/user/test.php on line 3

Reproduce code:
---------------
no safe mode, default php.ini

Expected result:
----------------
Empty exit w/o warning

Actual result:
--------------
Warning: mkdir(): File exists in /home/user/test.php on line 3

-- 
Edit bug report at http://bugs.php.net/?id=49049&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49049&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49049&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49049&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49049&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49049&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49049&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49049&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49049&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49049&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49049&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49049&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49049&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49049&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49049&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49049&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49049&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49049&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49049&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49049&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49049&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49049&r=mysqlcfg

Reply via email to