diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-08-26 21:41:59 +0100 |
---|---|---|
committer | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-08-28 15:59:43 +0100 |
commit | 2e10b236687e4c97c983854b4a099fff4dfa9382 (patch) | |
tree | d606ca9e9714a3f4c492ef50f11b09b6177edde1 | |
parent | 64dd80368cc0b33f80d13205e5713ef5a9e24b3c (diff) | |
download | virt-bootstrap.git-2e10b236687e4c97c983854b4a099fff4dfa9382.tar.gz virt-bootstrap.git-2e10b236687e4c97c983854b4a099fff4dfa9382.tar.xz virt-bootstrap.git-2e10b236687e4c97c983854b4a099fff4dfa9382.zip |
Split the function mapping_uid_gid
Split the function mapping_uid_gid in two parts so that the code which
makes both lists map_uid and map_gid with equal length can be
reused.
-rw-r--r-- | src/virtBootstrap/utils.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/virtBootstrap/utils.py b/src/virtBootstrap/utils.py index 72eab4d..96ddab4 100644 --- a/src/virtBootstrap/utils.py +++ b/src/virtBootstrap/utils.py @@ -501,9 +501,9 @@ def map_id(path, map_uid, map_gid): os.lchown(file_path, new_uid, new_gid) -def mapping_uid_gid(dest, uid_map, gid_map): +def balance_uid_gid_maps(uid_map, gid_map): """ - Mapping ownership for each uid_map and gid_map. + Make sure the UID/GID list of mappings have the same length. """ len_diff = len(uid_map) - len(gid_map) @@ -512,5 +512,11 @@ def mapping_uid_gid(dest, uid_map, gid_map): elif len_diff > 0: gid_map += [None] * len_diff + +def mapping_uid_gid(dest, uid_map, gid_map): + """ + Mapping ownership for each uid_map and gid_map. + """ + balance_uid_gid_maps(uid_map, gid_map) for uid, gid in zip(uid_map, gid_map): map_id(dest, uid, gid) |