]> andersk Git - openssh.git/commitdiff
- (djm) Make inability to read/write PRNG seedfile non-fatal
authordjm <djm>
Mon, 16 Oct 2000 09:13:43 +0000 (09:13 +0000)
committerdjm <djm>
Mon, 16 Oct 2000 09:13:43 +0000 (09:13 +0000)
ChangeLog
entropy.c

index ed4a40a871b3bc3b44be1fcb2431b15beb73d2b4..655df5f90450c4aab8c40270dc0e2573de7a13bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,8 @@
  - (djm) Update version in Redhat spec file
  - (djm) Merge some of Nalin Dahyabhai <nalin@redhat.com> changes from the 
    Redhat 7.0 spec file
+ - (djm) Make inability to read/write PRNG seedfile non-fatal
+
 
 20001015
  - (djm) Fix ssh2 hang on background processes at logout.
index ab4a13eda731c747189571d0debfef44a909aa01..e4aee8a1c9cb9765bc1bccf227fc23d408128801 100644 (file)
--- a/entropy.c
+++ b/entropy.c
@@ -514,10 +514,10 @@ prng_check_seedfile(char *filename) {
        /* FIXME raceable: eg replace seed between this stat and subsequent open */
        /* Not such a problem because we don't trust the seed file anyway */
        if (lstat(filename, &st) == -1) {
-               /* Fail on hard errors */
+               /* Give up on hard errors */
                if (errno != ENOENT)
-                       fatal("Couldn't stat random seed file \"%s\": %s", filename,
-                               strerror(errno));
+                       debug("WARNING: Couldn't stat random seed file \"%s\": %s", 
+                          filename, strerror(errno));
 
                return(0);
        }
@@ -527,10 +527,12 @@ prng_check_seedfile(char *filename) {
                fatal("PRNG seedfile %.100s is not a regular file", filename);
 
        /* mode 0600, owned by root or the current user? */
-       if (((st.st_mode & 0177) != 0) || !(st.st_uid == original_uid))
-               fatal("PRNG seedfile %.100s must be mode 0600, owned by uid %d",
+       if (((st.st_mode & 0177) != 0) || !(st.st_uid == original_uid)) {
+               debug("WARNING: PRNG seedfile %.100s must be mode 0600, owned by uid %d",
                         filename, getuid());
-
+               return(0);
+       }
+       
        return(1);
 }
 
@@ -569,15 +571,16 @@ prng_write_seedfile(void) {
        /* Don't care if the seed doesn't exist */
        prng_check_seedfile(filename);
        
-       if ((fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0600)) == -1)
-               fatal("couldn't access PRNG seedfile %.100s (%.100s)", filename
-                       strerror(errno));
-       
-       if (atomicio(write, fd, &seed, sizeof(seed)) != sizeof(seed))
-               fatal("problem writing PRNG seedfile %.100s (%.100s)", filename, 
-                        strerror(errno));
+       if ((fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0600)) == -1) {
+               debug("WARNING: couldn't access PRNG seedfile %.100s (%.100s)"
+                  filename, strerror(errno));
+       } else {        
+               if (atomicio(write, fd, &seed, sizeof(seed)) != sizeof(seed))
+                       fatal("problem writing PRNG seedfile %.100s (%.100s)", filename, 
+                                strerror(errno));
 
-       close(fd);
+               close(fd);
+       }
 }
 
 void
This page took 0.326496 seconds and 5 git commands to generate.