From ff9ddf823707b81d207127267433002454d70bc7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 17 Feb 2022 16:25:16 +0100 Subject: vidhar: ... --- hosts/vidhar/borg/copy.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'hosts') diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index b68fdf8d..71d9fe55 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py @@ -105,18 +105,21 @@ def copy_archive(src_repo_path, dst_repo_path, entry): with open('/proc/self/setgroups', 'w') as setgroups: setgroups.write('deny') with open('/proc/self/uid_map', 'w') as uid_map: - uid_map.write(f'{uid} {uid} 1') + uid_map.write(f'0 {uid} 1') with open('/proc/self/gid_map', 'w') as gid_map: - gid_map.write(f'{gid} {gid} 1') + gid_map.write(f'0 {gid} 1') subprocess.run(['mount', '--make-rprivate', '/'], check=True) chroot = pathlib.Path(tmpdir) / 'chroot' + lower = pathlib.Path(tmpdir) / 'lower' upper = pathlib.Path(tmpdir) / 'upper' work = pathlib.Path(tmpdir) / 'work' - for path in [chroot,upper,work]: + for path in [chroot,lower,upper,work]: path.mkdir() print(f'euid={os.getuid()}', file=stderr) - subprocess.run(['stat', '/', upper, work, chroot], check=True) - subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/,upperdir={upper},workdir={work}', chroot], check=True) + subprocess.run(['stat', '/', lower, upper, work, chroot], check=True) + subprocess.run(['mount', '-t', 'shifts', '/', lower], check=True) + subprocess.run(['stat', lower], check=True) + subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir={lower},upperdir={upper},workdir={work}', chroot], check=True) bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] if not ":" in src_repo_path: bindMounts.append(pathlib.Path(src_repo_path).relative_to('/')) -- cgit v1.2.3