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. --- src/virtBootstrap/virt_bootstrap.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/virtBootstrap/virt_bootstrap.py') diff --git a/src/virtBootstrap/virt_bootstrap.py b/src/virtBootstrap/virt_bootstrap.py index f0abac4..e387842 100755 --- a/src/virtBootstrap/virt_bootstrap.py +++ b/src/virtBootstrap/virt_bootstrap.py @@ -132,17 +132,19 @@ def bootstrap(uri, dest, password=password, uid_map=uid_map, gid_map=gid_map, + root_password=root_password, not_secure=not_secure, no_cache=no_cache, progress=prog).unpack(dest) - if root_password is not None: - logger.info("Setting password of the root account") - utils.set_root_password(fmt, dest, root_password) + if fmt == "dir": + if root_password is not None: + logger.info("Setting password of the root account") + utils.set_root_password_in_rootfs(dest, root_password) - if fmt == "dir" and (uid_map or gid_map): - logger.info("Mapping UID/GID") - utils.mapping_uid_gid(dest, uid_map, gid_map) + if uid_map or gid_map: + logger.info("Mapping UID/GID") + utils.mapping_uid_gid(dest, uid_map, gid_map) def set_logging_conf(loglevel=None): -- cgit