On 2014-11-06 21:21, Yousong Zhou wrote: > I am not quite familiar with the early history of how UCI file was parsed, but > thought that UCI config files were parsed in a quite clever way all by shell > scripts which made it possible to have multi-line value for options. AFAIK, > at > least package openvpn [1] depends on this feature. > > This series tries to fix an issue with current C implementation of parser for > UCI config file. The current code uses pointers into line buffer > `ctx->pctx->buf` which may need to grow in size when a backslash was found at > the end of line. The grow is implemented by function uci_realloc() which may > return an address different from the original. Then the parser will be in a > state where ctx->pctx->buf changed, but various char **str and char **target > are not updated along. > > The realloc() can be triggered by something like below (in function > parse_double_quote()). > > config sockd 'instance0' > option internal_network 'vpn' > option external_network 'wan' > option extra_config "a \ > bbbbbbbbbbbbb \ > ccccccccccccc \ > " > > A few test cases, including importing/exporting config, getting/setting option > values were also included trying to verify the patch. > > I do not expect this to be accepted in the neare future because at later stage > of preparing this series I saw that LF and NL characters are explicitly deemed > illegal for option value in uci_validate_text(). But if you are interested in > this feature, you can give it a try. > > I found multi-line option value useful in cases where I want parts of the > program's configuration values to be connected with OpenWrt system state, e.g. > stop/start services when the status of the dependent network go down/up, while > still keep the related bits all in one place, not just many remedy scripts > scattered here and there. > > [1] see `append_params()` in > package/network/services/openvpn/files/openvpn.init Applied to uci git. I will commit the update to trunk soon.
Thanks, - Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel