diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-01 14:59:46 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-05 00:52:56 +0900 |
commit | 319477f1b6db521ebc7c3db911ecb1a767a621aa (patch) | |
tree | 11607fbd37a1c1ae9b2684130a2e05de0dfdb51d /src/nspawn | |
parent | 5ee37b703e686782be565b2d0638c5488770141e (diff) | |
download | systemd-319477f1b6db521ebc7c3db911ecb1a767a621aa.tar.gz |
nspawn: ignore NULL machine ID in the container
Previously, when the NULL (all zero) machine ID is configured in the
container, nspawn refused to execute.
Now id128_get_machine() is used, so NULL machine ID is refused with
-ENOMEDIUM, and fallback to specified UUID or randomly generated one.
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 9fbacb2713..8abb016791 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2828,8 +2828,6 @@ static int mount_tunnel_open(void) { } static int setup_machine_id(const char *directory) { - const char *etc_machine_id; - sd_id128_t id; int r; /* If the UUID in the container is already set, then that's what counts, and we use. If it isn't set, and the @@ -2839,9 +2837,7 @@ static int setup_machine_id(const char *directory) { * in the container and our idea of the container UUID will always be in sync (at least if PID 1 in the * container behaves nicely). */ - etc_machine_id = prefix_roota(directory, "/etc/machine-id"); - - r = id128_read(etc_machine_id, ID128_FORMAT_PLAIN, &id); + r = id128_get_machine(directory, &arg_uuid); if (r < 0) { if (!ERRNO_IS_MACHINE_ID_UNSET(r)) /* If the file is missing, empty, or uninitialized, we don't mind */ return log_error_errno(r, "Failed to read machine ID from container image: %m"); @@ -2851,12 +2847,6 @@ static int setup_machine_id(const char *directory) { if (r < 0) return log_error_errno(r, "Failed to acquire randomized machine UUID: %m"); } - } else { - if (sd_id128_is_null(id)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Machine ID in container image is zero, refusing."); - - arg_uuid = id; } return 0; |