From de0b17ac11a62b2c5656f9147147f0a2782fcae0 Mon Sep 17 00:00:00 2001 From: xSmurf Date: Mon, 5 Oct 2015 03:58:41 +0000 Subject: [PATCH] Fix hostname-spoof when openssl bin is not present --- .../coreboot/rootfs-additions/etc/init.d/S25hostname-spoof | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/board/coreboot/rootfs-additions/etc/init.d/S25hostname-spoof b/board/coreboot/rootfs-additions/etc/init.d/S25hostname-spoof index 1dc0a08..bc15e04 100755 --- a/board/coreboot/rootfs-additions/etc/init.d/S25hostname-spoof +++ b/board/coreboot/rootfs-additions/etc/init.d/S25hostname-spoof @@ -2,7 +2,6 @@ do_start() { #FILE=/usr/share/dict/hostname-list - if [ -f "/etc/hostname" ]; then OLDHOST="$(cat /etc/hostname)" else @@ -23,7 +22,11 @@ do_start() { NOTFOUND=0 until [ "${NOTFOUND}" -gt "0" ]; do #WORD=$(/usr/bin/shuf -n1 "$FILE") - WORD=$(/usr/bin/openssl rand -hex 8) + if [ -e /usr/bin/openssl ]; then + WORD=$(/usr/bin/openssl rand -hex 8) + else + WORD=$(dd if=/dev/urandom bs=8 count1 2>>/dev/null | /usr/bin/hexdump -v -e '/1 "%02x"') + fi ES=$? if [ $ES -gt 0 ]; then echo "Error getting random hostname!"