base-files: network.sh: gracefully handle missing network.interface ubus ns
authorJo-Philipp Wich <jo@mein.io>
Tue, 17 Jul 2018 05:47:33 +0000 (07:47 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Mon, 30 Jul 2018 11:19:19 +0000 (13:19 +0200)
commitf24e0129975f91a1f75b0546d154f380aa91639c
tree64280c22d092caf680d01f724267a74718e3a6a7
parentd4a4f0658923e76a3b9e17017efd2d27e48c0d21
base-files: network.sh: gracefully handle missing network.interface ubus ns

When attempting to use any of the functions in network.sh while netifd is
not started yet, the ubus interface dump query will fail with "Not found",
yielding an empty response.

Subsequently, jsonfilter is invoked with an empty string instead of a valid
JSON document, causing it to emit a second "unexpected end of data" error.

This caused the dnsmasq init script to log the following errors during
early boot on some systems:

    procd: /etc/rc.d/S19dnsmasq: Command failed: Not found.
    procd: /etc/rc.d/S19dnsmasq: Failed to parse json data: unexpected end of data.

Fix the issue by allowing the ubus query to fail with "Not found" but still
logging other failures, and by passing an empty JSON object to jsonfilter
if the interface status cache is empty.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
package/base-files/Makefile
package/base-files/files/lib/functions/network.sh