Subject: misc/35274: rc script for seeding /dev/random
To: None <misc-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Denis Lagno <dlagno@rambler.ru>
List: netbsd-bugs
Date: 12/18/2006 23:30:00
>Number: 35274
>Category: misc
>Synopsis: rc script for seeding /dev/random
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: misc-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Dec 18 23:30:00 +0000 2006
>Originator: Denis Lagno
>Release: NetBSD 4.99.3
>Organization:
>Environment:
>Description:
it would be nice to add rc script for seeding /dev/random on boot
>How-To-Repeat:
>Fix:
/etc/rc.d/randseed:
#!/bin/sh
# REQUIRE: mountcritlocal
# BEFORE: sshd xdm
# PROVIDE: randseed
# KEYWORD: shutdown
$_rc_subr_loaded . /etc/rc.subr
name="randseed"
rcvar=$name
start_cmd="randseed_start"
stop_cmd="randseed_stop"
randseed_file=${randseed_file:-/var/db/randseed}
randseed_size=${randseed_size:-4}
dump_randseed()
{
cat < /dev/null > $randseed_file
chmod 600 $randseed_file
dd if=/dev/urandom of=$randseed_file bs=1024 count=$randseed_size 2> /dev/null
}
randseed_start()
{
if [ -f $randseed_file ]; then
echo "Seeding /dev/random"
cat $randseed_file > /dev/random 2> /dev/null
fi
dump_randseed
}
randseed_stop()
{
echo "Saving seed for /dev/random"
dump_randseed
}
load_rc_config $name
run_rc_command "$1"