summaryrefslogtreecommitdiff
path: root/hosts/vidhar/borg/copy.py
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vidhar/borg/copy.py')
-rwxr-xr-xhosts/vidhar/borg/copy.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py
index 4858db78..227b7d8a 100755
--- a/hosts/vidhar/borg/copy.py
+++ b/hosts/vidhar/borg/copy.py
@@ -96,20 +96,18 @@ def copy_archive(src_repo_path, dst_repo_path, entry):
96 # print('unshare/chroot', file=stderr) 96 # print('unshare/chroot', file=stderr)
97 uid, gid = os.getuid(), os.getgid() 97 uid, gid = os.getuid(), os.getgid()
98 unshare.unshare(unshare.CLONE_NEWNS | unshare.CLONE_NEWUSER) 98 unshare.unshare(unshare.CLONE_NEWNS | unshare.CLONE_NEWUSER)
99 ps_effective = {pyprctl.Cap.SETUID, pyprctl.Cap.SETGID} 99 ps_effective = {} # {pyprctl.Cap.SETUID, pyprctl.Cap.SETGID}
100 ps_ambient = {pyprctl.Cap.SYS_ADMIN} 100 ps_ambient = {pyprctl.Cap.SYS_ADMIN}
101 pyprctl.cap_permitted.add(*(ps_effective | ps_ambient)) 101 pyprctl.cap_permitted.add(*(ps_effective | ps_ambient))
102 pyprctl.cap_effective.add(*(ps_effective | ps_ambient)) 102 pyprctl.cap_effective.add(*(ps_effective | ps_ambient))
103 pyprctl.cap_inheritable.add(*ps_ambient) 103 pyprctl.cap_inheritable.add(*ps_ambient)
104 pyprctl.cap_ambient.add(*ps_ambient) 104 pyprctl.cap_ambient.add(*ps_ambient)
105 with open('/proc/self/uid_map', 'r') as uid_map:
106 print(uid_map.read(), file=stderr)
107 with open('/proc/self/setgroups', 'w') as setgroups: 105 with open('/proc/self/setgroups', 'w') as setgroups:
108 setgroups.write('deny') 106 setgroups.write('deny')
109 with open('/proc/self/uid_map', 'w') as uid_map: 107 with open('/proc/self/uid_map', 'w') as uid_map:
110 uid_map.write(f'0 0 4294967295') 108 uid_map.write(f'0 {uid} 4294967295')
111 with open('/proc/self/gid_map', 'w') as gid_map: 109 with open('/proc/self/gid_map', 'w') as gid_map:
112 gid_map.write(f'0 0 4294967295') 110 gid_map.write(f'0 {gid} 4294967295')
113 subprocess.run(['mount', '--make-rprivate', '/'], check=True) 111 subprocess.run(['mount', '--make-rprivate', '/'], check=True)
114 chroot = pathlib.Path(tmpdir) / 'chroot' 112 chroot = pathlib.Path(tmpdir) / 'chroot'
115 upper = pathlib.Path(tmpdir) / 'upper' 113 upper = pathlib.Path(tmpdir) / 'upper'