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

Contents of /trunk/init.d/urandom

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2695 - (show annotations) (download)
Fri May 11 10:33:49 2007 UTC (7 years, 3 months ago) by uberlord
File size: 981 byte(s)
Store the defined random pool size, #177722 thanks to Yaroslav Isakov.
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 depend() {
6 need localmount
7 }
8
9 save_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
18 }
19
20 start() {
21 [ -c /dev/urandom ] || return
22 if [ -f /var/run/random-seed ] ; then
23 cat /var/run/random-seed > /dev/urandom
24 fi
25 if ! rm -f /var/run/random-seed ; then
26 ewarn "Skipping /var/run/random-seed initialization (ro root?)"
27 return 0
28 fi
29 ebegin "Initializing random number generator"
30 save_seed
31 eend $? "Error initializing random number generator"
32 umask 022
33 }
34
35 stop() {
36 ebegin "Saving random seed"
37 # Carry a random seed from shut-down to start-up;
38 # see documentation in linux/drivers/char/random.c
39 save_seed
40 eend $? "Failed to save random seed"
41 }
42
43 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20