Skip to content

Commit 545da13

Browse files
committed
Improvement to Java security random source.
Fixes jruby/jruby#4857. Apparently the JDK will fail to use the egd path without a file URL. Stop the madness! See https://bz.apache.org/bugzilla/show_bug.cgi?id=56139
1 parent ec23bb3 commit 545da13

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

argparser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,12 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
248248
// Force OpenJDK-based JVMs to use /dev/urandom for random number generation
249249
// See https://github.com/jruby/jruby/issues/4685 among others.
250250
struct stat buffer;
251-
if (stat("/dev/urandom", &buffer) == 0) {
251+
if (access("/dev/urandom", R_OK) == 0) {
252252
// OpenJDK tries really hard to prevent you from using urandom.
253253
// See https://bugs.openjdk.java.net/browse/JDK-6202721
254-
javaOptions.push_back("-Djava.security.egd=/dev/./urandom");
254+
// Non-file URL causes fallback to slow threaded SeedGenerator.
255+
// See https://bz.apache.org/bugzilla/show_bug.cgi?id=56139
256+
javaOptions.push_back("-Djava.security.egd=file:/dev/urandom");
255257
}
256258

257259
if (getenv("VERIFY_JRUBY") != NULL) {

0 commit comments

Comments
 (0)