diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 13:38:01 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 13:38:01 +0100 |
commit | b53adfffd50440aec3d02ef49b5d0c55b2c82644 (patch) | |
tree | cf2e3fb6e466389b450a5ad1259b6413116af2f2 /hosts/vidhar/borg/copy.py | |
parent | b4e74d1ead7d0a7e5d5e502a58d70029673e2a77 (diff) | |
download | nixos-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-x | hosts/vidhar/borg/copy.py | 7 |
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' |