From d6c7d08d395d916429602037ed86114832c4e458 Mon Sep 17 00:00:00 2001 From: ribbon10 Date: Sun, 4 Nov 2012 20:49:36 +0100 Subject: [PATCH] Corrections for create of /var/config/settings.conf - Busybox awk does not interpret the -F option as regular expression. With this patch the field seperators are '" and not \"|' - Added gsub for $ so that it becomes \$. THis is because the generated config file assignes string with "" to variables. Insite "" the $ sign is used to reference variables. This problem was discovered with a wlan passphrase that included a \ and & sign. Here is a example string that can be used to reproduce both problems: Here is what we get before merge: echo '' | awk -F'[\"|'\'']' '{gsub(/\"\;/, "\\\"", $4); gsub(/\&apos\;/, "\047", $4); gsub(/\&\;/, "\\&", $4); gsub(/\<\;/, "<", $4); gsub(/\>\;/, ">", $4); print $2"=\""$4"\"";}' TEST_KEY="$-you_can_see_me" Here is what we get after merge: echo '' | awk -F'["'\'']' '{gsub(/\"\;/, "\\\"", $4); gsub(/\&apos\;/, "\047", $4); gsub(/\&\;/, "\\&", $4); gsub(/\<\;/, "<", $4); gsub(/\>\;/, ">", $4); gsub(/\$/, "\\\$", $4); print $2"=\""$4"\"";}' TEST_KEY="\$-you_can_see_me\you_can_not_see_me" --- packages/sysutils/busybox/init.d/06_systemconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sysutils/busybox/init.d/06_systemconfig b/packages/sysutils/busybox/init.d/06_systemconfig index ba3baf9f2f..18e542f48c 100644 --- a/packages/sysutils/busybox/init.d/06_systemconfig +++ b/packages/sysutils/busybox/init.d/06_systemconfig @@ -30,6 +30,6 @@ if [ -f "$OPENELEC_SETTINGS" ]; then mkdir -p /var/config cat "$OPENELEC_SETTINGS" \ - | awk -F'[\"|'\'']' '{gsub(/\"\;/, "\\\"", $4); gsub(/\&apos\;/, "\047", $4); gsub(/\&\;/, "\\&", $4); gsub(/\<\;/, "<", $4); gsub(/\>\;/, ">", $4); print $2"=\""$4"\"";}' \ + | awk -F'["'\'']' '{gsub(/\"\;/, "\\\"", $4); gsub(/\&apos\;/, "\047", $4); gsub(/\&\;/, "\\&", $4); gsub(/\<\;/, "<", $4); gsub(/\>\;/, ">", $4); gsub(/\$/, "\\\$", $4); print $2"=\""$4"\"";}' \ | sed '/^=/d' > /var/config/settings.conf fi