8b1af51bc6
Make dosh terminal sessions survive a dosh-server restart (crash/upgrade/systemctl restart): a reattaching client lands on the SAME shell with screen state intact, instead of a fresh one. Design: when persist_sessions is on (new config, default true) each terminal session's shell runs in a small detached per-session holder process (the dosh-server binary re-exec'd as `dosh-server hold`). The holder double-forks + setsid into its own session, opens the PTY, spawns the shell as ITS child, and serves the PTY master fd over a per-session Unix socket via SCM_RIGHTS. The server adopts that fd to build a PtyHandle that DETACHES (does not kill the shell) on drop, so a server exit leaves holder + shell alive. On startup the server scans the runtime dir under sessions_dir/run, reconnects to each live holder, receives the master fd again, restores the persisted vt100 screen, and rebuilds the Session. Screen/scrollback (server-memory only) is mirrored to disk atomically: byte-throttled on the output hot path plus a 2s periodic flush, and restored on re-adoption so reattach repaints. Truly-abandoned persistent sessions are still reaped per the existing grace logic by asking the holder to shut down. Anything in the persistent path failing degrades gracefully to the original in-process shell. PtyHandle gains an Owned (kill-on-drop, unchanged default) vs Adopted (detach-on-drop) backing; resize on an adopted master uses TIOCSWINSZ. No wire-format change, so protocol::VERSION stays 3. New deps: libc (direct). New config: persist_sessions (default true); existing integration tests pin it false to keep exercising the non-persistent path unchanged. Adds tests/integration_smoke.rs::session_survives_server_restart_same_ shell_and_screen: attaches, sets `cd /tmp; export MARK=...`, paints a screen marker, KILLs the server, restarts it on the same config, reattaches and asserts same shell pid + MARK + PWD + restored screen. Plus persist.rs unit tests (name round-trip, screen save/load, dead-holder scan cleanup, SCM_RIGHTS fd round-trip). cargo fmt --check and cargo test green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
806 B
TOML
40 lines
806 B
TOML
[package]
|
|
name = "dosh"
|
|
version = "0.1.0"
|
|
edition = "2024"
|
|
license = "MIT"
|
|
|
|
[dependencies]
|
|
anyhow = "1.0"
|
|
base64 = "0.22"
|
|
bincode = "1.3"
|
|
bytes = "1.7"
|
|
chacha20poly1305 = "0.10"
|
|
clap = { version = "4.5", features = ["derive"] }
|
|
crossterm = "0.28"
|
|
dirs = "5.0"
|
|
ed25519-dalek = "2.1"
|
|
hkdf = "0.12"
|
|
hmac = "0.12"
|
|
libc = "0.2"
|
|
portable-pty = "0.8"
|
|
rand = "0.8"
|
|
rpassword = "7.5.4"
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
sha2 = "0.10"
|
|
ssh-key = { version = "0.6.7", features = ["ed25519", "encryption"] }
|
|
tokio = { version = "1.41", features = ["full"] }
|
|
toml = "0.8"
|
|
vt100 = "0.15"
|
|
x25519-dalek = { version = "2.0.1", features = ["static_secrets", "getrandom"] }
|
|
|
|
[dev-dependencies]
|
|
tempfile = "3.14"
|
|
|
|
[profile.release]
|
|
opt-level = 2
|
|
codegen-units = 16
|
|
incremental = true
|
|
lto = false
|
|
strip = false
|