Atmosphere

  • PHP -V output: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May 2 2011 23:00:17) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3., Copyright (c) 1998-2010 Zend Technologies
  • cat /etc/problem output: Ubuntu 11.04
  • Apache2 -V ouput: Server version: Apache/2.2.17 (Ubuntu) Server built: Sep 1 2011 09:31:14
  • Browser About output: Opera 6..2

PS -AUX Ouput

root      2943  0.0  0.3 206420 12428 ?        Ss   Sep19   0:20 /usr/sbin/apache2 -k start
www-data 18658  0.0  0.2 208552 11096 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18659  0.0  0.3 208976 12036 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18660  0.0  0.3 210532 12476 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18661  0.0  0.3 210276 11820 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18662  0.0  0.2 206948 10236 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 20037  0.0  0.3 208976 12128 ?        S    08:22   0:00 /usr/sbin/apache2 -k start
www-data 20039  0.0  0.3 209132 11748 ?        S    08:23   0:00 /usr/sbin/apache2 -k start
www-data 20120  0.0  0.3 209004 12000 ?        S    09:04   0:00 /usr/sbin/apache2 -k start

File Permissions

drwxr-xr-x 2 www-data www-data   4096 2011-09-26 15:24 .
drwxr-xr-x 4 www-data www-data   4096 2011-08-26 11:31 ..
-rw-r--r-- 1 root     root     161976 2011-08-26 16:26 market.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test1.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test2.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test3.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test4.txt
-rw-r--r-- 1 root     root          0 2011-09-26 15:02 test5.txt

Code

rename($file, "$dest/$file");

Question

After I run the above mentioned code around the files indexed by the File Permissions section above, it correctly moves the file from the current location to an alternative location and removes the initial. How's this possible when apache2 is running as world wide web-data and also the files are possessed by root and just read access for non-root customers? Around the PHP documentation it states:

Alerts might be produced when the destination filesystem does not permit chown() or chmod() system calls to become made on files — for instance, when the destination filesystem is really a Body fat filesystem.

Does relabel() call either of individuals system functions throughout the procedure? If that's the case, why? Not it matters anyway as world wide web-data shouldn't have the ability to chown/chmod personal files possessed by root anyway.

Can anybody show me how this really is happening?

More Information

  • I've attempted this using the PHP script possessed by root by world wide web-data and delay pills work.

I attempted to supply just as much pertinent info as you possibly can but tell me if you want other things.

Moves don't "remove" originals, unless of course the move happens across filesystem limitations. Inside a single filesystem, a move simply rewrites the appropriate directory records therefore it Seems that you have replicated/erased the file, but all you have done is a little of housekeeping. Since world wide web-data is the owner of the sites under consideration, it may rewrite your directory records representing individuals files all it wants, and not touch the particular files.

When moving files you aren't editing the files themselves, but instead your directory they are members of. Inside your situation that directory is possessed by www-data (the apache process)