[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#3263: [sysvinit] /dev/urandom support



Package: sysvinit
Version: 2.62-1

The documentation of the random driver suggests some additions to the
boot, halt and reboot scripts to ensure unpredictability at system startup;
see linux/drivers/char/random.c . These additions are not present in
SysVinit; I'm including diffs based on the recommendations.

Please note that the current base (1.1.0-10) does not include /dev/random and 
/dev/urandom; bugs #2975 and #3039.

Note that the diffs are based on the assumption that it is best to do
the actions as early on in the boot process as possible (after having the
root fs rw, but before mounting local fs-s) and as late in the halt/reboot
as possible (after the killall and wtmp logging, but before deactivating
swap space).

Greetings,
Ray

--- /etc/init.d/boot.orig	Tue Jun 11 09:39:41 1996
+++ /etc/init.d/boot	Tue Jun 11 10:18:31 1996
@@ -108,6 +108,20 @@
   /etc/init.d/modules
 fi
 
+# Carry a random seed from start-up to start-up;
+# see documentation in linux/drivers/char/random.c
+if [ -c /dev/urandom ]
+then 
+  echo "Initializing random number generator..."
+  # Load and then save 512 bytes, which is the size of the entropy pool
+  if [ -f /etc/random-seed ]; then
+    cat /etc/random-seed >/dev/urandom
+  fi
+  dd if=/dev/urandom of=/etc/random-seed count=1 > /dev/null 2>&1 \
+      || echo "... failed."
+  chmod 600 /etc/random-seed
+fi
+
 # Mount local file systems in /etc/fstab.
 echo "Mounting local file systems..."
 mount -avt nonfs
--- /etc/init.d/halt.orig	Tue Jun 11 09:39:47 1996
+++ /etc/init.d/halt	Tue Jun 11 10:10:37 1996
@@ -18,6 +18,16 @@
 # Write a reboot record to /var/log/wtmp.
 halt -w
 
+# Carry a random seed from shut-down to start-up;
+# see documentation in linux/drivers/char/random.c
+if [ -c /dev/urandom ]
+then
+  # Save 512 bytes, which is the size of the entropy pool
+  echo "Saving random seed..."
+  dd if=/dev/urandom of=/etc/random-seed count=1 > /dev/null 2>&1 \
+      || echo "... failed."
+fi
+
 echo -n "Deactivating swap... "
 swapoff -a
 echo "done."
--- /etc/init.d/reboot.orig	Tue Jun 11 09:39:56 1996
+++ /etc/init.d/reboot	Tue Jun 11 10:10:27 1996
@@ -18,6 +18,16 @@
 # Write a reboot record to /var/log/wtmp.
 halt -w
 
+# Carry a random seed from shut-down to start-up;
+# see documentation in linux/drivers/char/random.c
+if [ -c /dev/urandom ]
+then
+  # Save 512 bytes, which is the size of the entropy pool
+  echo "Saving random seed..."
+  dd if=/dev/urandom of=/etc/random-seed count=1 > /dev/null 2>&1 \
+      || echo "...failed."
+fi
+
 echo -n "Deactivating swap... "
 swapoff -a
 echo "done."
-- 
POPULATION EXPLOSION  Unique in human experience, an event which happened 
yesterday but which everyone swears won't happen until tomorrow.  
- The Hipcrime Vocab by Chad C. Mulligan 


Reply to: