Re: public_html folder permissions preventing use of system()

From: Aaron Whiffin (aaron_at_nospam.com)
Date: 10/15/04


Date: Fri, 15 Oct 2004 09:16:49 GMT


> Please read this thread:
>
> http://tinyurl.com/6d348

I appreciate what the thread is saying but it doesn't work in this case ...

I can use system() commands, but to do this I need to be able to have 777
permissions on a folder as Apache is run as a completely seperate user. This
is obviously bad as people will be able to modify the contents of the
folder.

In all (but one) cases I can use PHP commands like mrdir() and unlink() -
that's fine, BUT they do not have permission to run either and they require
the permissions to be 777, so I am no better off.

So I tried using chmod() before (and after) each command, that does not have
permission to run.

So if I can't change permission in PHP I can't see a way around it. I don't
want to have to set folders to 777!

My ISP (www.dataflame.co.uk) seems helpful, but in this instance can't do
much.

Can anyone please think of a way around this, or something that I can email
dataflame's support team and ask them to change.

This MUST be a common problem. Would there be any reason chmod() isn't
working?

The error message given is:

Warning: chmod(): Operation not permitted in
/home/username/public_html/test.php

One further thing that may give an indication of their setup. If I set
folder permissions to 777, and create a folder in this one using PHP, this
subfolder can then not be deleted by my FTP. I'm assuming this is because it
is owned by Apache not me. I can of course delete the subfolder with PHP ...
and change its permissions.

Now this made me think, perhaps I could chown() my folders to Apache, so I
can have 777 permissions. This means I (and anyone else) could update files
from PHP, but not from their usual account. Slightly safer, but still not
good. Plus of course I will not be able to delete folders etc via FTP.

But I may be thinking on the right steps.

So ... I created a folder by PHP, then chmod() to 755. It worked (permissins
had a T after them in FlashFXP (d-w-rwxr-T)- whatever that means) ... but
now I can't delete this using PHP commands, system() commands within PHP or
by FTP! I can't even use system() and chown to change ownership to my FTP
account.

Now to make things slightly harder, as well as needing to
read/write/delete/modify files/folders in seperate folders which I *may* be
able to solve using some method. I also need to be able to create folders in
my public_html folder so people can go to www.mysite.com/subsite/

I know this is a mess, but I am sure it's common, so can someone please
help?

Cheers



Relevant Pages

  • Re: [PHP] File Upload Security and chmod
    ... PHP ftp functions, but I have used the PHP functions chmodand mkdir ... >what permissions do you set the parent folder at when you are finished ... upon the permissions the parent folder. ...
    (php.general)
  • Re: [PHP] File Upload Security and chmod
    ... The FTP will be slower, ... your files at will in PHP. ... all of the directory creation and permissions changes? ... upon the permissions the parent folder. ...
    (php.general)
  • Re: [PHP] File Upload Security and chmod
    ... I ran into the same problem trying to work with, and understand, permissions on a virtual host. ... the key to setting the permissions of a file depends upon the permissions the parent folder. ... that also presents a major security hole because then anyone can use that folder to upload and run evil code. ... I thought perhaps php had something like that and as such I discovered how to ftp connect via php. ...
    (php.general)
  • Re: IIS Password Protected Directory 403 Errors on PHP pages
    ... do your php pages include any files that are ... the users permissions to that, ... > protected directory using IIS 5. ... > and sharing permsission to the folder and then all folders above it to ...
    (microsoft.public.inetserver.iis)
  • RE: File Permissions
    ... access on the share and then remove the inheritable permissions on the user's ... On the user's folder, give them read/write permission. ... Put on your logon script the following commands: ... read/write to users on their folders and fullcontrol to the administrators. ...
    (microsoft.public.security)