The switch to start bloom filters as a temp file in
71a4b32ee40bb44e48b246138c15716357816454
bloom: overhaul lifetime/context management; rm when incomplete
left them with restrictive mkstemp permissions, which
test-comparative-split-join detected (during long-check).
Capture the umask at startup once as bup.io.initial_umask and use it
to give the temp file the correct permissions.
Signed-off-by: Rob Browning <
r...@defaultvalue.org>
Tested-by: Rob Browning <
r...@defaultvalue.org>
---
Pushed to main.
lib/bup/bloom.py | 3 ++-
lib/bup/io.py | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/bup/bloom.py b/lib/bup/bloom.py
index f0e32408..a28d2630 100644
--- a/lib/bup/bloom.py
+++ b/lib/bup/bloom.py
@@ -95,7 +95,7 @@ from bup.helpers import \
mmap_readwrite_private,
notimplemented,
unlink)
-from
bup.io import path_msg as pm
+from
bup.io import initial_umask, path_msg as pm
BLOOM_VERSION = 2
@@ -215,6 +215,7 @@ def _create(path, expected, k):
fd, tmp = mkstemp(dir=dir or os.getcwdb(), prefix=(name + b'-'))
with ExitStack() as ctx:
ctx.enter_context(finalized(tmp, unlink))
+ os.fchmod(fd, 0o666 & ~initial_umask)
os.close(fd)
tmp_file = ctx.enter_context(builtins.open(tmp, 'w+b'))
tmp_file.write(b'BLOM')
diff --git a/lib/bup/io.py b/lib/bup/io.py
index fe2bfa66..acc8fb8c 100644
--- a/lib/bup/io.py
+++ b/lib/bup/io.py
@@ -6,6 +6,11 @@ import mmap as py_mmap
import os, select, sys, time
+# Get the umask once, early, so we can avoid further global changes.
+initial_umask = os.umask(0o777);
+os.umask(initial_umask)
+
+
# Write (blockingly) to sockets that may or may not be in blocking mode.
# We need this because our stderr is sometimes eaten by subprocesses
# (probably ssh) that sometimes make it nonblocking, if only temporarily,
--
2.47.3