Entropy check before password generation

This commit is contained in:
Bob Mottram 2015-11-24 10:22:55 +00:00
parent a8bd4680e8
commit 49593d8436
1 changed files with 5 additions and 0 deletions

View File

@ -237,6 +237,11 @@ EOF
echo ' if [ -f ~/login.txt ]; then' >> $rootdir/root/.bashrc
echo ' NEW_USER_PASSWORD=$(cat ~/login.txt)' >> $rootdir/root/.bashrc
echo ' else' >> $rootdir/root/.bashrc
echo ' ENTROPY=$(cat /proc/sys/kernel/random/entropy_avail)' >> $rootdir/root/.bashrc
echo ' if [ $ENTROPY -lt 500]; then' >> $rootdir/root/.bashrc
echo ' echo "WARNING: The entropy available on this system is too low to generate a password"' >> $rootdir/root/.bashrc
echo ' exit 5763' >> $rootdir/root/.bashrc
echo ' fi' >> $rootdir/root/.bashrc
echo ' NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"' >> $rootdir/root/.bashrc
echo ' fi' >> $rootdir/root/.bashrc
echo ' echo -n "${NEW_USER_PASSWORD}" > ~/login.txt' >> $rootdir/root/.bashrc