forked from pool/systemd
.
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=867
This commit is contained in:
parent
4d4e08c3a1
commit
dc87c28a24
@ -5,11 +5,11 @@ write back the bytes and increase the entropy bit counter.
|
|||||||
Related to bnc#892096
|
Related to bnc#892096
|
||||||
|
|
||||||
---
|
---
|
||||||
systemd-210/src/random-seed/random-seed.c | 73 +++++++++++++++++++++++++-----
|
systemd-219/src/random-seed/random-seed.c | 71 +++++++++++++++++++++++++-----
|
||||||
1 file changed, 62 insertions(+), 11 deletions(-)
|
1 file changed, 61 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
--- systemd-210/src/random-seed/random-seed.c
|
--- systemd-219/src/random-seed/random-seed.c
|
||||||
+++ systemd-210/src/random-seed/random-seed.c 2015-04-14 11:38:08.617519434 +0000
|
+++ systemd-219/src/random-seed/random-seed.c 2015-04-21 09:26:07.589518787 +0000
|
||||||
@@ -22,7 +22,9 @@
|
@@ -22,7 +22,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -31,7 +31,7 @@ Related to bnc#892096
|
|||||||
size_t buf_size = 0;
|
size_t buf_size = 0;
|
||||||
ssize_t k;
|
ssize_t k;
|
||||||
int r;
|
int r;
|
||||||
@@ -64,11 +66,12 @@ int main(int argc, char *argv[]) {
|
@@ -65,11 +67,12 @@ int main(int argc, char *argv[]) {
|
||||||
if (buf_size <= POOL_SIZE_MIN)
|
if (buf_size <= POOL_SIZE_MIN)
|
||||||
buf_size = POOL_SIZE_MIN;
|
buf_size = POOL_SIZE_MIN;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ Related to bnc#892096
|
|||||||
|
|
||||||
r = mkdir_parents_label(RANDOM_SEED, 0755);
|
r = mkdir_parents_label(RANDOM_SEED, 0755);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@@ -82,6 +85,23 @@ int main(int argc, char *argv[]) {
|
@@ -83,6 +86,23 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (streq(argv[1], "load")) {
|
if (streq(argv[1], "load")) {
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ Related to bnc#892096
|
|||||||
seed_fd = open(RANDOM_SEED, O_RDWR|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
|
seed_fd = open(RANDOM_SEED, O_RDWR|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
|
||||||
if (seed_fd < 0) {
|
if (seed_fd < 0) {
|
||||||
seed_fd = open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
seed_fd = open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||||
@@ -102,7 +122,7 @@ int main(int argc, char *argv[]) {
|
@@ -104,7 +124,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,29 +79,25 @@ Related to bnc#892096
|
|||||||
if (k <= 0) {
|
if (k <= 0) {
|
||||||
|
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
@@ -113,16 +133,32 @@ int main(int argc, char *argv[]) {
|
@@ -115,13 +135,29 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
lseek(seed_fd, 0, SEEK_SET);
|
lseek(seed_fd, 0, SEEK_SET);
|
||||||
|
|
||||||
- k = loop_write(random_fd, buf, (size_t) k, false);
|
- r = loop_write(random_fd, buf, (size_t) k, false);
|
||||||
- if (k <= 0) {
|
- if (r < 0)
|
||||||
- log_error("Failed to write seed to /dev/urandom: %s", r < 0 ? strerror(-r) : "short write");
|
- 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("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 {
|
||||||
+ k = loop_write(random_fd, entropy->buf, (size_t) k, false);
|
+ r = loop_write(random_fd, buf, (size_t) k, false);
|
||||||
+ if (k <= 0) {
|
+ if (r < 0)
|
||||||
+ log_error("Failed to write seed to /dev/urandom: %s", r < 0 ? strerror(-r) : "short write");
|
+ log_error_errno(r, "Failed to write seed to /dev/urandom: %m");
|
||||||
|
|
||||||
- r = k == 0 ? -EIO : (int) k;
|
|
||||||
+ r = k == 0 ? -EIO : (int) k;
|
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} else if (streq(argv[1], "save")) {
|
} else if (streq(argv[1], "save")) {
|
||||||
|
|
||||||
@ -115,8 +111,8 @@ Related to bnc#892096
|
|||||||
+
|
+
|
||||||
seed_fd = open(RANDOM_SEED, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
|
seed_fd = open(RANDOM_SEED, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
|
||||||
if (seed_fd < 0) {
|
if (seed_fd < 0) {
|
||||||
log_error("Failed to open " RANDOM_SEED ": %m");
|
log_error_errno(errno, "Failed to open " RANDOM_SEED ": %m");
|
||||||
@@ -137,6 +173,21 @@ int main(int argc, char *argv[]) {
|
@@ -136,6 +172,21 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +146,6 @@ Related to bnc#892096
|
|||||||
} else {
|
} else {
|
||||||
- r = loop_write(seed_fd, buf, (size_t) k, false);
|
- r = loop_write(seed_fd, buf, (size_t) k, false);
|
||||||
+ r = loop_write(seed_fd, entropy->buf, (size_t) k, false);
|
+ r = loop_write(seed_fd, entropy->buf, (size_t) k, false);
|
||||||
if (r <= 0) {
|
if (r < 0)
|
||||||
log_error("Failed to write new random seed file: %s", r < 0 ? strerror(-r) : "short write");
|
log_error_errno(r, "Failed to write new random seed file: %m");
|
||||||
r = r == 0 ? -EIO : r;
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user