From 2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sat, 26 Aug 2017 21:42:05 +0100 Subject: Set root password with guestfs-python Use the python bindings of libguestfs to create additional qcow2 image which has as backing file the last layer (layer-0.qcow2 for FileSource) and insert hashed value of given root password in the /etc/shadow file. Note: This additional qcow2 image is also used to apply UID/GID map. --- tests/file_source.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/file_source.py') diff --git a/tests/file_source.py b/tests/file_source.py index 9ffd4e3..4554ecd 100644 --- a/tests/file_source.py +++ b/tests/file_source.py @@ -115,3 +115,12 @@ class TestQcow2FileSource(Qcow2ImageAccessor): self.call_bootstrap() self.apply_mapping() self.check_qcow2_images(self.get_image_path(1)) + + def test_qcow2_setting_root_password(self): + """ + Ensures that the root password is set in the last qcow2 image. + """ + self.root_password = "My secret password" + self.call_bootstrap() + self.check_image = self.validate_shadow_file_in_image + self.check_qcow2_images(self.get_image_path(1)) -- cgit