summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/sources/docker_source.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-26 21:42:05 +0100
committerRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-28 16:03:59 +0100
commit2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac (patch)
tree6d73ffc3effffc67e3ae67f9908a08f3ca5ff436 /src/virtBootstrap/sources/docker_source.py
parent7baf904cffdc4074ba5529b095f98a8c1ed6707a (diff)
downloadvirt-bootstrap.git-2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac.tar.gz
virt-bootstrap.git-2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac.tar.xz
virt-bootstrap.git-2bb76d45f14ae1bce4240bd3c1eeabcb44f663ac.zip
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.
Diffstat (limited to 'src/virtBootstrap/sources/docker_source.py')
-rw-r--r--src/virtBootstrap/sources/docker_source.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/virtBootstrap/sources/docker_source.py b/src/virtBootstrap/sources/docker_source.py
index a2fc8b9..3500bf1 100644
--- a/src/virtBootstrap/sources/docker_source.py
+++ b/src/virtBootstrap/sources/docker_source.py
@@ -51,6 +51,7 @@ class DockerSource(object):
@param password: Password to access source registry
@param uid_map: Mappings for UID of files in rootfs
@param gid_map: Mappings for GID of files in rootfs
+ @param root_password: Root password to set in rootfs
@param fmt: Format used to store image [dir, qcow2]
@param not_secure: Do not require HTTPS and certificate verification
@param no_cache: Whether to store downloaded images or not
@@ -65,6 +66,7 @@ class DockerSource(object):
self.password = kwargs.get('password', None)
self.uid_map = kwargs.get('uid_map', [])
self.gid_map = kwargs.get('gid_map', [])
+ self.root_password = kwargs.get('root_password', None)
self.output_format = kwargs.get('fmt', utils.DEFAULT_OUTPUT_FORMAT)
self.insecure = kwargs.get('not_secure', False)
self.no_cache = kwargs.get('no_cache', False)
@@ -287,10 +289,15 @@ class DockerSource(object):
)
img.create_base_layer()
img.create_backing_chains()
+ img.set_root_password(self.root_password)
if self.uid_map or self.gid_map:
logger.info("Mapping UID/GID")
utils.map_id_in_image(
- len(self.layers), dest, self.uid_map, self.gid_map
+ len(self.layers), # Number of layers
+ dest,
+ self.uid_map,
+ self.gid_map,
+ (self.root_password is None) # Create new disk?
)
else: