On Tue, May 6, 2008 at 1:54 PM, Scott Ullrich <[EMAIL PROTECTED]> wrote:
> On 5/6/08, David Rees <[EMAIL PROTECTED]> wrote:
> > I did some checking in the PHP code - it does look like there are
>  >  various locations where the /conf/config.xml or
>  >  {$g['conf_path']}/config.xml or /cf/conf/config.xml are written just
>  >  using a plain fopen, write, close. This does leave you open to the
>  >  race condition I mentioned earlier where it's possible that another
>  >  process ends up reading a halfway written config file.
>
>  Yes and no.  Any config.xml operations are protected by config_lock()
>  and unlock().    Are you seeing a case where they are not?  Note:
>  write_config() automatically handles this behind the scenes.

Ah, missed that. I did see a few other places where it appears that
config.xml is written besides through the write_config routine...
Modifying write_config to update the config file atomically will be
straight forward and should cover most of the cases where the file is
commonly written.

If you lock the file before doing any reads of the config then we
should be sure that we aways get a valid config file. Even if
everything does, it's not bad practice to attempt the config files
atomically.

But since the ping_hosts.sh script doesn't check, that explains the
problem. I'm guessing that there are other scripts that don't as well.

I'll see if I can modify write_config to do the "right thing".

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to