base-files: fix UCI config parsing and callback handling
authorTony Ambardar <itugrok@yahoo.com>
Thu, 8 Mar 2018 05:00:45 +0000 (21:00 -0800)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 6 Jun 2018 13:02:00 +0000 (15:02 +0200)
commit023944853241920c20842c0f4649d1dd4e7e273b
tree077107577bffacc7898ed654a78d57a9e1a44d15
parentb295e3a18df21ee9a2df6f738a5df94d12894467
base-files: fix UCI config parsing and callback handling

There are several long-standing issues present in the UCI shell API as
documented in https://wiki.openwrt.org/doc/devel/config-scripting. They
relate both to high-level, user-defined callback functions used to
process UCI config files, and also to low-level functions used within
scripts generally.

The related problems have been encountered now and in the past, e.g.
https://forum.openwrt.org/viewtopic.php?id=54295, and include:

a) UCI parsing option() function and user-defined option_cb() callbacks
being erroneously called during processing of "list" config file entries;

b) normal usage of the low-level config_set() unexpectedy calling any
defined option_cb() if present; and

c) handling of the list_cb() not respecting the NO_CALLBACK variable.

Root causes include a function stack "inversion", where the low-level
config_set() function incorrectly calls the high-level option() function,
intended only for processing the "option" keyword of UCI config files.

This change addresses the inversion and other issues, making the option
handling code more consistent and smaller, and simplifying developers'
usage of UCI callbacks.

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_RELEASE increase]
package/base-files/Makefile
package/base-files/files/lib/functions.sh