aboutsummaryrefslogtreecommitdiff
path: root/init.d/urandom
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-06-22 02:57:40 +0000
committerMike Frysinger <vapier@gentoo.org>2007-06-22 02:57:40 +0000
commit6e8f3dabf7b84f6048a915ff5986a018e985ca80 (patch)
tree564d46d0617fb1f39fc2fe909a33f647a5cef68d /init.d/urandom
parent1bf11dcfb61fba06ef3d4f696a3c302a21dfc2ed (diff)
Allow urandom location to be customized #134489.
Diffstat (limited to 'init.d/urandom')
-rwxr-xr-xinit.d/urandom17
1 files changed, 10 insertions, 7 deletions
diff --git a/init.d/urandom b/init.d/urandom
index b901d6d8..ecded0a5 100755
--- a/init.d/urandom
+++ b/init.d/urandom
@@ -2,6 +2,8 @@
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+URANDOM_SEED=${URANDOM_SEED:-/var/run/random-seed}
+
depend() {
need localmount
}
@@ -13,23 +15,24 @@ save_seed() {
poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
fi
- umask 077
- dd if=/dev/urandom of=/var/run/random-seed count=${poolsize} 2>/dev/null
+ ( # sub shell to prevent umask pollution
+ umask 077
+ dd if=/dev/urandom of="${URANDOM_SEED}" count=${poolsize} 2>/dev/null
+ )
}
start() {
[ -c /dev/urandom ] || return
- if [ -f /var/run/random-seed ] ; then
- cat /var/run/random-seed > /dev/urandom
+ if [ -f "${URANDOM_SEED}" ] ; then
+ cat "${URANDOM_SEED}" > /dev/urandom
fi
- if ! rm -f /var/run/random-seed ; then
- ewarn "Skipping /var/run/random-seed initialization (ro root?)"
+ if ! rm -f "${URANDOM_SEED}" ; then
+ ewarn "Skipping ${URANDOM_SEED} initialization (ro root?)"
return 0
fi
ebegin "Initializing random number generator"
save_seed
eend $? "Error initializing random number generator"
- umask 022
}
stop() {