chiark / gitweb /
Use /dev/urandom (or corresponding file) by default in --both mode
[vbig.git] / vbig.cc
diff --git a/vbig.cc b/vbig.cc
index 5dcb42136e25000db7ba623d15b97a6ec2f76011..d2cc1a2c8ce4b8b28ade90a2fb98321a8a0403e7 100644 (file)
--- a/vbig.cc
+++ b/vbig.cc
@@ -54,15 +54,15 @@ static void help(void) {
          "  vbig [--seed SEED] --verify|--create PATH [SIZE]\n"
          "\n"
          "Options:\n"
-         "  --seed, -s     Specify random seed as string\n"
-         "  --seed-file, -S Read random seed from (start of) this file\n"
+         "  --seed, -s        Specify random seed as string\n"
+         "  --seed-file, -S   Read random seed from (start of) this file\n"
          "  --seed-length, -L Set (maximum) seed length to read from file\n"
-         "  --verify, -v   Verify that PATH contains the expected contents\n"
-         "  --create, -c   Create PATH with psuedo-random contents\n"
-         "  --flush, -f    Flush cache\n"
-         "  --entire, -e   Write until full; read until EOF\n"
-         "  --help, -h     Display usage message\n"
-         "  --version, -V  Display version string\n");
+         "  --verify, -v      Verify that PATH contains the expected contents\n"
+         "  --create, -c      Create PATH with psuedo-random contents\n"
+         "  --flush, -f       Flush cache\n"
+         "  --entire, -e      Write until full; read until EOF\n"
+         "  --help, -h        Display usage message\n"
+         "  --version, -V     Display version string\n");
 }
 
 // Possible modes of operation
@@ -163,6 +163,14 @@ int main(int argc, char **argv) {
   }
   if(seed && seedpath)
     fatal(0, "both --seed and --seed-file specified");
+  if(mode == BOTH && !seed && !seedpath) {
+#ifdef HAVE_RANDOM_DEVICE
+    seedpath = RANDOM_DEVICE;
+#else
+    fatal(0, "no --seed or --seed-file specified in --both mode"
+         " and random device not supported on this system");
+#endif
+  }
   if(seedpath) {
     if(!seedlen)
       seedlen = DEFAULT_SEED_LENGTH;