From 3b1c49ea07255ad87a1e9c0b1bc9eaad1693751d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 18 Feb 2022 11:47:40 +0100 Subject: vidhar: ... --- hosts/vidhar/borg/copy.py | 7 ++++--- hosts/vidhar/borg/default.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'hosts/vidhar') diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index e6cf2ac4..1714e2e8 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py @@ -118,8 +118,6 @@ def copy_archive(src_repo_path, dst_repo_path, entry): bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] if os.environ.get('BORG_BASE_DIR'): bindMounts.append(pathlib.Path(os.environ['BORG_BASE_DIR']).relative_to('/')) - if os.environ.get('CREDENTIALS_DIRECTORY'): - bindMounts.append(pathlib.Path(os.environ['CREDENTIALS_DIRECTORY']).relative_to('/')) if not ":" in src_repo_path: bindMounts.append(pathlib.Path(src_repo_path).relative_to('/')) if 'SSH_AUTH_SOCK' in os.environ: @@ -128,6 +126,9 @@ def copy_archive(src_repo_path, dst_repo_path, entry): (chroot / bindMount).mkdir(parents=True,exist_ok=True) # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr) subprocess.run(['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], check=True) + if os.environ.get('CREDENTIALS_DIRECTORY'): + creds_path = pathlib.Path(os.environ['CREDENTIALS_DIRECTORY']).relative_to('/') + subprocess.run(['binfs', '-r', f'--force-user={borg_pwd.pw_uid}', f'--force-group={borg_pwd.pw_gid}', pathlib.Path('/') / creds_path, chroot / creds_path], check=True) os.chroot(chroot) os.chdir('/') dir = pathlib.Path('/borg') @@ -248,7 +249,7 @@ def sigterm(signum, frame): def main(): signal.signal(signal.SIGTERM, sigterm) - + if "::" in args.source: (src_repo_path, _, src_archive) = args.source.partition("::") entry = None diff --git a/hosts/vidhar/borg/default.nix b/hosts/vidhar/borg/default.nix index 37cdba8c..53b36d82 100644 --- a/hosts/vidhar/borg/default.nix +++ b/hosts/vidhar/borg/default.nix @@ -72,7 +72,7 @@ let copy wrapProgram $out/bin/copy \ - --prefix PATH : ${makeBinPath (with pkgs; [utillinux borgbackup])} + --prefix PATH : ${makeBinPath (with pkgs; [utillinux borgbackup bindfs])} ''; }); in { -- cgit v1.2.3