From 45d411c20e662cfc1545b78227965d68c11e962e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 17 Feb 2022 15:52:42 +0100 Subject: vidhar: ... --- hosts/vidhar/borg/copy.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index ab5e027d..1a415732 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py @@ -96,6 +96,12 @@ def copy_archive(src_repo_path, dst_repo_path, entry): # print('unshare/chroot', file=stderr) uid, gid = os.getuid(), os.getgid() unshare.unshare(unshare.CLONE_NEWNS | unshare.CLONE_NEWUSER) + ps_effective = set(pyprctl.Cap.SETUID, pyprctl.Cap.SETGID) + ps_ambient = set(pyprctl.Cap.SYS_ADMIN) + pyprctl.cap_permitted.add(*(ps_effective + ps_ambient)) + pyprctl.cap_effective.add(*(ps_effective + ps_ambient)) + pyprctl.cap_inheritable.add(*ps_ambient) + pyprctl.cap_ambient.add(*ps_ambient) with open('/proc/self/uid_map', 'r') as uid_map: print(uid_map.read(), file=stderr) with open('/proc/self/setgroups', 'w') as setgroups: @@ -104,9 +110,6 @@ def copy_archive(src_repo_path, dst_repo_path, entry): uid_map.write(f'0 0 4294967295') with open('/proc/self/gid_map', 'w') as gid_map: gid_map.write(f'0 0 4294967295') - pyprctl.cap_permitted.sys_admin = True - pyprctl.cap_inheritable.sys_admin = True - pyprctl.cap_ambient.sys_admin = True subprocess.run(['mount', '--make-rprivate', '/'], check=True) chroot = pathlib.Path(tmpdir) / 'chroot' upper = pathlib.Path(tmpdir) / 'upper' -- cgit v1.2.3