Jump to content

problems deleting files as www-data, chmod seems erratic


allasso

Recommended Posts

Hello,

 

I have started writing php scripts and using them for a site on a local access server (Apache) on my local network, and for the most part things have gone quite smoothly.

 

I have noticed however that when new files are created as user www-data, the behavior with deleting files, and changing permissions seems a bit erratic. Sometimes I am able to delete them, other times not. I have used:

 

shell_exec( "rm -r $dir" ) and sometimes it works and sometimes it doesn't. I have checked the permissions of the parent directories and all child file/dirs and even files I should be able to remove I cannot remove, well sometimes. I would not be so perplexed if it were consistent, but it is not. Sometimes I have been able to start deleting files from the bottom of the path, and work my way up using rmdir, but this is quite tedious, and in some cases even that hasn't worked.

 

I tried changing permissions using eg chmod( "file", "0777" ) so I could go I could access my account on the server as user me and delete them that way, but though the permissions get changed, they do not change to what I am setting them to. They changed from 0644 to 411, which means that now no one has write permissions. I do not have root access to the server, and so this puts me in a bit of a mess.

 

I would like to keep the permissions liberal (on that level anyway) so that I can freely manage the files via ftp or ssh. I have gotten in the habit of first creating a file by accessing the server so I don't run into this problem any more, but I am not comfortable with what seems to be erratic to me. Also, I have several dirs and files on the server I cannot remove.

 

Anyone have any clues about this erratic behavior?

 

I have a couple of other questions that I will post on another topic.

 

Thank you, Allasso

 

 

I found that chmod() was sending mode in decimal.  I do not understand this since I was prefixing my numbers with zero:

 

from the manual:

 

Note that mode  is not automatically assumed to be an octal value, so strings (such as "g+w") will not work properly. To ensure the expected operation, you need to prefix mode  with a zero (0):

 

I had quotes around the the mode numbers originally, but even taking them out doesn't make any difference.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.