diff options
-rw-r--r-- | src/partition/repart.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 3d21caa306..e4ae8a2c89 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -4909,24 +4909,14 @@ static int context_read_seed(Context *context, const char *root) { return 0; if (!arg_randomize) { - _cleanup_close_ int fd = -EBADF; - - fd = chase_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, NULL); - if (fd == -ENOENT) - log_info("No machine ID set, using randomized partition UUIDs."); - else if (fd < 0) - return log_error_errno(fd, "Failed to determine machine ID of image: %m"); - else { - r = id128_read_fd(fd, ID128_FORMAT_PLAIN, &context->seed); - if (r < 0) { - if (!ERRNO_IS_MACHINE_ID_UNSET(r)) - return log_error_errno(r, "Failed to parse machine ID of image: %m"); + r = id128_get_machine(root, &context->seed); + if (r >= 0) + return 0; - log_info("No machine ID set, using randomized partition UUIDs."); - } + if (!ERRNO_IS_MACHINE_ID_UNSET(r)) + return log_error_errno(r, "Failed to parse machine ID of image: %m"); - return 0; - } + log_info("No machine ID set, using randomized partition UUIDs."); } r = sd_id128_randomize(&context->seed); |