forked from pool/systemd
.
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=866
This commit is contained in:
parent
d95acb2975
commit
0d1af4e728
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Mar 16 15:35:31 UTC 2015 - werner@suse.de
|
||||||
|
|
||||||
|
- Add upstream patch
|
||||||
|
0001-core-don-t-change-removed-devices-to-state-tentative.patch
|
||||||
|
to fix the fix of the last backport (bsc#921898)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Mar 5 11:36:11 UTC 2015 - jengelh@inai.de
|
Thu Mar 5 11:36:11 UTC 2015 - jengelh@inai.de
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package systemd-mini
|
# spec file for package systemd-mini
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Mar 16 15:35:31 UTC 2015 - werner@suse.de
|
||||||
|
|
||||||
|
- Add upstream patch
|
||||||
|
0001-core-don-t-change-removed-devices-to-state-tentative.patch
|
||||||
|
to fix the fix of the last backport (bsc#921898)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Mar 5 11:36:11 UTC 2015 - jengelh@inai.de
|
Thu Mar 5 11:36:11 UTC 2015 - jengelh@inai.de
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package systemd
|
# spec file for package systemd
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
@ -5,13 +5,11 @@ write back the bytes and increase the entropy bit counter.
|
|||||||
Related to bnc#892096
|
Related to bnc#892096
|
||||||
|
|
||||||
---
|
---
|
||||||
src/random-seed/random-seed.c | 65 +++++++++++++++++++++++++++++++++++++++---
|
systemd-210/src/random-seed/random-seed.c | 73 +++++++++++++++++++++++++-----
|
||||||
1 file changed, 61 insertions(+), 4 deletions(-)
|
1 file changed, 62 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
Index: systemd-218/src/random-seed/random-seed.c
|
--- systemd-210/src/random-seed/random-seed.c
|
||||||
===================================================================
|
+++ systemd-210/src/random-seed/random-seed.c 2015-04-14 11:38:08.617519434 +0000
|
||||||
--- systemd-218.orig/src/random-seed/random-seed.c
|
|
||||||
+++ systemd-218/src/random-seed/random-seed.c
|
|
||||||
@@ -22,7 +22,9 @@
|
@@ -22,7 +22,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -22,31 +20,46 @@ Index: systemd-218/src/random-seed/random-seed.c
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@@ -32,8 +34,9 @@
|
@@ -32,8 +34,8 @@
|
||||||
#define POOL_SIZE_MIN 512
|
#define POOL_SIZE_MIN 512
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
- _cleanup_close_ int seed_fd = -1, random_fd = -1;
|
- _cleanup_close_ int seed_fd = -1, random_fd = -1;
|
||||||
|
- _cleanup_free_ void* buf = NULL;
|
||||||
+ _cleanup_close_ int seed_fd = -1, random_fd = -1, entropy_fd = -1;
|
+ _cleanup_close_ int seed_fd = -1, random_fd = -1, entropy_fd = -1;
|
||||||
_cleanup_free_ void* buf = NULL;
|
+ _cleanup_free_ struct rand_pool_info *entropy = NULL;
|
||||||
+ size_t entropy_count = 0;
|
|
||||||
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[]) {
|
||||||
|
if (buf_size <= POOL_SIZE_MIN)
|
||||||
|
buf_size = POOL_SIZE_MIN;
|
||||||
|
|
||||||
|
- buf = malloc(buf_size);
|
||||||
|
- if (!buf) {
|
||||||
|
+ entropy = (struct rand_pool_info*) malloc(sizeof(struct rand_pool_info) + buf_size);
|
||||||
|
+ if (!entropy) {
|
||||||
|
r = log_oom();
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
+ entropy->buf_size = buf_size;
|
||||||
|
|
||||||
|
r = mkdir_parents_label(RANDOM_SEED, 0755);
|
||||||
|
if (r < 0) {
|
||||||
@@ -82,6 +85,23 @@ int main(int argc, char *argv[]) {
|
@@ -82,6 +85,23 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (streq(argv[1], "load")) {
|
if (streq(argv[1], "load")) {
|
||||||
|
|
||||||
+ entropy_fd = open(RANDOM_SEED_DIR "entropy_count", O_RDONLY|O_CLOEXEC|O_NOCTTY, 0600);
|
+ entropy_fd = open(RANDOM_SEED_DIR "entropy_count", O_RDONLY|O_CLOEXEC|O_NOCTTY, 0600);
|
||||||
+ if (entropy_fd < 0) {
|
+ if (entropy_fd < 0) {
|
||||||
+ entropy_count = 0;
|
+ entropy->entropy_count = 0;
|
||||||
+ if (errno != ENOENT) {
|
+ if (errno != ENOENT) {
|
||||||
+ log_error("Failed to open " RANDOM_SEED "/entropy_count: %m");
|
+ log_error("Failed to open " RANDOM_SEED "/entropy_count: %m");
|
||||||
+ r = -errno;
|
+ r = -errno;
|
||||||
+ goto finish;
|
+ goto finish;
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ r = read(entropy_fd, &entropy_count, sizeof(entropy_count));
|
+ r = read(entropy_fd, &entropy->entropy_count, sizeof(entropy->entropy_count));
|
||||||
+ if (r < 0) {
|
+ if (r < 0) {
|
||||||
+ log_error("Failed to read entropy count file: %m");
|
+ log_error("Failed to read entropy count file: %m");
|
||||||
+ r = -errno;
|
+ r = -errno;
|
||||||
@ -57,56 +70,64 @@ Index: systemd-218/src/random-seed/random-seed.c
|
|||||||
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);
|
||||||
@@ -113,12 +133,34 @@ int main(int argc, char *argv[]) {
|
@@ -102,7 +122,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- k = loop_read(seed_fd, buf, buf_size, false);
|
||||||
|
+ k = loop_read(seed_fd, entropy->buf, entropy->buf_size, false);
|
||||||
|
if (k <= 0) {
|
||||||
|
|
||||||
|
if (r != 0)
|
||||||
|
@@ -113,16 +133,32 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
lseek(seed_fd, 0, SEEK_SET);
|
lseek(seed_fd, 0, SEEK_SET);
|
||||||
|
|
||||||
- r = loop_write(random_fd, buf, (size_t) k, false);
|
- k = loop_write(random_fd, buf, (size_t) k, false);
|
||||||
- if (r < 0)
|
- if (k <= 0) {
|
||||||
- log_error_errno(r, "Failed to write seed to /dev/urandom: %m");
|
- log_error("Failed to write seed to /dev/urandom: %s", r < 0 ? strerror(-r) : "short write");
|
||||||
+ if (entropy_count && (size_t) k == buf_size) {
|
+ if (entropy->entropy_count && (size_t) k == entropy->buf_size) {
|
||||||
+ struct rand_pool_info entropy = {
|
+ r = ioctl(random_fd, RNDADDENTROPY, entropy);
|
||||||
+ .entropy_count = entropy_count,
|
|
||||||
+ .buf_size = buf_size,
|
|
||||||
+ };
|
|
||||||
+ entropy.buf[0] = ((__u32*)buf)[0];
|
|
||||||
+ r = ioctl(random_fd, RNDADDENTROPY, &entropy);
|
|
||||||
+ if (r < 0) {
|
+ if (r < 0) {
|
||||||
+ log_error("Failed to write seed to /dev/urandom: %m");
|
+ log_error("Failed to write seed to /dev/urandom: %m");
|
||||||
+ r = -errno;
|
+ r = -errno;
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ k = loop_write(random_fd, buf, (size_t) k, false);
|
+ k = loop_write(random_fd, entropy->buf, (size_t) k, false);
|
||||||
+ if (k <= 0) {
|
+ if (k <= 0) {
|
||||||
+ log_error("Failed to write seed to /dev/urandom: %s", r < 0 ? strerror(-r) : "short write");
|
+ log_error("Failed to write seed to /dev/urandom: %s", r < 0 ? strerror(-r) : "short write");
|
||||||
|
|
||||||
|
- r = k == 0 ? -EIO : (int) k;
|
||||||
+ r = k == 0 ? -EIO : (int) k;
|
+ r = k == 0 ? -EIO : (int) k;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (streq(argv[1], "save")) {
|
} else if (streq(argv[1], "save")) {
|
||||||
|
|
||||||
+ /* 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_count) < 0)
|
+ if (fscanf(f, "%zu", &entropy->entropy_count) < 0)
|
||||||
+ entropy_count = 0;
|
+ entropy->entropy_count = 0;
|
||||||
+ fclose(f);
|
+ fclose(f);
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
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) {
|
||||||
@@ -134,6 +176,21 @@ int main(int argc, char *argv[]) {
|
log_error("Failed to open " RANDOM_SEED ": %m");
|
||||||
|
@@ -137,6 +173,21 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ if (entropy_count) {
|
+ if (entropy->entropy_count) {
|
||||||
+ entropy_fd = open(RANDOM_SEED_DIR "entropy_count", O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
|
+ entropy_fd = open(RANDOM_SEED_DIR "entropy_count", O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
|
||||||
+ if (seed_fd < 0) {
|
+ if (seed_fd < 0) {
|
||||||
+ log_error("Failed to open " RANDOM_SEED_DIR "entropy_count: %m");
|
+ log_error("Failed to open " RANDOM_SEED_DIR "entropy_count: %m");
|
||||||
+ r = -errno;
|
+ r = -errno;
|
||||||
+ goto finish;
|
+ goto finish;
|
||||||
+ }
|
+ }
|
||||||
+ r = write(entropy_fd, &entropy_count, sizeof(entropy_count));
|
+ r = write(entropy_fd, &entropy->entropy_count, sizeof(entropy->entropy_count));
|
||||||
+ if (r < 0) {
|
+ if (r < 0) {
|
||||||
+ log_error("Failed to write entropy count file: %m");
|
+ log_error("Failed to write entropy count file: %m");
|
||||||
+ r = -errno;
|
+ r = -errno;
|
||||||
@ -117,3 +138,18 @@ Index: systemd-218/src/random-seed/random-seed.c
|
|||||||
} else {
|
} else {
|
||||||
log_error("Unknown verb %s.", argv[1]);
|
log_error("Unknown verb %s.", argv[1]);
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
|
@@ -149,12 +200,12 @@ int main(int argc, char *argv[]) {
|
||||||
|
fchmod(seed_fd, 0600);
|
||||||
|
fchown(seed_fd, 0, 0);
|
||||||
|
|
||||||
|
- k = loop_read(random_fd, buf, buf_size, false);
|
||||||
|
+ k = loop_read(random_fd, entropy->buf, entropy->buf_size, false);
|
||||||
|
if (k <= 0) {
|
||||||
|
log_error("Failed to read new seed from /dev/urandom: %s", r < 0 ? strerror(-r) : "EOF");
|
||||||
|
r = k == 0 ? -EIO : (int) k;
|
||||||
|
} else {
|
||||||
|
- r = loop_write(seed_fd, buf, (size_t) k, false);
|
||||||
|
+ r = loop_write(seed_fd, entropy->buf, (size_t) k, false);
|
||||||
|
if (r <= 0) {
|
||||||
|
log_error("Failed to write new random seed file: %s", r < 0 ? strerror(-r) : "short write");
|
||||||
|
r = r == 0 ? -EIO : r;
|
||||||
|
Loading…
Reference in New Issue
Block a user