aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-04 04:47:51 -0400
committerJack Lloyd <[email protected]>2016-10-04 04:47:51 -0400
commit921cd40cbde252b36fb59cb4f957ab49abf39279 (patch)
tree397bf29eec1756fc7e1546d84a7a3a8b27c74d22 /src
parent210f82b75591eb6ca57cfefa6a72242a598a947f (diff)
parent467007928b2e929a67d68b22ff6d59a7a40b236a (diff)
Merge GH #648 Accept read-only access to /dev/urandom
See also GH #647
Diffstat (limited to 'src')
-rw-r--r--src/lib/rng/system_rng/system_rng.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/rng/system_rng/system_rng.cpp b/src/lib/rng/system_rng/system_rng.cpp
index 135f4fabd..1ea749327 100644
--- a/src/lib/rng/system_rng/system_rng.cpp
+++ b/src/lib/rng/system_rng/system_rng.cpp
@@ -75,6 +75,12 @@ System_RNG_Impl::System_RNG_Impl()
#endif
m_fd = ::open(BOTAN_SYSTEM_RNG_DEVICE, O_RDWR | O_NOCTTY);
+
+ // Cannot open in read-write mode. Fall back to read-only
+ // Calls to add_entropy will fail, but randomize will work
+ if(m_fd < 0)
+ m_fd = ::open(BOTAN_SYSTEM_RNG_DEVICE, O_RDONLY | O_NOCTTY);
+
if(m_fd < 0)
throw Exception("System_RNG failed to open RNG device");
#endif