Skip to content

Commit ec23bb3

Browse files
committed
Try to force OpenJDK to use /dev/urandom.
See jruby/jruby#4685 and many others.
1 parent c53a5ad commit ec23bb3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

argparser.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
244244
javaOptions.push_back("-Dfile.encoding=UTF-8");
245245
}
246246
#endif
247+
248+
// Force OpenJDK-based JVMs to use /dev/urandom for random number generation
249+
// See https://github.com/jruby/jruby/issues/4685 among others.
250+
struct stat buffer;
251+
if (stat("/dev/urandom", &buffer) == 0) {
252+
// OpenJDK tries really hard to prevent you from using urandom.
253+
// See https://bugs.openjdk.java.net/browse/JDK-6202721
254+
javaOptions.push_back("-Djava.security.egd=/dev/./urandom");
255+
}
256+
247257
if (getenv("VERIFY_JRUBY") != NULL) {
248258
noBootClassPath = true;
249259
}

lib/jruby-launcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module JRubyLauncher
2-
VERSION = "1.1.2"
2+
VERSION = "1.1.3"
33
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
#ifndef _VERSION_H_
77
#define _VERSION_H_
88

9-
#define JRUBY_LAUNCHER_VERSION "1.1.2"
9+
#define JRUBY_LAUNCHER_VERSION "1.1.3"
1010

1111
#endif // ! _VERSION_H_

0 commit comments

Comments
 (0)