_yaml
_yaml
¶
Write-back for the few sandbox sites that mutate config files, and for secrets.
Config edits go through the shared round-trip YAML facade
(terok_util.yaml) and are written as operator-owned
config (write_config_file).
Secrets get write_secret_text
instead: atomic, and always 0o600.
__all__ = ['update_section', 'write_secret_text']
module-attribute
¶
update_section(path, section, updates)
¶
Merge updates into data[section] at path, preserving comments.
The file is operator-owned config: an existing one is rewritten in
place and keeps its symlinks, mode and owner, and a new one is
created 0o600.
Source code in src/terok_sandbox/_yaml.py
write_secret_text(path, text)
¶
Atomically create-or-replace path with mode 0o600.
Writes a temp file in the same directory, fsyncs, then
os.replaces it onto path. A crash mid-write leaves either
the old file intact or no file at all — never a truncated one.
mkstemp opens with mode 0o600 from the kernel, so a passphrase
never has a window of world-readable visibility.