On Thu, Apr 23, 2009 at 13:21, Christoph Boget
<christoph.bo...@gmail.com> wrote:
> Is there a reason why you can't programatically set ownership of a
> symbolic ink?  The following code

    You can't do it from the command line either, Chris.  This is
because chown and chgrp automatically dereference symlinks, so it's
actually changing ownership of the target.

> yet when I go take a look at it in the directory, the group for the
> link has not been changed to what I set it to.  Is that not something
> you can do for symbolic links programatically?

    To modify ownership of a symlink, you should instead use something
in the exec() family (exec(), passthru(), system(), etc.) and run the
command as if from the command line, with the option explicitly set
*not* to dereference symbolic links (which is -h or --no-dereference):


$symLink = 'linked'; // The actual name of the symbolic link file reference
$linkName = escapeshellarg($symLink); // Since we may accept user input

$ret = null; // This will only be populated and displayed once, on error.
$err = null; // We'll use this to define our errors.

exec('chgrp -h groupName '.$linkName,$ret,$err); // Group, using short flag
if(!is_null($err)) {

exec('chown --no-dereference ownerName '.$linkName,$ret,$err); //
Owner, full flag
if(!is_null($err)) {

</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to