summaryrefslogtreecommitdiff
path: root/hosts/vidhar/borg/copy.py
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-17 13:38:01 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-17 13:38:01 +0100
commitb53adfffd50440aec3d02ef49b5d0c55b2c82644 (patch)
treecf2e3fb6e466389b450a5ad1259b6413116af2f2 /hosts/vidhar/borg/copy.py
parentb4e74d1ead7d0a7e5d5e502a58d70029673e2a77 (diff)
downloadnixos-b53adfffd50440aec3d02ef49b5d0c55b2c82644.tar
nixos-b53adfffd50440aec3d02ef49b5d0c55b2c82644.tar.gz
nixos-b53adfffd50440aec3d02ef49b5d0c55b2c82644.tar.bz2
nixos-b53adfffd50440aec3d02ef49b5d0c55b2c82644.tar.xz
nixos-b53adfffd50440aec3d02ef49b5d0c55b2c82644.zip
vidhar: ...
Diffstat (limited to 'hosts/vidhar/borg/copy.py')
-rwxr-xr-xhosts/vidhar/borg/copy.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py
index 3ec520b5..e15b56c3 100755
--- a/hosts/vidhar/borg/copy.py
+++ b/hosts/vidhar/borg/copy.py
@@ -86,9 +86,14 @@ def copy_archive(src_repo_path, dst_repo_path, entry):
86 child = os.fork() 86 child = os.fork()
87 if child == 0: 87 if child == 0:
88 # print('unshare/chroot', file=stderr) 88 # print('unshare/chroot', file=stderr)
89 uid_map_content = f'0 {os.getuid()} 1'
90 gid_map_content = f'0 {os.getgid()} 1'
89 unshare.unshare(unshare.CLONE_NEWUSER) 91 unshare.unshare(unshare.CLONE_NEWUSER)
92 with open('/proc/self/uid_map', 'w') as uid_map:
93 uid_map.write(uid_map_content)
94 with open('/proc/self/gid_map', 'w') as gid_map:
95 gid_map.write(gid_map_content)
90 unshare.unshare(unshare.CLONE_NEWNS) 96 unshare.unshare(unshare.CLONE_NEWNS)
91 pyprctl.cap_ambient_raise(pyprctl.Cap.SYS_ADMIN)
92 subprocess.run(['mount', '--make-rprivate', '/'], check=True) 97 subprocess.run(['mount', '--make-rprivate', '/'], check=True)
93 chroot = pathlib.Path(tmpdir) / 'chroot' 98 chroot = pathlib.Path(tmpdir) / 'chroot'
94 upper = pathlib.Path(tmpdir) / 'upper' 99 upper = pathlib.Path(tmpdir) / 'upper'