Entropy device is blocked. Dance fandango on keyboard to
unblock.
Mark Murray
mark at grondar.org
Wed Jun 23 08:04:43 GMT 2004
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
-------------- next part --------------
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
@@ -389,6 +389,7 @@
{
char line[256];
FILE *rcSite, *rcOld;
+ int rcRNG, rcEntropy;
Variable *v;
int write_header;
time_t t_loc;
@@ -396,6 +397,8 @@
static int did_marker = 0;
int do_sort;
int do_merge;
+ int do_rng;
+ int i;
time_t tp;
configTtys();
@@ -403,6 +406,7 @@
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");
@@ -462,6 +466,31 @@
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
@@ -50,6 +50,7 @@
int
main(int argc, char **argv)
{
+ FILE *rng;
int choice, scroll, curr, max, status;
/* Record name to be able to restart */
@@ -77,6 +78,14 @@
}
#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);
More information about the freebsd-current
mailing list