Jump to content

Setting permissions not permitted


joe92

Recommended Posts

Hi there, I am working on a little CMS site and I have run into a bit of a problem. When the user comes to publish the changes they have made I need to push the new files onto their server. I don't know whether they are on a shared host or not though, and if they are they won't be the root user and so functions like chmod and rmdir will be disallowed. Even if they weren't on a shared host I doubt whether they would be running scripts as root anyway.

 

I cannot ask the user to set the file permissions to 0777 to use the CMS as I know that most people would not do that, I know I wouldn't. So my plan of action was to have the permissions set to 0644 and temporarily change them to 0777 whiles I push the changes then change it back again afterwards. I have a tiny website on a shared host so I am able to test this in the worst of scenarios and these are the errors I get:

Warning: chmod() [function.chmod]: Operation not permitted in ******** on line 20

Warning: fopen(********) [function.fopen]: failed to open stream: Permission denied in ******** on line 35

Warning: fwrite() expects parameter 1 to be resource, boolean given in ******** on line 39

Warning: fclose() expects parameter 1 to be resource, boolean given in ******** on line 40

 

Because I am not the root user chmod is not permitted and because the file permissions are set to 0644 I cannot execute the file system functions which alter the files. It all relies on the permissions being set right. I tried using umask but as someone says in a note on php.net, umask can only remove/delete permissions, it can't grant them. So that seems like a dead end. I can't change ownership either with chown as that requires you to be the root to use too.

 

Wondering what was going on I used fileperms to find out what the permissions were according to the php and got the number 33188. Turns out after a bit of research that this is an octal number, so I converted it and got the number 100644. That looks about right, but I don't know what the 10 is doing before the permissions?

 

Does anyone know how can I get around this problem? I would like to avoid using FTP functions if I can.

 

Thanks for any help,

Joe

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.