Documentation
¶
Overview ¶
Package console serves the recorded console plane on the agent side: a console channel is piped to the node's own sshd and to nothing else.
Two kinds of channel arrive here, and both are served the same way: a person's interactive console, and an agent-driven one the SaaS opens to run one shell-tool command (ADR 0017), marked AgentDriven on the channel open. Since ADR 0019 the agent serves the marked channel at every action level: the SaaS grades the command, an admin approves it, and the session is recorded there, under a certificate whose key ID names the agent and the person.
The agent never forks a PTY, never spawns a shell and never authenticates an end user (ADR 0002). It moves bytes between the tunnel and a local TCP connection, which is what keeps the node's own keys, PAM, sudo and audit authoritative — a shell this process spawned would answer to this process's privileges, not the operator's.
Index ¶
Constants ¶
const LocalSSH = "127.0.0.1:22"
LocalSSH is the only address a console channel can reach. Loopback, and literal: with one agent per node there is no cross-node dialling to permit, so there is no allowlist to widen and no configuration that could widen it.
Variables ¶
var ErrNoSSHD = errors.New("console: sshd is not accepting connections on this node")
ErrNoSSHD is returned when nothing is listening on the node's sshd port.
var ErrNotAllowed = errors.New("console: target is not in this node's web allowlist")
ErrNotAllowed is returned for a target this node does not expose.
var ErrNotThisNode = errors.New("console: target names another node")
ErrNotThisNode is returned when a channel names a node this agent is not.
The caller must not pass this text to the SaaS: a probing SaaS learns the cluster's topology by watching which names come back differently. The distinction is for this node's own log.
Functions ¶
This section is empty.
Types ¶
type Dialer ¶
Dialer opens the local connection. Injected so tests can stand in a fake sshd without a listener on port 22.
type FileAllowlist ¶
type FileAllowlist struct{ Path string }
FileAllowlist resolves against the file each time it is asked.
The file changes underneath a running agent -- `advisor target_set` writes it, and config_advisor's Commit seeds one -- and reading it once at startup meant every such change needed a restart. A read per channel costs nothing: a channel is opened by a person clicking a button.
A parse error refuses rather than falling back to the last good copy: an allowlist nobody can read is not one to keep enforcing from memory.
type Handler ¶
type Handler struct {
// NodeID is this agent's own node. A target naming anything else is
// refused — the check is here, on the node, and not only in the SaaS,
// because the SaaS is never trusted to scope its own requests.
NodeID string
// Dial opens the local sshd connection; nil uses a real TCP dialler.
Dial Dialer
}
Handler serves console channels for one node.
type WebAllowlist ¶
WebAllowlist maps a symbolic target name to one host:port.
One host per name, not a set: the protocol carries a name and nothing else, so a name that meant several addresses could not say which one it wanted.
func LoadWebAllowlist ¶
func LoadWebAllowlist(path string) (WebAllowlist, error)
LoadWebAllowlist reads the allowlist. A missing file is an empty allowlist: a node that exposes no web target still serves SSH.
JSON, not YAML, because the agent runs on customer nodes and does not take a dependency to read four lines of configuration.
type WebHandler ¶
type WebHandler struct {
// Allow is the only source of addresses. Nil refuses everything.
Allow WebResolver
// Dial opens the upstream connection; nil uses a real TCP dialler.
Dial Dialer
}
WebHandler serves web channels for one node.
func (*WebHandler) Serve ¶
func (h *WebHandler) Serve(ctx context.Context, name string, rw io.ReadWriter) error
Serve pipes rw to the allowlisted address for name.
Bytes only: the agent parses no HTTP, so there is no request it can be tricked into rewriting.
type WebResolver ¶
WebResolver is what a handler asks for an address. A fixed WebAllowlist is one; so is a file read fresh on every channel.