Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
PHP

Journal ceejayoz's Journal: PHP and File Permissions 12

Hey Linux pros...

I have a PHP script that goes into my POP account directory and pulls e-mails out of it, parses them, and adds them to a mySQL db.

However...

My mail server (courier) creates those files with permissions of 0600 - meaning PHP can't read them without me manually CHMOD'ing them to 0644 (defeats the point of this script getting them in the first place).

so...

I need one of the following...

a) a shell script to CHOMD all files in that directory to 0644, which I'd put as a cron job every minute or so
b) some way of making courier save with 0644 permissions as default, instead of 0600
c) some way of getting PHP to run as the user (ceejay) instead of its default (nobody)

Anyone got ideas?

This discussion has been archived. No new comments can be posted.

PHP and File Permissions

Comments Filter:
  • Comment removed based on user account deletion
  • by ces ( 119879 )
    Courier can probably be whacked to save the files mode 644. Try looking in the config file.

    I wouldn't have the PHP process run as you but having it run as its own user instead of "nobody" has some merit. In general I prefer to run processes and subsystems under their own userids rather than grouping them all under single uid. If for no other reason than it can limit the damage caused by a bug or malicious user/process. It also permits somewhat finer grained access controls, for example you can make sure th
  • PHP's umask function [php.net] is related to what you need. There's an example at the bottom of the page that's pretty clear.
  • Can't you change the permissions on the folder so that files created in it are automatically created with the same group as your http user? I like this, as it should work even if a reboot disturbs a cron job.
  • Comment removed based on user account deletion

You knew the job was dangerous when you took it, Fred. -- Superchicken

Working...