make_build_h: handle backslashes in external strings
authorkkm <kkm@smartaction.com>
Wed, 25 Jan 2017 01:51:07 +0000 (17:51 -0800)
committerKirill Katsnelson <kkm@smartaction.com>
Fri, 27 Jan 2017 03:17:20 +0000 (21:17 -0600)
LikewiseOpen creates user names with a backslash in them. A gentle
massage with sed(1) allows such strings to be inserted into build.h
properly quoted. I am also adding the same for host name and other
strings used in the script that are more or less user-controlled.

ASTERISK-26754

Change-Id: Iac5ef2b67a68ee58f35ddbf86bb818ba6eabecae

build_tools/make_build_h

index a7cb6fe..2c8895e 100755 (executable)
@@ -1,13 +1,13 @@
 #!/bin/sh
-HOSTNAME=`uname -n`
-KERNEL=`uname -r`
-MACHINE=`uname -m`
+HOSTNAME=`uname -n | sed 's/\\\\/\\\\\\\\/g'`
+KERNEL=`uname -r   | sed 's/\\\\/\\\\\\\\/g'`
+MACHINE=`uname -m  | sed 's/\\\\/\\\\\\\\/g'`
 OS=`uname -s`
-USER=`id | awk -F")" '{print $1}'| awk -F"(" '{print $2}'`
+USER=`id | awk -F")" '{print $1}'| awk -F"(" '{print $2}' | sed 's/\\\\/\\\\\\\\/g'`
 DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
 cat << END
 /*
- * build.h 
+ * build.h
  * Automatically generated
  */
 #define BUILD_HOSTNAME "${HOSTNAME}"