Garayed.com  

Go Back   Garayed.com > PHP
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-11-2008, 06:42 PM
lawrence k
 
Posts: n/a
Default why can't PHP chmod a file that is already 777?

I've a simple script to transfer some files from one domain to
another, with both domains living on the same server. The files in
both directories are already chmod 777. Yet after transfer, I try to
ensure that the file is 777, and I get an error. Why?


for ($i=0; $i < count($transferArray); $i++) {
$fileName = $transferArray[$i];
$commandAsString = "\cp -f /var/www/vhosts/mydomain.com/httpdocs/
site_specific_files/$fileName /var/www/vhosts/theice.org/httpdocs/
site_specific_files/$fileName";
exec($commandAsString);
chmod("/var/www/vhosts/ice.org/httpdocs/site_specific_files/
$fileName", 0777);
if ($i > 0) $resultString .= ", ";
$resultString .= "$fileName";
}


The files copy over just fine, but the line where I try to do chmod, I
get this error:

"Warning: chmod(): Operation not permitted in /var/www/vhosts/
cyberbitten.com/httpdocs/sharedCode/
transferFilesFromCyberbittenToTSR.php on line 33"

The owner and the group of the file change to "www-data" which is
annoying, but which should allow PHP to do anything it wants with the
files. So why would I get an error?

I also tried to end with this line:

exec("chown mgtr /var/www/vhosts/ice.org/httpdocs/site_specific_files/
$fileName");

This doesn't work at all. Why?

I ssh to the server and edited the configuration files to be sure the
open_basedir restriction was off, then I rebooted Apache. That made
no difference, for this particular bug.












Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-12-2008, 02:23 AM
Mike Lahey
 
Posts: n/a
Default Re: why can't PHP chmod a file that is already 777?

lawrence k wrote:
> I've a simple script to transfer some files from one domain to
> another, with both domains living on the same server. The files in
> both directories are already chmod 777. Yet after transfer, I try to
> ensure that the file is 777, and I get an error. Why?
>
>
> for ($i=0; $i < count($transferArray); $i++) {
> $fileName = $transferArray[$i];
> $commandAsString = "\cp -f /var/www/vhosts/mydomain.com/httpdocs/
> site_specific_files/$fileName /var/www/vhosts/theice.org/httpdocs/
> site_specific_files/$fileName";
> exec($commandAsString);
> chmod("/var/www/vhosts/ice.org/httpdocs/site_specific_files/
> $fileName", 0777);
> if ($i > 0) $resultString .= ", ";
> $resultString .= "$fileName";
> }
>
>
> The files copy over just fine, but the line where I try to do chmod, I
> get this error:
>
> "Warning: chmod(): Operation not permitted in /var/www/vhosts/
> cyberbitten.com/httpdocs/sharedCode/
> transferFilesFromCyberbittenToTSR.php on line 33"
>
> The owner and the group of the file change to "www-data" which is
> annoying, but which should allow PHP to do anything it wants with the
> files. So why would I get an error?
>
> I also tried to end with this line:
>
> exec("chown mgtr /var/www/vhosts/ice.org/httpdocs/site_specific_files/
> $fileName");
>
> This doesn't work at all. Why?
>
> I ssh to the server and edited the configuration files to be sure the
> open_basedir restriction was off, then I rebooted Apache. That made
> no difference, for this particular bug.


I haven't seen your entire command, but cp could be failing here. a+x on
the destination directory.. chown won't change the owner unless the
person running it is root or through sudo.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:36 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.