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

Geoff Simmons geoff at varnish-cache.org
Wed Aug 31 16:05:00 CEST 2011


commit d58cad0ad57330cd165c68466b6f44fba9d9896b
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