diff --git a/backup.py b/backup.py index 5a68bb5..a4118a4 100755 --- a/backup.py +++ b/backup.py @@ -257,10 +257,12 @@ class Backup(object): os.makedirs(tmpdir, exist_ok = True) os.chmod(tmpdir, mode = 0o0700) for idx, prep in enumerate(repo['prep']): - exec_tmp = tempfile.mkstemp(prefix = '_borgextend.', - suffix = '._tmpexc', - text = True, - dir = tmpdir)[1] + exec_fd, exec_tmp = tempfile.mkstemp(prefix = '_borgextend.', + suffix = '._tmpexc', + text = True, + dir = tmpdir)[1] + # D'oh. I need to close the FD before messing with it. + os.close(exec_fd) os.chmod(exec_tmp, mode = 0o0700) with open(exec_tmp, 'w') as f: f.write(prep)