Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 34 | Blame | Compare with Previous | Last modification | View Log | RSS feed

Author: Magnus Holmgren <holmgren@debian.org>
Description: Show the intended error message when no seed file exists
 (instead of one about a locking error)

diff -urNad trunk~/src/unix_random.c trunk/src/unix_random.c
--- trunk~/src/unix_random.c    2006-01-23 18:47:10.000000000 +0100
+++ trunk/src/unix_random.c     2008-06-24 22:29:29.000000000 +0200
@@ -353,6 +353,15 @@
 
     yarrow256_init(&self->yarrow, RANDOM_NSOURCES, self->sources);
     
+    if (access(lsh_get_cstring(seed_file_name), F_OK) < 0)
+      {
+       werror("No seed file. Please create one by running\n");
+       werror("lsh-make-seed -o \"%S\".\n", seed_file_name);
+
+       KILL(self);
+       return NULL;
+      }
+
     verbose("Reading seed-file `%S'\n", seed_file_name);
     
     self->lock
@@ -374,8 +383,7 @@
     self->seed_file_fd = open(lsh_get_cstring(seed_file_name), O_RDWR);
     if (self->seed_file_fd < 0)
       {
-       werror("No seed file. Please create one by running\n");
-       werror("lsh-make-seed -o \"%S\".\n", seed_file_name);
+       werror("Could not open seed file \"%S\".\n", seed_file_name);
 
        KILL_RESOURCE(lock);
        KILL(self);