From 0ea7160cc37ed4e7bd415621398491e8b2a63606 Mon Sep 17 00:00:00 2001
From: Markus Gothe <markus.gothe@genexis.eu>
Date: Mon, 29 Nov 2021 13:47:05 +0100
Subject: [PATCH] RM#34619 - kv_read bug makes box report weird values

Update with fix provided by Altibox. Also set the 'readonly'
attribute on variables.

Change-Id: I567e3ee1b193636949300c2b236ef3c206bdc028
---
 iopsys-brcm63xx-arm/eagle/base-files/usr/bin/kv_read   | 6 +++---
 iopsys-brcm63xx-arm/koala/base-files/usr/bin/kv_read   | 6 +++---
 iopsys-brcm63xx-arm/panda/base-files/usr/bin/kv_read   | 6 +++---
 iopsys-brcm63xx-arm/panther/base-files/usr/bin/kv_read | 6 +++---
 iopsys-brcm63xx-arm/tiger/base-files/usr/bin/kv_read   | 6 +++---
 iopsys-brcm63xx-arm/zebra/base-files/usr/bin/kv_read   | 6 +++---
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/iopsys-brcm63xx-arm/eagle/base-files/usr/bin/kv_read b/iopsys-brcm63xx-arm/eagle/base-files/usr/bin/kv_read
index 40f55044b..0968839e0 100755
--- a/iopsys-brcm63xx-arm/eagle/base-files/usr/bin/kv_read
+++ b/iopsys-brcm63xx-arm/eagle/base-files/usr/bin/kv_read
@@ -1,7 +1,7 @@
  #!/bin/sh
 
-DEVPARAM_FILE="/data/config/device_params"
-DEVPARAM="$1"
+readonly DEVPARAM_FILE="/data/config/device_params"
+readonly DEVPARAM="$1"
 
 if [ ! -f $DEVPARAM_FILE ]; then
 	fw_printenv -n $DEVPARAM
@@ -9,7 +9,7 @@ if [ ! -f $DEVPARAM_FILE ]; then
 fi
 
 if [ -n "$DEVPARAM" ]; then
-	grep $DEVPARAM $DEVPARAM_FILE | awk -F'=' '{print$2}'
+	grep "^${DEVPARAM}=" $DEVPARAM_FILE | awk -F'=' '{print$2}'
 else
 	cat $DEVPARAM_FILE
 fi
diff --git a/iopsys-brcm63xx-arm/koala/base-files/usr/bin/kv_read b/iopsys-brcm63xx-arm/koala/base-files/usr/bin/kv_read
index 40f55044b..0968839e0 100755
--- a/iopsys-brcm63xx-arm/koala/base-files/usr/bin/kv_read
+++ b/iopsys-brcm63xx-arm/koala/base-files/usr/bin/kv_read
@@ -1,7 +1,7 @@
  #!/bin/sh
 
-DEVPARAM_FILE="/data/config/device_params"
-DEVPARAM="$1"
+readonly DEVPARAM_FILE="/data/config/device_params"
+readonly DEVPARAM="$1"
 
 if [ ! -f $DEVPARAM_FILE ]; then
 	fw_printenv -n $DEVPARAM
@@ -9,7 +9,7 @@ if [ ! -f $DEVPARAM_FILE ]; then
 fi
 
 if [ -n "$DEVPARAM" ]; then
-	grep $DEVPARAM $DEVPARAM_FILE | awk -F'=' '{print$2}'
+	grep "^${DEVPARAM}=" $DEVPARAM_FILE | awk -F'=' '{print$2}'
 else
 	cat $DEVPARAM_FILE
 fi
diff --git a/iopsys-brcm63xx-arm/panda/base-files/usr/bin/kv_read b/iopsys-brcm63xx-arm/panda/base-files/usr/bin/kv_read
index 40f55044b..0968839e0 100755
--- a/iopsys-brcm63xx-arm/panda/base-files/usr/bin/kv_read
+++ b/iopsys-brcm63xx-arm/panda/base-files/usr/bin/kv_read
@@ -1,7 +1,7 @@
  #!/bin/sh
 
-DEVPARAM_FILE="/data/config/device_params"
-DEVPARAM="$1"
+readonly DEVPARAM_FILE="/data/config/device_params"
+readonly DEVPARAM="$1"
 
 if [ ! -f $DEVPARAM_FILE ]; then
 	fw_printenv -n $DEVPARAM
@@ -9,7 +9,7 @@ if [ ! -f $DEVPARAM_FILE ]; then
 fi
 
 if [ -n "$DEVPARAM" ]; then
-	grep $DEVPARAM $DEVPARAM_FILE | awk -F'=' '{print$2}'
+	grep "^${DEVPARAM}=" $DEVPARAM_FILE | awk -F'=' '{print$2}'
 else
 	cat $DEVPARAM_FILE
 fi
diff --git a/iopsys-brcm63xx-arm/panther/base-files/usr/bin/kv_read b/iopsys-brcm63xx-arm/panther/base-files/usr/bin/kv_read
index 40f55044b..0968839e0 100755
--- a/iopsys-brcm63xx-arm/panther/base-files/usr/bin/kv_read
+++ b/iopsys-brcm63xx-arm/panther/base-files/usr/bin/kv_read
@@ -1,7 +1,7 @@
  #!/bin/sh
 
-DEVPARAM_FILE="/data/config/device_params"
-DEVPARAM="$1"
+readonly DEVPARAM_FILE="/data/config/device_params"
+readonly DEVPARAM="$1"
 
 if [ ! -f $DEVPARAM_FILE ]; then
 	fw_printenv -n $DEVPARAM
@@ -9,7 +9,7 @@ if [ ! -f $DEVPARAM_FILE ]; then
 fi
 
 if [ -n "$DEVPARAM" ]; then
-	grep $DEVPARAM $DEVPARAM_FILE | awk -F'=' '{print$2}'
+	grep "^${DEVPARAM}=" $DEVPARAM_FILE | awk -F'=' '{print$2}'
 else
 	cat $DEVPARAM_FILE
 fi
diff --git a/iopsys-brcm63xx-arm/tiger/base-files/usr/bin/kv_read b/iopsys-brcm63xx-arm/tiger/base-files/usr/bin/kv_read
index 40f55044b..0968839e0 100755
--- a/iopsys-brcm63xx-arm/tiger/base-files/usr/bin/kv_read
+++ b/iopsys-brcm63xx-arm/tiger/base-files/usr/bin/kv_read
@@ -1,7 +1,7 @@
  #!/bin/sh
 
-DEVPARAM_FILE="/data/config/device_params"
-DEVPARAM="$1"
+readonly DEVPARAM_FILE="/data/config/device_params"
+readonly DEVPARAM="$1"
 
 if [ ! -f $DEVPARAM_FILE ]; then
 	fw_printenv -n $DEVPARAM
@@ -9,7 +9,7 @@ if [ ! -f $DEVPARAM_FILE ]; then
 fi
 
 if [ -n "$DEVPARAM" ]; then
-	grep $DEVPARAM $DEVPARAM_FILE | awk -F'=' '{print$2}'
+	grep "^${DEVPARAM}=" $DEVPARAM_FILE | awk -F'=' '{print$2}'
 else
 	cat $DEVPARAM_FILE
 fi
diff --git a/iopsys-brcm63xx-arm/zebra/base-files/usr/bin/kv_read b/iopsys-brcm63xx-arm/zebra/base-files/usr/bin/kv_read
index 40f55044b..0968839e0 100755
--- a/iopsys-brcm63xx-arm/zebra/base-files/usr/bin/kv_read
+++ b/iopsys-brcm63xx-arm/zebra/base-files/usr/bin/kv_read
@@ -1,7 +1,7 @@
  #!/bin/sh
 
-DEVPARAM_FILE="/data/config/device_params"
-DEVPARAM="$1"
+readonly DEVPARAM_FILE="/data/config/device_params"
+readonly DEVPARAM="$1"
 
 if [ ! -f $DEVPARAM_FILE ]; then
 	fw_printenv -n $DEVPARAM
@@ -9,7 +9,7 @@ if [ ! -f $DEVPARAM_FILE ]; then
 fi
 
 if [ -n "$DEVPARAM" ]; then
-	grep $DEVPARAM $DEVPARAM_FILE | awk -F'=' '{print$2}'
+	grep "^${DEVPARAM}=" $DEVPARAM_FILE | awk -F'=' '{print$2}'
 else
 	cat $DEVPARAM_FILE
 fi
-- 
GitLab