[experimental-ims] f1951c4 Seed random() on startup from /dev/urandom so vtmpfile actually returns random file names

Geoff Simmons geoff at varnish-cache.org
Mon Aug 1 13:18:18 CEST 2011


commit f1951c46026a144ee65b2a7114080ca22866d487
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Jun 10 09:43:48 2011 +0200

    Seed random() on startup from /dev/urandom so vtmpfile actually
    returns random file names

diff --git a/lib/libvarnish/vtmpfile.c b/lib/libvarnish/vtmpfile.c
index 327790a..c998fc2 100644
--- a/lib/libvarnish/vtmpfile.c
+++ b/lib/libvarnish/vtmpfile.c
@@ -48,12 +48,8 @@ seed_random(void)
 	unsigned seed;
 
 	fd = open("/dev/urandom", O_RDONLY);
-	if (fd == -1) {
-		/* urandom not available, fall back to something
-		 * weaker */
-		srandom(time(NULL));
-		return (0);
-	}
+	if (fd == -1)
+		return (1);
 	if (read(fd, &seed, sizeof seed) != sizeof seed)
 		return (1);
 	(void)close(fd);



More information about the varnish-commit mailing list