[asterisk-bugs] [Asterisk 0008786]: [patch] Properly handle tempates on config read/write

noreply at bugs.digium.com noreply at bugs.digium.com
Tue Nov 6 10:55:49 CST 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=8786 
====================================================================== 
Reported By:                ssokol
Assigned To:                murf
====================================================================== 
Project:                    Asterisk
Issue ID:                   8786
Category:                   Core/Configuration
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:            SVN 
SVN Branch (only for SVN checkouts, not tarball releases):  1.4 
SVN Revision (number only!): 49334 
Disclaimer on File?:        Yes 
Request Review:              
====================================================================== 
Date Submitted:             01-10-2007 13:17 CST
Last Modified:              11-06-2007 10:55 CST
====================================================================== 
Summary:                    [patch] Properly handle tempates on config
read/write
Description: 
The configuration parser properly handles inherited properties from
templates when loading them from configuration files, but miss-handles them
when writing the configuration back to disk.

The attached patch denotes a context which has been built from a template
by automatically adding a variable called "inherited_" which is set to the
parent category name.  When the config handler writes the file, it checks
to see if a category is marked as inherited_ and if so, only writes those
values which are absent from the parent context.
====================================================================== 

---------------------------------------------------------------------- 
 murf - 11-06-07 10:55  
---------------------------------------------------------------------- 
OK, I've played with this, and now, I'm an expert.

While I think Steve took a practical approach, using a var to 
store the info needed, it didn't cover all the possibilities, and
so I did my own version of this fix, where I put this structure
into the structs in config.c; I didn't use the vars, because, if I
put the list of templates in a single var, I'd have to write
extra code to split it back out. Being the lazy slob I am, I made
this list an official list in the ast_cataegory struct...

Here's my set of tests:
                 Output         output                    output
Input config     1.4 plain      with Sokol's patch        My version
------------     ---------      ------------------        ------------

[foo](!)          [foo]              [foo]                [foo](!)
test = yes         (same)             (same)               (same)
data=blahblah      (same)             (same)               (same)

[foo2](!)         [foo2]             [foo2]               [foo2](!)
test2 = yes        (same)             (same)               (same)
data2 = bluchbluch (same)             (same)               (same)

[foo3](!)         [foo3]             [foo3]               [foo3](!)
test3=no           (same)             (same)               (same)
data3=hoochbluch   (same)             (same)               (same)

[foo4](foo,foo2,foo3)  [foo4]        [foo4](foo)        
[foo4](foo,foo2,foo3)
hooch=no           test=yes           test2=yes           hooch=no
data3=blahblech    data=blahblah      data2=bluchbluch    data3=blahblech
newthing=2         test2=yes          test3=no            newthing=2
                   data2=bluchbluch   data3=hoochbluch
                   test3=no           hooch=no
                   data3=blahblech    data3=blahblech
                   newthing=2         newthing=2

Don't ask me why, I didn't debug it, but the 1.4 version, as is, for some
reason, left out hooch=no!

It's probably bad form to try to override template values in the
instances, as the config stuff has both var decls in the var list. Not
good, as you'll probably not see the override. But the code as-is does
this, so I left it be. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
11-06-07 10:55  murf           Note Added: 0073197                          
======================================================================




More information about the asterisk-bugs mailing list