From:             arnaud dot lb at gmail dot com
Operating system: Linux
PHP version:      5.2.4
PHP Bug Type:     Filesystem function related
Bug description:  Unable to chown/chgrp of a symlink

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 bug report at http://bugs.php.net/?id=42711&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42711&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42711&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42711&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42711&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42711&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42711&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42711&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42711&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42711&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42711&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42711&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42711&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42711&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42711&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42711&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42711&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42711&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42711&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42711&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42711&r=mysqlcfg

Reply via email to