changeset 4568:140b6d549a5e

/dev/random is not writable on Haiku And since the default user is root, the open() call does not fail as expected.
author hamish
date Thu, 06 Sep 2012 19:42:09 +0100
parents 892e575949eb
children fd10746f1371
files src/solaris/classes/sun/security/provider/NativePRNG.java
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/security/provider/NativePRNG.java	Thu Sep 06 04:21:05 2012 +0100
+++ b/src/solaris/classes/sun/security/provider/NativePRNG.java	Thu Sep 06 19:42:09 2012 +0100
@@ -29,6 +29,7 @@
 
 import java.security.*;
 import java.security.SecureRandom;
+import sun.security.action.GetPropertyAction;
 
 /**
  * Native PRNG implementation for Solaris/Linux. It interacts with
@@ -161,11 +162,18 @@
         // mutex lock for setSeed()
         private final Object LOCK_SET_SEED = new Object();
 
+        // we can't write /dev/random on Haiku
+        private final boolean isHaiku;
+
         // constructor, called only once from initIO()
         private RandomIO(File randomFile, File urandomFile) throws IOException {
             randomIn = new FileInputStream(randomFile);
             urandomIn = new FileInputStream(urandomFile);
             urandomBuffer = new byte[BUFFER_SIZE];
+
+            String osname = AccessController
+                .doPrivileged(new GetPropertyAction("os.name"));
+            isHaiku = osname.equals("Haiku");
         }
 
         // get the SHA1PRNG for mixing
@@ -242,7 +250,7 @@
                         }
                     });
                 }
-                if (randomOut != null) {
+                if (randomOut != null && !isHaiku) {
                     try {
                         randomOut.write(seed);
                     } catch (IOException e) {