From ac49c8c278d40d7a83c4fd1dd1861153a402d19c Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 8 Mar 2007 08:30:28 +1300 Subject: [PATCH] Ensure that _some_ password is set. dd /dev/urandom seems to work quite well, actually. --- dba/create-database.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dba/create-database.sh b/dba/create-database.sh index 879903fd..96f7da24 100755 --- a/dba/create-database.sh +++ b/dba/create-database.sh @@ -33,11 +33,12 @@ if [ "${ADMINPW}" = "" ] ; then # # Generate a random administrative password. If pwgen is available we'll use that, # otherwise try and hack something up using a few standard utilities - PWGEN="`which pwgen`" - if [ "$PWGEN" = "" ] ; then + ADMINPW="`pwgen -Bcny 2>/dev/null | tr \"\\\'\" '^='`" + if [ "$ADMINPW" = "" ] ; then ADMINPW="`dd if=/dev/urandom bs=512 count=1 2>/dev/null | tr -c -d "[:alnum:]" | cut -c2-9`" - else - ADMINPW="`pwgen -Bcny | tr \"\\\'\" '^='`" + fi + if [ "$ADMINPW" = "" ] ; then + ADMINPW="please change this password" fi fi psql -q -c "UPDATE usr SET password = '**${ADMINPW}' WHERE user_no = 1;" "${DBNAME}"