From 59184b23a24d302eeec627a656f1acefff7d6597 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 11 Mar 2021 22:01:39 +0000 Subject: [PATCH] stages/rpm: truncate the machine id Instead of deleting and re-creating /etc/machine-id, just truncate it to an empty file. This should let the mode be 0444, which is the mode that systemd also creates it with. --- stages/org.osbuild.rpm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stages/org.osbuild.rpm b/stages/org.osbuild.rpm index c664154d..5c726063 100755 --- a/stages/org.osbuild.rpm +++ b/stages/org.osbuild.rpm @@ -289,12 +289,11 @@ def main(tree, inputs, options): enable_dracut(masked_files) remove_unowned_etc_kernel(tree) - # remove temporary machine ID if it was created by us + # if we created a temporary machine id, replace it with an empty one if not machine_id_set_previously: - print("deleting the fake machine id") + print("replacing fake machine id with empty one") machine_id_file = pathlib.Path(f"{tree}/etc/machine-id") - machine_id_file.unlink() - machine_id_file.touch() + machine_id_file.write_bytes(b"") # remove random seed from the tree if exists with contextlib.suppress(FileNotFoundError):