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

noreply at bugs.digium.com noreply at bugs.digium.com
Tue Mar 18 21:57:36 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
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-18-2008 21:57 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
====================================================================== 

---------------------------------------------------------------------- 
 murf - 03-18-08 21:57  
---------------------------------------------------------------------- 
OK, I'm diving into this one. It looks like, in the first read of that
config 
data, it was correctly input, but when saved, the output algorithm is
wrong, and wrote the data as:

[template](!)(master-template)

instead of:

[template](!,master-template)

Since the output category header is syntactically incorrect, then
information is lost when it is read back in.... thus your second reading
has different results than the first.

I've just corrected this in 1.4, and will propagate this thru trunk and
1.6.

Due to the use of inherit_category, categories inheriting from templates
will
copy the template vars into the current category. An initial reading of
the code
seems to indicate that if the category being referenced hasn't been
defined yet, you might not get the inheritance. Of course then, since the
config file reader explodes the hierarchy upon reading, then if the
explosion does not occur, then you don't get the variables either... I will
have to research this.

The other problem is, that I could filter any var=val entry that already
appears in a referenced template, dropping it if var=val is found; but
there is code in the config_text_file_save() routine to do this already.
I'll see why it doesn't appear to be working...

More to come 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
03-18-08 21:57  murf           Note Added: 0084220                          
======================================================================




More information about the asterisk-bugs mailing list