1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Per-user private scratch directory for short-lived sensitive files (Cause 7).
//!
//! Screenshots and clipboard images used to be written to fixed, predictable
//! names directly in the shared system temp dir (`/tmp/mermaid-screenshot-N.png`,
//! `/tmp/mermaid-clipboard-paste.png`). On a multi-user host another local user
//! could read those frames, or pre-create / symlink the path to redirect the
//! write. Routing them through a `0700` directory under the app data dir closes
//! that window — only the owning user can traverse it (#11, #33).
use PathBuf;
/// Return (creating if needed) a `0700` per-user scratch directory under the app
/// data dir. Callers write transient sensitive files here instead of the shared
/// system temp dir.
///
/// # Errors
///
/// Returns an error when the app data dir cannot be resolved, and when
/// creating `<data dir>/tmp` fails. Tightening the mode to `0700` is
/// best-effort and never fails the call, so a returned path is not proof the
/// directory is owner-only.