]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: robustly deal with "uninitialized" machine-id
authorHarald Seiler <hws@denx.de>
Thu, 15 Oct 2020 19:22:15 +0000 (21:22 +0200)
committerHarald Seiler <hws@denx.de>
Mon, 19 Oct 2020 14:28:21 +0000 (16:28 +0200)
When nspawn starts an image, this image could be in any state, including
an aborted first boot.  For this case, it needs to correctly handle the
situation like there was no machine-id at all.

src/nspawn/nspawn.c

index 82bb1673975ed0dde2724155355b07430cf4e511..5db08cb5b3a65c8fd4cb950fe73ceece1ef61bef 100644 (file)
@@ -2726,7 +2726,7 @@ static int setup_machine_id(const char *directory) {
 
         etc_machine_id = prefix_roota(directory, "/etc/machine-id");
 
-        r = id128_read(etc_machine_id, ID128_PLAIN, &id);
+        r = id128_read(etc_machine_id, ID128_PLAIN_OR_UNINIT, &id);
         if (r < 0) {
                 if (!IN_SET(r, -ENOENT, -ENOMEDIUM)) /* If the file is missing or empty, we don't mind */
                         return log_error_errno(r, "Failed to read machine ID from container image: %m");