/[baselayout]/trunk/init.d/urandom
Gentoo

Diff of /trunk/init.d/urandom

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2694 Revision 2695
2# Copyright 1999-2007 Gentoo Foundation 2# Copyright 1999-2007 Gentoo Foundation
3# Distributed under the terms of the GNU General Public License v2 3# Distributed under the terms of the GNU General Public License v2
4 4
5depend() { 5depend() {
6 need localmount 6 need localmount
7}
8
9save_seed() {
10 local poolsize=1
11
12 if [ -e /proc/sys/kernel/random/poolsize ] ; then
13 poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
14 fi
15
16 umask 077
17 dd if=/dev/urandom of=/var/run/random-seed count=${poolsize} 2>/dev/null
7} 18}
8 19
9start() { 20start() {
10 [ -c /dev/urandom ] || return 21 [ -c /dev/urandom ] || return
11 if [ -f /var/run/random-seed ] ; then 22 if [ -f /var/run/random-seed ] ; then
14 if ! rm -f /var/run/random-seed ; then 25 if ! rm -f /var/run/random-seed ; then
15 ewarn "Skipping /var/run/random-seed initialization (ro root?)" 26 ewarn "Skipping /var/run/random-seed initialization (ro root?)"
16 return 0 27 return 0
17 fi 28 fi
18 ebegin "Initializing random number generator" 29 ebegin "Initializing random number generator"
19 umask 077 30 save_seed
20 dd if=/dev/urandom of=/var/run/random-seed count=1 2>/dev/null
21 eend $? "Error initializing random number generator" 31 eend $? "Error initializing random number generator"
22 umask 022 32 umask 022
23} 33}
24 34
25stop() { 35stop() {
26 ebegin "Saving random seed" 36 ebegin "Saving random seed"
27 # Carry a random seed from shut-down to start-up; 37 # Carry a random seed from shut-down to start-up;
28 # see documentation in linux/drivers/char/random.c 38 # see documentation in linux/drivers/char/random.c
29 umask 077 39 save_seed
30 dd if=/dev/urandom of=/var/run/random-seed count=1 2>/dev/null
31 eend $? "Failed to save random seed" 40 eend $? "Failed to save random seed"
32} 41}
33 42
34# vim:ts=4 43# vim: set ts=4 :

Legend:
Removed from v.2694  
changed lines
  Added in v.2695

  ViewVC Help
Powered by ViewVC 1.1.20