This doesn't actually change much, but makes the code less surprising.
Status quo ante:
1. Open a journal file
2. If newly created set header machine ID to zero
3. If existing and open for write check if machine ID in header matches
local one, if not, refuse.
4. if open for writing, now refresh the machine ID from the local system
Of course, step 4 is pretty much pointless for existing files, as the
check in 3 made sure it is already in order or we'd refuse operating on
it anyway. With this patch this is simplified to:
1. Open a journal file
2. If newly created initialized machine ID to local machine ID
3. If existing, compare machine ID in header with local one, if not
matching refuse.
Outcome is the same.
if (r < 0)
return r;
+ r = sd_id128_get_machine(&h.machine_id);
+ if (r < 0 && !ERRNO_IS_MACHINE_ID_UNSET(r))
+ return r; /* If we have no valid machine ID (test environment?), let's simply leave the
+ * machine ID field all zeroes. */
+
if (template) {
h.seqnum_id = template->header->seqnum_id;
h.tail_entry_seqnum = template->header->tail_entry_seqnum;
assert(f);
assert(f->header);
- r = sd_id128_get_machine(&f->header->machine_id);
- if (r < 0) {
- if (!ERRNO_IS_MACHINE_ID_UNSET(r))
- return r;
-
- /* don't have a machine-id, let's continue without */
- f->header->machine_id = SD_ID128_NULL;
- }
-
/* We used to update the header's boot ID field here, but we don't do that anymore, as per
* HEADER_COMPATIBLE_TAIL_ENTRY_BOOT_ID */