diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2026-10-03 19:03:27 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2026-10-03 19:03:27 -0300 |
| commit | 60c586001cf4d21ef1351be8c8ad7a269a6f005a (patch) | |
| tree | c3fd1685968c4b3835b8755e73412eeef286dfab /claude_logbook/config.py | |
| parent | 2f8bc985b79e036ca6d34bb680a8858154c17a3b (diff) | |
| download | claude-logbook-60c586001cf4d21ef1351be8c8ad7a269a6f005a.tar.gz claude-logbook-60c586001cf4d21ef1351be8c8ad7a269a6f005a.zip | |
Share one session through a public link
claude-logbook -s REF --share uploads a session to a share server and
prints its link; --shares lists them, --unshare deletes them, --expire
picks how long they live. Before uploading it shows what goes up and warns
about anything that looks like a credential.
server/ is that share server: Go, standard library only, a FROM scratch
image. It serves /share/<id> as a page, .txt and .json, accepts only the
JSON payload (never HTML), pins the template's scripts with a CSP, keeps
secrets hashed and rate-limits per client IP.
Diffstat (limited to 'claude_logbook/config.py')
| -rw-r--r-- | claude_logbook/config.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/claude_logbook/config.py b/claude_logbook/config.py index 96c2e48..cd30675 100644 --- a/claude_logbook/config.py +++ b/claude_logbook/config.py @@ -82,9 +82,11 @@ def read_json(path): return data -def write_json(path, data): +def write_json(path, data, mode=None): """Atomic replace that keeps the file's mode (0644 minus umask if new) and - whether it ended in a newline, so an untouched key reads exactly the same.""" + whether it ended in a newline, so an untouched key reads exactly the same. + An explicit `mode` wins over both, for files that hold secrets.""" + forced = mode try: mode = os.stat(path).st_mode & 0o777 with open(path, "rb") as fh: @@ -107,7 +109,7 @@ def write_json(path, data): json.dump(data, fh, indent=2, ensure_ascii=False) if newline: fh.write("\n") - os.chmod(tmp, mode) + os.chmod(tmp, forced if forced is not None else mode) os.replace(tmp, path) except BaseException: try: |