Start machine terminals at the su login prompt instead of tmux

A new terminal runs su -l for the server's own account in its PTY, so the
operator types the account password before getting a shell. Opening is
refused when su is missing, the server runs as root, or su opens a shell
without asking. The Pipelines-owned tmux backing, its reattach and its
persisted session names are removed: terminals end with the server and
are listed as ended. A starting server ends leftover pipelines-term_*
sessions on tmux -L pipelines only.
This commit is contained in:
2026-11-10 00:37:11 +00:00
parent 070f9e205e
commit 227c036aa5
16 changed files with 887 additions and 545 deletions
+19 -24
View File
@@ -1,17 +1,20 @@
package protocol
// Machine terminals: interactive login shells the operator opens on a
// server's machine, independent of any chat. Each runs `$SHELL -l` (else
// /bin/sh) in a pseudo-terminal; where tmux is installed the shell lives in
// a Pipelines-owned tmux server (socket name "pipelines", never the
// operator's own), so it survives a Pipelines server restart and the next
// process reattaches it. Without tmux a shell ends with the server and is
// listed as ended. Typed input is never logged or stored.
// server's machine, independent of any chat. Each starts at the machine's
// login prompt for the server's own account (`su -l <user>` in a
// pseudo-terminal): the operator types that account's password before the
// login shell starts. A terminal ends with the server process and is then
// listed as ended (run tmux inside it to keep work across restarts). Typed
// input is never logged or stored.
const (
// TerminalOpen starts a shell. The body is TerminalRequest (cwd, cols,
// rows); cwd defaults to the operator's home and must be an existing
// directory inside it. The reply carries the new terminal; the
// connection is then subscribed to its terminal_event output frames.
// TerminalOpen starts a terminal at the login prompt. The body is
// TerminalRequest (cwd, cols, rows); cwd defaults to the operator's home
// and must be an existing directory inside it (the shell starts there
// after the login). The reply, sent once the password prompt shows,
// carries the new terminal; the connection is subscribed to its
// terminal_event output frames. A login that cannot ask for a password
// (no su, a root server, an account without one) is refused.
TerminalOpen = "terminal_open"
// TerminalList lists this machine's terminals (running and ended),
// oldest first, without output. The body is optional.
@@ -27,7 +30,7 @@ const (
// tail; OutputStart says where it starts). It also subscribes the
// connection to the terminal's terminal_event output frames.
TerminalOutput = "terminal_output"
// TerminalClose ends a terminal: its shell (and tmux session) is killed
// TerminalClose ends a terminal: its login or shell is killed
// and its record removed. The reply echoes the last record.
TerminalClose = "terminal_close"
// TerminalEvent is pushed: an output chunk to the connections subscribed
@@ -53,8 +56,6 @@ const (
TerminalChunkLimit = 64 << 10
// TerminalEndedKept bounds the ended terminals still listed.
TerminalEndedKept = 16
// TerminalTmuxHistory is the tmux scrollback of one tmux-backed shell.
TerminalTmuxHistory = 10000
// TerminalTitleLimit bounds a recorded title.
TerminalTitleLimit = 200
)
@@ -79,22 +80,16 @@ type TerminalRecord struct {
Cwd string `json:"cwd"`
Shell string `json:"shell"`
CreatedAt int64 `json:"created_at"`
// Tmux is the tmux session name keeping the shell alive across server
// restarts; empty when the shell is a direct child of the server and
// ends with it.
Tmux string `json:"tmux,omitempty"`
Status string `json:"status"`
EndedAt int64 `json:"ended_at,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
Status string `json:"status"`
EndedAt int64 `json:"ended_at,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
// Reason says why an ended terminal ended when it was not simply its
// shell exiting (the server restarted without tmux, its tmux session
// was gone).
// shell exiting (the login failed, the server stopped or restarted).
Reason string `json:"reason,omitempty"`
Cols int `json:"cols"`
Rows int `json:"rows"`
// Stream names this server process's output stream of the terminal;
// OutputEnd is the absolute byte count read into it. A restarted server
// that reattaches starts a new stream at zero, so a client holding
// OutputEnd is the absolute byte count read into it. A client holding
// another stream reads the terminal again from its start.
Stream string `json:"stream,omitempty"`
OutputEnd int64 `json:"output_end"`