ID:               42711
 Updated by:       [EMAIL PROTECTED]
 Reported By:      arnaud dot lb at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Filesystem function related
 Operating System: Linux
 PHP Version:      5.2.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You need to use the lchown() function.


Previous Comments:
------------------------------------------------------------------------

[2007-09-19 14:17:09] arnaud dot lb at gmail dot com

Description:
------------
There is no way to change the owner or group of a symlink.

Using chown and chgrp functions on a symlink affect the file 
referenced by the symbolic link, rather than the symbolic link 
itself.

There should have a "$dereference" argument to be able to affect the 
file referenced by the symlink or the symlink itself.

Reproduce code:
---------------
<?php
// Setup test files
if (file_exists('test-referent')) unlink('test-referent');
if (file_exists('test-symlink')||is_link('test-symlink'))
unlink('test-symlink');
touch('test-referent');
symlink('test-referent', 'test-symlink');
echo shell_exec('chown -h nobody test-symlink test-referent 2>&1');

echo "Original owners: \n";
echo shell_exec("ls -l test-referent test-symlink") . "\n";

// Test changing symlink owner with PHP's chown() function

chown('test-symlink', 'root');

echo "New owners: \n";
echo shell_exec("ls -l test-referent test-symlink");
?>

Expected result:
----------------
chown should affect symlink owner instead of the referenced file

Original owners:
-rw-r--r-- 1 nobody root  0 2007-09-19 16:04 test-referent
lrwxrwxrwx 1 nobody root 13 2007-09-19 16:04 test-symlink -> 
test-referent

New owners:
-rw-r--r-- 1 nobody   root  0 2007-09-19 16:04 test-referent
lrwxrwxrwx 1 root root 13 2007-09-19 16:04 test-symlink -> 
test-referent

Actual result:
--------------
chown has affected the referenced file instead of the symlink itself

Original owners:
-rw-r--r-- 1 nobody root  0 2007-09-19 16:04 test-referent
lrwxrwxrwx 1 nobody root 13 2007-09-19 16:04 test-symlink -> 
test-referent

New owners:
-rw-r--r-- 1 root   root  0 2007-09-19 16:04 test-referent
lrwxrwxrwx 1 nobody root 13 2007-09-19 16:04 test-symlink -> 
test-referent


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42711&edit=1

Reply via email to