I have a bash script that is reading quite a bit of data /dev/random. I need the user to type randomly to seed the random daemon. However once the script completes everything typed will get dumped to command input. Here's the code:
for i in ${users_thing[@]}
do
pass[${num}] = $(dd if=/dev/random status=noexfer bs=1 count=128 | base64) & #generate password
echo -n "Creating password: `expr $num + 1` of $sizes "
#tell what's going of
echo -en "\033[s"
while [[ $(jobs) != *Exit* ]] #while the program is still running
do
for j in ${spinny_thing[@]} #now spin
do
echo -en "\033[u\033[1D$j "
done
done
echo ""
num=`expr $num + 1`
done
So I would like to be able to dump the standard input without interrupting the foreground process so read
is out because it pauses. Would it be possible to some how map it /dev/null
?
#now spin you beotch!
what a nice comment. On a more serious note, might it be possible to have a child process readstdin
constantly? And just kill it when the parent is done? – Drew McGowen Jul 24 '14 at 20:27cat >/dev/null
is one way to readstdin
– Drew McGowen Jul 24 '14 at 20:41/dev/urandom
instead and negate the requirement to press keys. It has less entropy apparently - only you know if that will cause issues in your application. – garethTheRed Jul 24 '14 at 20:50cat >/dev/null &
and it didn't help at all. – Micah Jul 24 '14 at 21:00/dev/urandom
is also good for a cryptographically secure PRNG. Do you really really need the data to be that random? Are the stakes high enough for the time your users will lose? See also: http://security.stackexchange.com/questions/3936/is-a-rand-from-dev-urandom-secure-for-a-login-key – Valmiky Arquissandas Jul 24 '14 at 21:51/dev/random
, read from/dev/urandom
instead. It's just as secure for cryptography. Telling the user to type is dubious anyway because the entropy from keystrokes isn't that good. It's not only very user-unfriendly, it's also unnecessary complexity (which results in more bugs) and a false promise of security. Don't do it. – Gilles 'SO- stop being evil' Jul 25 '14 at 06:58