[asterisk-bugs] [Asterisk 0011442]: duplicate values when rewriting templated config files

noreply at bugs.digium.com noreply at bugs.digium.com
Wed Mar 19 10:36:57 CDT 2008


The following issue has been ASSIGNED. 
====================================================================== 
http://bugs.digium.com/view.php?id=11442 
====================================================================== 
Reported By:                tzafrir
Assigned To:                murf
====================================================================== 
Project:                    Asterisk
Issue ID:                   11442
Category:                   Core/Configuration
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:            1.4.14  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             12-03-2007 06:02 CST
Last Modified:              03-19-2008 10:36 CDT
====================================================================== 
Summary:                    duplicate values when rewriting templated config
files
Description: 
I'm trying to generate slimmer config files using templates.

I use something of the sort of:

[master-template](!)
mastervar = bar
[template](!,master-template)
tvar = value
[cat](template)
catvar = val

I do not expect full transparent rewrite support of this. I do hope to get
at least some "flattening" of the templates that will preserve the values:


[cat]
mastervar = bar
tvar = value
catvar = val


What I actually get is: 

After first save/rewrite:

[master-template](!)
mastervar = bar
[template](!)(master-template)
mastervar = bar
tvar = value
[cat](template)
mastervar = bar
tvar = value
catvar = val

And then after the second time those values get rewritten to the
configuration file by Asterisk, they end up as:

[master-template](!)
mastervar = bar
[template](!)
mastervar = bar
tvar = value
[cat](template)
mastervar = bar
tvar = value
mastervar = bar
tvar = value
catvar = val
====================================================================== 

---------------------------------------------------------------------- 
 svnbot - 03-19-08 10:36  
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 109908

U   branches/1.4/main/config.c

------------------------------------------------------------------------
r109908 | murf | 2008-03-19 10:36:54 -0500 (Wed, 19 Mar 2008) | 72 lines

(closes issue http://bugs.digium.com/view.php?id=11442)
Reported by: tzafrir
Patches:
      11442.patch uploaded by murf (license 17)
Tested by: murf

I didn't give tzafrir very much time to test this, but if he does 
still have remaining issues, he is welcome to 
re-open this bug, and we'll do what is called for.

I reproduced the problem, and tested the fix, so I hope I
am not jumping by just going ahead and committing the fix.

The problem was with what file_save does with templates; 
firstly, it tended to print out multiple options:

[my_category](!)(templateref)

instead of 

[my_category](!,templateref)

which is fixed by this patch.


Nextly, the code to suppress output of duplicate declarations
that would occur because the reader copies inherited declarations
down the hierarchy, was not working. Thus:


 [master-template](!)
 mastervar = bar


 [template](!,master-template)
 tvar = value


 [cat](template)
 catvar = val


would be rewritten as:

 ;!
 ;! Automatically generated configuration file
 ;! Filename: experiment.conf (/etc/asterisk/experiment.conf)
 ;! Generator: Manager
 ;! Creation Date: Tue Mar 18 23:17:46 2008
 ;!
 
 [master-template](!)
 mastervar = bar

 
 [template](!,master-template)
 mastervar = bar
 tvar = value

 
 [cat](template)
 mastervar = bar
 tvar = value
 catvar = val

This has been fixed. Since the config reader 'explodes' inherited
vars into the category, users may, in certain circumstances, see
output different from what they originally entered, but it should
be both correct and equivalent.



------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=109908 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
03-19-08 10:36  svnbot         Note Added: 0084242                          
03-19-08 10:36  svnbot         Status                   feedback => assigned
======================================================================




More information about the asterisk-bugs mailing list