diff random.c @ 641:2b1bb792cd4d dropbear-tfm

- Update tfm changes to current default tip
author Matt Johnston <matt@ucc.asn.au>
date Mon, 21 Nov 2011 19:52:28 +0800
parents 76097ec1a29a 2d896267f16d
children
line wrap: on
line diff
--- a/random.c	Mon Nov 21 19:19:57 2011 +0800
+++ b/random.c	Mon Nov 21 19:52:28 2011 +0800
@@ -64,32 +64,23 @@
 #ifdef DROPBEAR_RANDOM_DEV
 	readfd = open(DROPBEAR_RANDOM_DEV, O_RDONLY);
 	if (readfd < 0) {
-		dropbear_exit("couldn't open random device");
+		dropbear_exit("Couldn't open random device");
 	}
 #endif
 
 #ifdef DROPBEAR_PRNGD_SOCKET
-	memset((void*)&egdsock, 0x0, sizeof(egdsock));
-	egdsock.sun_family = AF_UNIX;
-	strlcpy(egdsock.sun_path, DROPBEAR_PRNGD_SOCKET,
-			sizeof(egdsock.sun_path));
+	readfd = connect_unix(DROPBEAR_PRNGD_SOCKET);
 
-	readfd = socket(PF_UNIX, SOCK_STREAM, 0);
 	if (readfd < 0) {
-		dropbear_exit("couldn't open random device");
-	}
-	/* todo - try various common locations */
-	if (connect(readfd, (struct sockaddr*)&egdsock, 
-			sizeof(struct sockaddr_un)) < 0) {
-		dropbear_exit("couldn't open random device");
+		dropbear_exit("Couldn't open random device");
 	}
 
 	if (buflen > 255)
-		dropbear_exit("can't request more than 255 bytes from egd");
+		dropbear_exit("Can't request more than 255 bytes from egd");
 	egdcmd[0] = 0x02;	/* blocking read */
 	egdcmd[1] = (unsigned char)buflen;
 	if (write(readfd, egdcmd, 2) < 0)
-		dropbear_exit("can't send command to egd");
+		dropbear_exit("Can't send command to egd");
 #endif
 
 	/* read the actual random data */
@@ -118,7 +109,7 @@
 			if (readlen < 0 && errno == EINTR) {
 				continue;
 			}
-			dropbear_exit("error reading random source");
+			dropbear_exit("Error reading random source");
 		}
 		readpos += readlen;
 	} while (readpos < buflen);