local_forward_socket_path built {TMPDIR}/herdr-remote-{pid}-{target}-
{session}.sock. On macOS std::env::temp_dir() returns /var/folders/.../T/
(~49 chars), so a ~24-char target was enough to push the path past
sun_path's 104-byte ceiling and UnixListener::bind rejected it with
"path must be shorter than SUN_LEN". Per-component sanitization capped
each piece at 32 chars but ignored the directory prefix.
The function now picks the first form that fits within 103 bytes (one
byte of headroom for the trailing NUL; portable across macOS' 104 and
Linux's 108) measured via OsStrExt::as_bytes:
1. Readable name in TMPDIR (unchanged when it fits).
2. Hashed short name in TMPDIR.
3. Hashed short name in /tmp (rare fallback for over-long TMPDIRs).
The hash covers the full unsanitized target/session so uniqueness does
not depend on prefix truncation; the truncated prefix is kept only for
debuggability of the short-form filename.
Co-authored-by: jett <jett@pingcap.cn>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>