Allow urandom location to be customized #134489.
This commit is contained in:
parent
1bf11dcfb6
commit
6e8f3dabf7
@ -1,6 +1,10 @@
|
|||||||
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
||||||
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
||||||
|
|
||||||
|
21 Jun 2007; Mike Frysinger <vapier@gentoo.org>:
|
||||||
|
|
||||||
|
Allow urandom location to be customized #134489.
|
||||||
|
|
||||||
02 Jun 2007; Mike Frysinger <vapier@gentoo.org>:
|
02 Jun 2007; Mike Frysinger <vapier@gentoo.org>:
|
||||||
|
|
||||||
Fix from comio for /proc/filesystems typo in localmount #180621.
|
Fix from comio for /proc/filesystems typo in localmount #180621.
|
||||||
|
8
conf.d/urandom
Normal file
8
conf.d/urandom
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# /etc/conf.d/urandom
|
||||||
|
|
||||||
|
# Sometimes you want to have urandom start before "localmount"
|
||||||
|
# (say for crypt swap), so you will need to customize this
|
||||||
|
# behavior. If you have /var on a separate partition, then
|
||||||
|
# make sure this path lives on your root device somewhere.
|
||||||
|
|
||||||
|
URANDOM_SEED="/var/run/random-seed"
|
@ -2,6 +2,8 @@
|
|||||||
# Copyright 1999-2007 Gentoo Foundation
|
# Copyright 1999-2007 Gentoo Foundation
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
|
URANDOM_SEED=${URANDOM_SEED:-/var/run/random-seed}
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need localmount
|
need localmount
|
||||||
}
|
}
|
||||||
@ -13,23 +15,24 @@ save_seed() {
|
|||||||
poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
|
poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
umask 077
|
( # sub shell to prevent umask pollution
|
||||||
dd if=/dev/urandom of=/var/run/random-seed count=${poolsize} 2>/dev/null
|
umask 077
|
||||||
|
dd if=/dev/urandom of="${URANDOM_SEED}" count=${poolsize} 2>/dev/null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
[ -c /dev/urandom ] || return
|
[ -c /dev/urandom ] || return
|
||||||
if [ -f /var/run/random-seed ] ; then
|
if [ -f "${URANDOM_SEED}" ] ; then
|
||||||
cat /var/run/random-seed > /dev/urandom
|
cat "${URANDOM_SEED}" > /dev/urandom
|
||||||
fi
|
fi
|
||||||
if ! rm -f /var/run/random-seed ; then
|
if ! rm -f "${URANDOM_SEED}" ; then
|
||||||
ewarn "Skipping /var/run/random-seed initialization (ro root?)"
|
ewarn "Skipping ${URANDOM_SEED} initialization (ro root?)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
ebegin "Initializing random number generator"
|
ebegin "Initializing random number generator"
|
||||||
save_seed
|
save_seed
|
||||||
eend $? "Error initializing random number generator"
|
eend $? "Error initializing random number generator"
|
||||||
umask 022
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
Loading…
Reference in New Issue
Block a user