rename across filesystems loses ownership and permission info
| Bug #30388 | rename across filesystems loses ownership and permission info | ||||
|---|---|---|---|---|---|
| Submitted: | 2004-10-11 04:00 UTC | Modified: | 2004-10-27 14:06 UTC | ||
| From: | drachma60 at ml1 dot net | Assigned: | tony2001 (profile) | ||
| Status: | Closed | Package: | Filesystem function related | ||
| PHP Version: | 4.3.8 | OS: | FreeBSD | ||
| Private report: | No | CVE-ID: | None | ||
[2004-10-11 04:00 UTC] drachma60 at ml1 dot net
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-10-11 04:06 UTC] drachma60 at ml1 dot net
[2004-10-23 13:56 UTC] tony2001@php.net
[2004-10-27 14:06 UTC] tony2001@php.net