[FS#225] equally named config sections of different type cannot coexist

LEDE Bugs lede-bugs at lists.infradead.org
Thu Oct 13 17:33:29 PDT 2016


A new Flyspray task has been opened.  Details are below. 

User who did this - Karol Babioch (kbabioch) 

Attached to Project - LEDE Project
Summary - equally named config sections of different type cannot coexist
Task Type - Bug Report
Category - Base system
Status - Unconfirmed
Assigned To - 
Operating System - All
Severity - Low
Priority - Very Low
Reported Version - Trunk
Due in Version - Undecided
Due Date - Undecided
Details - Fiddling around with UCI and a more advanced configuration files I just realized that introducing a new section with the same name of an already existing but with a different type makes the first one disappear.

Lets take this file as an example:


 # anonymous dnsmasq section
 config dnsmasq

 # another anonymous dnsmasq section
 config dnsmasq

 # named dnsmasq section
 config dnsmasq foo

 # another dnsmasq section
 config dnsmasq bar

 # named dhcp section: this makes the dnsmasq section named bar disappear
 config dhcp bar


There is a dnsmasq config section named "foo". But as soon as I put another section named bar (of a different type) into the file (e.g. the last line) it is no longer parsed correctly. For instance config_cb is no longer invoked for the dnsmasq section. I have a test script like this:


 #!/bin/sh

 . /lib/functions.sh

 config_cb() {
         echo "$@"
 }

 config_load test


The output of this script is:


 root at lede:~# ./test.sh 
 dnsmasq cfg02411c
 dnsmasq cfg04411c
 dnsmasq foo
 dhcp bar
 


Note how the dnsmasq section named bar is missing from the output. The output is expected to look like this:


 root at lede:~# ./test.sh 
 dnsmasq cfg02411c
 dnsmasq cfg04411c
 dnsmasq foo
 dnsmasq bar
 dhcp bar



When removing the last section from the configuration file the output actually includes the line "dnsmasq bar", which is correct.

This bug makes it pretty much impossible to have two section of different type with the same name within a configuration file, since one cannot be sure that it is parsed correctly.

More information can be found at the following URL:
https://bugs.lede-project.org/index.php?do=details&task_id=225



More information about the lede-bugs mailing list