From fd8eb9492faac1b2d323c45ad1029d2cd964f61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Thu, 26 Sep 2019 14:47:35 +0200 Subject: [PATCH] stages/dnf: Remove random seed after dnf run Some dnf packages introduce random seed file. If we leave in the tree it would mean all systems running from the created image would use the same random seed. This can be potentially dangerous, therefore we just remove the generated random seed from our images. --- stages/org.osbuild.dnf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stages/org.osbuild.dnf b/stages/org.osbuild.dnf index 4ef8e2c0..8fe6e0c1 100755 --- a/stages/org.osbuild.dnf +++ b/stages/org.osbuild.dnf @@ -1,5 +1,5 @@ #!/usr/bin/python3 - +import contextlib import hashlib import json import os @@ -129,6 +129,10 @@ def main(tree, options): machine_id_file.unlink() machine_id_file.touch() + # remove random seed from the tree if exists + with contextlib.suppress(FileNotFoundError): + os.unlink(f"{tree}/var/lib/systemd/random-seed") + return 0