summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/sources/file_source.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-26 21:42:04 +0100
committerRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-28 16:03:28 +0100
commit7baf904cffdc4074ba5529b095f98a8c1ed6707a (patch)
treef7fffb9fcef085c747898e3649a182cdcc3fce4d /src/virtBootstrap/sources/file_source.py
parent6ca9a3f7eccae0411f73d7aa8df759eb09be8955 (diff)
downloadvirt-bootstrap.git-7baf904cffdc4074ba5529b095f98a8c1ed6707a.tar.gz
virt-bootstrap.git-7baf904cffdc4074ba5529b095f98a8c1ed6707a.tar.xz
virt-bootstrap.git-7baf904cffdc4074ba5529b095f98a8c1ed6707a.zip
Enable UID/GID mapping for qcow2
Apply ownership mapping in qcow2 images using libguestfs python bindings. To make this solution more general we introduce function guestfs_walk() which will return the root file system tree of disk image along with UID/GID values. These changes are applied in additional qcow2 disk image using the last layer as backing file. For FileSource this is layer-1.qcow2 with backing file layer-0.qcow2.
Diffstat (limited to 'src/virtBootstrap/sources/file_source.py')
-rw-r--r--src/virtBootstrap/sources/file_source.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/virtBootstrap/sources/file_source.py b/src/virtBootstrap/sources/file_source.py
index 69f024c..b4b29ce 100644
--- a/src/virtBootstrap/sources/file_source.py
+++ b/src/virtBootstrap/sources/file_source.py
@@ -41,10 +41,14 @@ class FileSource(object):
@param uri: Path to tar archive file.
@param fmt: Format used to store image [dir, qcow2]
+ @param uid_map: Mappings for UID of files in rootfs
+ @param gid_map: Mappings for GID of files in rootfs
@param progress: Instance of the progress module
"""
self.path = kwargs['uri'].path
self.output_format = kwargs.get('fmt', utils.DEFAULT_OUTPUT_FORMAT)
+ self.uid_map = kwargs.get('uid_map', [])
+ self.gid_map = kwargs.get('gid_map', [])
self.progress = kwargs['progress'].update_progress
def unpack(self, dest):
@@ -73,6 +77,9 @@ class FileSource(object):
progress=self.progress
)
img.create_base_layer()
+ if self.uid_map or self.gid_map:
+ logger.info("Mapping UID/GID")
+ utils.map_id_in_image(1, dest, self.uid_map, self.gid_map)
else:
raise Exception("Unknown format:" + self.output_format)