blob: eecac2d4c3afd4d0de3979e09d6396587069b7b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# urandom-save - save a new seed-file, for use by kernel PRNG at next boot
#
description "save seed-file for use by kernel PRNG"
# a) We should refresh the seed-file as soon as possible
# i.e. as soon as the filesystem is mounted and writeable.
# b) We should also refresh it again as late as possible,
# i.e. when shutting down, i.e. runlevels other than 2345
start on (filesystem or runlevel [!2345])
task
console output
script
SAVEDFILE=/var/lib/urandom/random-seed # probably belongs in a config file
# 512 is usually the right size, as documented in drivers/char/random.c
POOLSIZE=512 # size in bytes
if test -f /proc/sys/kernel/random/poolsize \
&& ProcPoolSize="$(cat /proc/sys/kernel/random/poolsize)" ; then
# Kernels 2.6.12 and later report poolsize in bits; we convert to bytes here:
POOLSIZE=$((ProcPoolSize/8))
fi
dd if=/dev/urandom of=$SAVEDFILE bs=$POOLSIZE count=1 >/dev/null 2>&1
end script
|