summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-08-18 13:43:08 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-08-18 13:43:08 -0400
commitf3664a28a927c7a9a122af4d72a89114b26f39bd (patch)
tree9f9c98aa603a37bf51e1584fc3376394903bb7b6 /src
parentd0eb997ee9f9889f184d0d52397b49a7f0dee009 (diff)
downloadrandom-seed-f3664a28a927c7a9a122af4d72a89114b26f39bd.tar.xz
random-seed-f3664a28a927c7a9a122af4d72a89114b26f39bd.zip
Stuff.
Diffstat (limited to 'src')
-rw-r--r--src/random-seed.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/random-seed.c b/src/random-seed.c
index 0ce1f8b..dd1c447 100644
--- a/src/random-seed.c
+++ b/src/random-seed.c
@@ -49,7 +49,7 @@ static inline void usage() {
}
static bool run_seed_file_cmd(const char *cmd, const unsigned char *salt, FILE *seed_file) {
-#define HASH_ID_CMD(my_cmd, type, fn, hash_access, ...) \
+#define HASH_ID_CMD(my_cmd, type, fn, data_accessor, ...) \
do { \
if (!streq(cmd, my_cmd)) \
break; \
@@ -66,7 +66,7 @@ static bool run_seed_file_cmd(const char *cmd, const unsigned char *salt, FILE *
fputs("error getting " my_cmd " hash\n", stderr); \
return false; \
} \
- hash(salt, fn ## _hash, hash_access fn ## _buf, sz); \
+ hash(salt, fn ## _hash, data_accessor fn ## _buf, sz); \
unsigned char theirdigest[HASH_LEN]; \
if (hex2mem(theirdigest, HASH_LEN, arg) == 0) { \
fputs("error decoding hex hash\n", stderr); \
@@ -81,7 +81,7 @@ static bool run_seed_file_cmd(const char *cmd, const unsigned char *salt, FILE *
HASH_ID_CMD("machine-id", char *, get_machine_id, );
HASH_ID_CMD("fs-id", fsid_t, get_fs_id, &, fileno(seed_file));
-#if defined(HAVE_UDEV) || defined(HAVE_UTIL_LINUX)
+#if defined(HAVE_LIBUDEV) || defined(HAVE_UTIL_LINUX)
HASH_ID_CMD("fs-uuid", char *, get_fs_uuid, fileno(seed_file));
#else
if (streq(cmd, "fs-uuid")) {
@@ -89,7 +89,7 @@ static bool run_seed_file_cmd(const char *cmd, const unsigned char *salt, FILE *
return false;
}
#endif
-#ifdef HAVE_UDEV
+#ifdef HAVE_LIBUDEV
HASH_ID_CMD("drive-id", char *, get_drive_id, fileno(seed_file));
#else
if (streq(cmd, "drive-id")) {
@@ -105,7 +105,7 @@ static bool load(FILE *seed_file) {
bool credit_entropy = true;
struct rand_pool_info_ rpi = {
- .entropy_count = RAND_POOL_SIZE * 8,
+ .entropy_count = RAND_POOL_SIZE * CHAR_BIT,
.buf_size = RAND_POOL_SIZE,
.buf = { 0 }
};
@@ -302,6 +302,12 @@ static bool save(const char *seed_path, unsigned char *random_buf) {
}
GET_HASH_STR(fsid_t, &, fs_id, seed_dir_fd);
+#ifdef HAVE_LIBUDEV
+ GET_HASH_STR(char *, , drive_id, seed_dir_fd);
+#endif
+#if defined(HAVE_LIBUDEV) || defined(HAVE_UTIL_LINUX)
+ GET_HASH_STR(char *, , fs_uuid, seed_dir_fd);
+#endif
seed_fd = openat(seed_dir_fd, seed_name_new, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (seed_fd == -1) {