diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 16:20:54 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 16:20:54 +0100 |
commit | 8944cccd59a7d430d7416b20fc7a0952a65d6a39 (patch) | |
tree | 3a556b9b9a2b807de12759a66cf5eca41810ad99 /hosts | |
parent | 32c87dc2a17e8d5c78a7ffae553be59d214a04fa (diff) | |
download | nixos-8944cccd59a7d430d7416b20fc7a0952a65d6a39.tar nixos-8944cccd59a7d430d7416b20fc7a0952a65d6a39.tar.gz nixos-8944cccd59a7d430d7416b20fc7a0952a65d6a39.tar.bz2 nixos-8944cccd59a7d430d7416b20fc7a0952a65d6a39.tar.xz nixos-8944cccd59a7d430d7416b20fc7a0952a65d6a39.zip |
vidhar: ...
Diffstat (limited to 'hosts')
-rwxr-xr-x | hosts/vidhar/borg/copy.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index 41b0ae74..b68fdf8d 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py | |||
@@ -105,19 +105,18 @@ def copy_archive(src_repo_path, dst_repo_path, entry): | |||
105 | with open('/proc/self/setgroups', 'w') as setgroups: | 105 | with open('/proc/self/setgroups', 'w') as setgroups: |
106 | setgroups.write('deny') | 106 | setgroups.write('deny') |
107 | with open('/proc/self/uid_map', 'w') as uid_map: | 107 | with open('/proc/self/uid_map', 'w') as uid_map: |
108 | uid_map.write(f'0 {uid} 1') | 108 | uid_map.write(f'{uid} {uid} 1') |
109 | with open('/proc/self/gid_map', 'w') as gid_map: | 109 | with open('/proc/self/gid_map', 'w') as gid_map: |
110 | gid_map.write(f'0 {gid} 1') | 110 | gid_map.write(f'{gid} {gid} 1') |
111 | subprocess.run(['mount', '--make-rprivate', '/'], check=True) | 111 | subprocess.run(['mount', '--make-rprivate', '/'], check=True) |
112 | chroot = pathlib.Path(tmpdir) / 'chroot' | 112 | chroot = pathlib.Path(tmpdir) / 'chroot' |
113 | chroot2 = pathlib.Path(tmpdir) / 'chroot2' | ||
114 | upper = pathlib.Path(tmpdir) / 'upper' | 113 | upper = pathlib.Path(tmpdir) / 'upper' |
115 | work = pathlib.Path(tmpdir) / 'work' | 114 | work = pathlib.Path(tmpdir) / 'work' |
116 | for path in [chroot,chroot2,upper,work]: | 115 | for path in [chroot,upper,work]: |
117 | path.mkdir() | 116 | path.mkdir() |
118 | print(f'euid={os.getuid()}', file=stderr) | 117 | print(f'euid={os.getuid()}', file=stderr) |
119 | subprocess.run(['stat', '/', upper, work, chroot], check=True) | 118 | subprocess.run(['stat', '/', upper, work, chroot], check=True) |
120 | subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir={chroot2},upperdir={upper},workdir={work}', chroot], check=True) | 119 | subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/,upperdir={upper},workdir={work}', chroot], check=True) |
121 | bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] | 120 | bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] |
122 | if not ":" in src_repo_path: | 121 | if not ":" in src_repo_path: |
123 | bindMounts.append(pathlib.Path(src_repo_path).relative_to('/')) | 122 | bindMounts.append(pathlib.Path(src_repo_path).relative_to('/')) |