views:

34

answers:

1

Hi,

I have a web application which has a shared config.php file. In this file, I include a function which gathers error messages (using set_error_handler) and then, at the end of the script execution, saves the errors to a centralised log file (using register_shutdown_function).

Log files are created daily, in the format Y-m-d.log. Cron scripts run every 5 minutes as part of the application, so are usually the cause of the first errors each day and so the error file is created under the cron user, which is the account superuser.

When our staff come in to work and use the application, the script runs under the apache user (99). The error logger can't write to the error file, as it is owned by superuser.

One possible solution is to have the cron script chown the log file to 99, so that it can be accessed by the apache user. Is uid 99 an accepted convention for apache hosting, or will I be causing future portability issues if I hard-code 99 in?

Are there any other ways (without resorting to exec/sudo) to make my log accessible?

Update: I don't have shell access to the server.

Thanks, Adam

A: 

root@deathstar:~# su nobody $ id uid=65534(nobody) gid=65534(nogroup) Gruppen=65534(nogroup)

you don't need the id. The username is enough and if you don't want to hardcode nothing, i suggest that you:

  • first grep the /etc/apache2/apache2.config for "User"
  • do a chmod using the username (chmod will get the userid for you)
VP
Thanks, but I don't have shell access
adam
but you can write a script to do it..
VP