From:             drachma60 at ml1 dot net
Operating system: FreeBSD
PHP version:      4.3.8
PHP Bug Type:     Unknown/Other Function
Bug description:  rename acroos file systems looses ownership and permission info

Description:
------------
When renaming a file (via the "rename" function) across filesystems,
owner, group and permission information will be lost if (a) we are running
as root and (b) the file is not owned by root.

Additionally, I suspect that permission information can be lost even if
(a) we are not running as root and (b) we are running as the user who owns
the file.


Reproduce code:
---------------
<?php

// I am running as root
touch ("/tmp/testfile");
passthru ("ls -l /tmp/testfile");

chown ("/tmp/testfile", "nobody");
chgrp ("/tmp/testfile", "nobody");
chmod ("/tmp/testfile", 0);
passthru ("ls -l /tmp/testfile");

rename ("/tmp/testfile", "/tmp/testfile2");
passthru ("ls -l /tmp/testfile2");

rename ("/tmp/testfile2", "/home/testfile2");
passthru ("ls -l /home/testfile2");

?>


Expected result:
----------------
-rw-r--r--  1 root  wheel  0 Oct 10 18:53 /tmp/testfile
----------  1 nobody  nobody  0 Oct 10 18:53 /tmp/testfile
----------  1 nobody  nobody  0 Oct 10 18:53 /tmp/testfile2
----------  1 nobody  nobody  0 Oct 10 18:53 /home/testfile2


Actual result:
--------------
-rw-r--r--  1 root  wheel  0 Oct 10 18:53 /tmp/testfile
----------  1 nobody  nobody  0 Oct 10 18:53 /tmp/testfile
----------  1 nobody  nobody  0 Oct 10 18:53 /tmp/testfile2
-rw-r--r--  1 root  wheel  0 Oct 10 18:53 /home/testfile2



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

Reply via email to