aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/client/store.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/client/store.py')
-rw-r--r--packages/meshbay-cli/src/meshbay_cli/client/store.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/client/store.py b/packages/meshbay-cli/src/meshbay_cli/client/store.py
index c48fe89..00ff9f3 100644
--- a/packages/meshbay-cli/src/meshbay_cli/client/store.py
+++ b/packages/meshbay-cli/src/meshbay_cli/client/store.py
@@ -63,7 +63,10 @@ def data_dir() -> Path:
def _write_private(path: Path, data: bytes) -> None:
"""Atomically, readable by this user only."""
tmp = path.with_name(path.name + ".tmp")
- fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
+ # O_BINARY: without it Windows opens in text mode and writes every 0x0A of
+ # the ciphertext as CR LF, and the secrets no longer open.
+ flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | getattr(os, "O_BINARY", 0)
+ fd = os.open(tmp, flags, 0o600)
try:
os.write(fd, data)
os.fsync(fd)