From ce5a624ca88bcccf1591265d26bc28d27e822da1 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 29 Feb 2016 16:43:14 -0500 Subject: Check for test and netstat before trying to use them These may not be available on all systems. Work around it best we can. In the case of netstat this can be replaced by using /dev/urandom or /dev/random instead and piping it through tr to produce only ASCII strings. --- gencert.in | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gencert.in b/gencert.in index e437a60..490c396 100755 --- a/gencert.in +++ b/gencert.in @@ -39,7 +39,11 @@ getFQDN() { return fi defhost=`hostname` - hosthost=`host $defhost | grep -v "not found" | awk '{print $1}'` + if [ -e /usr/bin/host -o -e /bin/host ]; then + hosthost=`host $defhost | grep -v "not found" | awk '{print $1}'` + else + hosthost='' + fi for host in $defhost $hosthost `hostname -f` `hostname -a` ; do len=`echo $host | wc -c` if [ $len -gt $max ]; then @@ -124,7 +128,11 @@ function generate_server_sni_cert { echo "#####################################################################" echo "Generating $NICKNAME server certificate request" echo "#####################################################################" - (ps -elf; date; netstat -a) > $DEST/noise + if [ -e /dev/urandom ]; then + (ps -elf; date; dd if=/dev/urandom count=1 bs=1024 2>/dev/null| tr -dc 'a-zA-Z0-9') > $DEST/noise + else + (ps -elf; date; dd if=/dev/random count=1 bs=128 2>/dev/null| tr -dc 'a-zA-Z0-9') > $DEST/noise + fi $CERTUTIL -R -d $DBDIR \ -s "$SERVER_DN" \ -o $DEST/tmpcertreq \ -- cgit