[asterisk-bugs] [Asterisk 0010781]: [patch] Doesn't lock config files when writing

noreply at bugs.digium.com noreply at bugs.digium.com
Mon Sep 24 01:24:45 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=10781 
====================================================================== 
Reported By:                paravoid
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   10781
Category:                   Core/Configuration
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
Asterisk Version:           1.4.11  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             09-21-2007 00:48 CDT
Last Modified:              09-24-2007 01:24 CDT
====================================================================== 
Summary:                    [patch] Doesn't lock config files when writing
Description: 
Asterisk does not use flock() to lock configuration files when writing them
on config_text_file_save().

This was originally reported as Debian bug
http://bugs.digium.com/view.php?id=353227 by John Goerzen. In his
own words:
"It appears to not protect the file even against itself.  It certainly
doesn't use flock() to protect it against others.

This is a problem for several reasons.  First, of course, people can be
hand-editing the file to add or remove users.  Secondly, automated
programs may be appending data to it for the same purpose.

We've noticed corruption in our file and are almost certain that this is
the culprit."
====================================================================== 

---------------------------------------------------------------------- 
 paravoid - 09-24-07 01:24  
---------------------------------------------------------------------- 
No, not exactly.

With file locking a process (or a thread for that matter) can *inform* the
others that it's writing the files so they can hold their operation until
writing is done.

Your solution is safe -file corruption wise-, even safer than locking.

But it won't block a thread from trying to write a file while it's already
being written by another process. Or block another process while Asterisk
is writing the file.

OTOH, I'm not sure how well will Asterisk behave if that thread gets
blocked for an unknown period of time.

I guess that's only a problem of interaction between Asterisk and other
processes (e.g. editors). 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
09-24-07 01:24  paravoid       Note Added: 0071015                          
======================================================================




More information about the asterisk-bugs mailing list