🔐 Owned SSH connection reuse
Each explicit selected alias/config attempt owns a separate native OpenSSH master. It never borrows a ControlPath from the user’s configuration. A private runtime root /tmp/containerdesk-<uid> and random 128-bit child directory have mode 0700; a 0600 flock lease identifies this app instance and records the socket’s device/inode. Socket paths are at most 80 bytes, leaving room for OpenSSH’s temporary suffix even under macOS’s smaller Unix socket limit. Home/config path length does not extend the socket path.
Connection setup has a 30-second overall bound. A strict nonmultiplexed authentication preflight preserves actionable jump-host errors: native OpenSSH ControlPersist otherwise suppresses ProxyJump stderr. Master startup then uses explicit ControlMaster/Path/Persist, with a 15-second child deadline and bounded output. Native ControlPersist backgrounds only after a usable listener exists; unconditional -f is deliberately avoided. The original config is referenced through the existing strict policy overlay, never copied or modified.
Snapshots and future log/terminal channel owners share the same argument builder. Every channel has independent cancellation and a session-close signal. Closing the session invalidates it, cancels its children, waits for direct child cleanup/reaping, and sends -O exit only to its verified owned socket. Control messages use /dev/null as configuration, avoiding repeated evaluation of user Match/ProxyCommand rules during monitoring/cleanup. The native Tauri Exit callback fences new work and awaits session shutdown. An independent user control master is not targeted. The detached OpenSSH daemon is reaped by the OS; the app reaps its direct starter, channel and control children.
Multiplex channels use a fixed failing native ProxyCommand so OpenSSH cannot silently create a new transport after the app master disappears. There is no replay of dispatched commands. If a private location is unexpectedly occupied, the app preserves it and uses the visible direct_fallback mode, where each explicit operation opens a strict separate SSH connection. Failure to create a safe runtime policy fails closed. Unsupported mux startup failures may produce a connection error instead of fallback.
Native ControlPersist is 60 seconds idle. Because control health requests can reset that timer, the app separately counts actual channel leases and expires a connection after 60 seconds without active work. A 500 ms health check reports connection loss without reconnecting. Settings polls live transport state once a second after setup; reconnect is explicit. Loss/idle expiry closes the selected session and releases its diagnostic gate. Workspace/SSH override changes require disconnecting an active session first.
Recovery examines at most 128 private directories. It requires a valid owner-only lease at least 120 seconds old, an available flock, a recognized instance marker, only known entries, matching socket identity and a refused/absent Unix listener before deleting a socket. Live, replaced, unknown or ambiguous resources are retained. Recovery never signals a numeric PID, exits another master’s socket or recursively removes directories. A crash while a socket is created but before its identity is recorded can leave an unrecognized stale directory; it is retained for manual inspection. The namespace’s 128-entry admission limit reports resource exhaustion rather than growing without bound.
Real Linux checks use the disposable SSH lab: direct and ProxyJump reuse, independent channel cancellation, shared remote PTY, coordinator shutdown while another master survives, long config path, stale socket fallback, master death without reconnect and native/app idle deadlines. Conservative abandoned-lease cleanup is separately covered with local Unix sockets. No macOS run or forced native GUI crash is claimed. The later log/interactive terminal features must add their own streaming/PTY limits and backend permissions; this task only establishes their shared transport ownership.
References: OpenSSH control options, control commands, ProxyJump stderr handling, ControlPersist startup.