• The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Owner Permissions Error

Pagemakers

Silver Pleskian
Hello

We have a PHP script that creates files within a domain. However, the files are created with the owner permissions of apache and not the domain that created them.

Why?
 
This is normal, files are created with the apache owner because PHP is running 'inside' apache.
 
Thanks for your reply...

The php script creates a folder and then another non-php script (a Perl cgi script) tries to write files within that folder.

Here is the problem. It can't write the files because it does not have the permissions to write to the Apache owned folder.

Any ideas?
 
I would suggest that you either make a cronjob that on a hourly/daily basis set the correct file permissions - or maybe you add a custom button in the controlpanel allowing the users to manually set the correct permissions (create a script that sets it correct when runned).
 
Copied from php.net about safemode
I use mkdir just fine. You just have to make sure you set sticky bits on the directory you are creating the files in. Look at "man chmod" clipping:

4000 (the setuid bit). Executable files with this bit set will run with effective uid set to the uid of the file owner. Directories with this bit set will force all files and sub-directories created in them to be owned by the directory owner and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to mount(8).

And then lower I saw this
Beware that when in safe mode, mkdir creates folders with apache's UID, though the files you create in them are of your script's UID (usually the same as your FTP uid).

What this means is that if you create a folder, you won't be able to remove it, nor to remove any of the files you've created in it (because those operations require the UID to be the same).

Ideally mkdir should create the folder with the script's UID, but this has already been discussed and will not be fixed in the near future.

In the meantime, I would advice NOT to user mkdir in safe mode, as you may end up with folders you can't remove/use.

Maybe this will help without a cronjob
 
Back
Top