Sfoglia il codice sorgente

Entropy check before password generation

Bob Mottram 9 anni fa
parent
commit
49593d8436
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5
    0
      src/freedombone-image-customise

+ 5
- 0
src/freedombone-image-customise Vedi File

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