[OpenWrt-Devel] [PATCH] uboot-env-tools be safer

Imran K gururug at gmail.com
Tue Dec 17 08:59:28 EST 2019


uboot-env-tools: Check for config prior to append

In the rare event a pre-populated fw_env.config exists in the rootfs prior
to firstboot, calling fw_setenv after the system has initialised will
annihilate the devices environment due to two identical lines in
fw_env.config.

Check for existence prior to blind appendage.

--- a/uboot-envtools.sh
+++ b/uboot-envtools.sh
@@ -31,6 +31,6 @@ ubootenv_add_app_config() {
  config_get envsize "$1" envsize
  config_get secsize "$1" secsize
  config_get numsec "$1" numsec
- echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
+ grep -q "$dev $offset $envsize $secsize $numsec" /etc/fw_env.config ||
echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
 }

Signed-off-by: Imran Khan <gururug at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20191217/7f329ade/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list