SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2015-04-21 09:45:51 +00:00 committed by Git OBS Bridge
parent dc87c28a24
commit ba67084b43

View File

@ -9,7 +9,7 @@ Related to bnc#892096
1 file changed, 61 insertions(+), 10 deletions(-) 1 file changed, 61 insertions(+), 10 deletions(-)
--- systemd-219/src/random-seed/random-seed.c --- systemd-219/src/random-seed/random-seed.c
+++ systemd-219/src/random-seed/random-seed.c 2015-04-21 09:26:07.589518787 +0000 +++ systemd-219/src/random-seed/random-seed.c 2015-04-21 09:39:03.057518051 +0000
@@ -22,7 +22,9 @@ @@ -22,7 +22,9 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -86,14 +86,14 @@ Related to bnc#892096
- r = loop_write(random_fd, buf, (size_t) k, false); - r = loop_write(random_fd, buf, (size_t) k, false);
- if (r < 0) - if (r < 0)
- log_error_errno(r, "Failed to write seed to /dev/urandom: %m"); - log_error_errno(r, "Failed to write seed to /dev/urandom: %m");
+ if (entropy->entropy_count && (size_t) k == entropy->buf_size) { + if (entropy->entropy_count && ((size_t)k) == entropy->buf_size) {
+ r = ioctl(random_fd, RNDADDENTROPY, entropy); + r = ioctl(random_fd, RNDADDENTROPY, entropy);
+ if (r < 0) { + if (r < 0) {
+ log_error_errno(errno, "Failed to write seed to /dev/urandom: %m"); + log_error_errno(errno, "Failed to write seed to /dev/urandom: %m");
+ r = -errno; + r = -errno;
+ } + }
+ } else { + } else {
+ r = loop_write(random_fd, buf, (size_t) k, false); + r = loop_write(random_fd, entropy->buf, (size_t) k, false);
+ if (r < 0) + if (r < 0)
+ log_error_errno(r, "Failed to write seed to /dev/urandom: %m"); + log_error_errno(r, "Failed to write seed to /dev/urandom: %m");
+ } + }
@ -104,7 +104,7 @@ Related to bnc#892096
+ /* Read available entropy count, if possible */ + /* Read available entropy count, if possible */
+ f = fopen("/proc/sys/kernel/random/entropy_avail", "re"); + f = fopen("/proc/sys/kernel/random/entropy_avail", "re");
+ if (f) { + if (f) {
+ if (fscanf(f, "%zu", &entropy->entropy_count) < 0) + if (fscanf(f, "%d", &entropy->entropy_count) < 0)
+ entropy->entropy_count = 0; + entropy->entropy_count = 0;
+ fclose(f); + fclose(f);
+ } + }