Re: Entropy device is blocked. Dance fandango on keyboard to unblock.

From: Mark Murray <mark_at_grondar.org>
Date: Wed, 23 Jun 2004 09:03:10 +0100
Scott Long writes:
> Yes, this will be a 5.3 showstopper item.  I will update the TODO list
> tonight.  MarkM, paging MarkM, you have a call on the Batphone.

:-)

Here is the proposed fix. Anyone want to try it before I commit?

M
--
Mark Murray
iumop ap!sdn w,I idlaH

Index: config.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/sysinstall/config.c,v
retrieving revision 1.222
diff -u -d -r1.222 config.c
--- config.c	7 May 2004 19:15:55 -0000	1.222
+++ config.c	22 Jun 2004 22:34:57 -0000
_at__at_ -389,6 +389,7 _at__at_
 {
     char line[256];
     FILE *rcSite, *rcOld;
+    int rcRNG, rcEntropy;
     Variable *v;
     int write_header;
     time_t t_loc;
_at__at_ -396,6 +397,8 _at__at_
     static int did_marker = 0;
     int do_sort;
     int do_merge;
+    int do_rng;
+    int i;
     time_t tp;
 
     configTtys();
_at__at_ -403,6 +406,7 _at__at_
     do_sort = RunningAsInit && file_readable("/usr/bin/sort") &&
 	file_readable("/usr/bin/uniq");
     do_merge = do_sort && file_readable("/etc/rc.conf");
+    do_rng = RunningAsInit;
 
     if(do_merge) {
 	rcSite = fopen("/etc/rc.conf.new", "w");
_at__at_ -462,6 +466,31 _at__at_
     if (do_sort) {
 	(void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf");
     }
+
+    /* Kickstart the new RNG with a new /entropy file */
+    if (do_rng) {
+	rcRNG = open("/dev/random", O_RDONLY);
+	if(rcRNG == -1) {
+	    msgError("Error opening /dev/random for reading: %s (%u)",
+                strerror(errno), errno);
+	    return;
+	}
+	rcEntropy = open("/entropy", O_WRONLY|O_CREAT, 0600);
+	if(rcEntropy == -1) {
+	    msgError("Error opening /entropy for writing: %s (%u)",
+                strerror(errno), errno);
+	    close(rcRNG);
+	    return;
+	}
+
+        for (i = 0; i < 2048; i += (int)sizeof(line)) {
+            read(rcRNG, line, sizeof(line));
+            write(rcEntropy, line, sizeof(line));
+        }
+
+	close(rcEntropy);
+	close(rcRNG);
+    }
 }
 
 int
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/sysinstall/main.c,v
retrieving revision 1.71
diff -u -d -r1.71 main.c
--- main.c	20 Aug 2003 06:27:21 -0000	1.71
+++ main.c	22 Jun 2004 22:29:03 -0000
_at__at_ -50,6 +50,7 _at__at_
 int
 main(int argc, char **argv)
 {
+    FILE *rng;
     int choice, scroll, curr, max, status;
     
     /* Record name to be able to restart */
_at__at_ -77,6 +78,14 _at__at_
     }
 #endif
 
+    /* Unblock RNG. This could be replaced with something to make the
+     * human installer generate some entropy, but we'll likely get
+     * as much or better through the install/reboot.
+     */
+    rng = fopen("/dev/random", "w");
+    fprintf(rng, "unlock");
+    fclose(rng);
+
     /* Set up whatever things need setting up */
     systemInitialize(argc, argv);
 
Received on Wed Jun 23 2004 - 06:04:43 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:58 UTC