[FEATURE] Provide restricted terminal controls for mediated descriptors #5

Open
opened 2026-10-28 03:20:50 +01:00 by erikinkinen · 3 comments
Owner

Problem and motivation

Compatibility programs need terminal controls through their Posixd descriptors. Existing TTY byte endpoints do not provide those controls, and the separate session-owner route carries unrelated authority.

Proposed behavior and scope

Provide restricted Ttyd control views, then adopt them through LibIPC, LibPosixABI, Posixd and namespaced LibCstd interfaces. Bind each view to its original live PTY and byte stream, with explicit operation rights.

Cover terminal identification and naming, attributes and control characters, speeds, window dimensions, drain/flush/flow/break, and compatibility session/foreground-group operations. Specify real effects and errors for virtual PTYs and physical serial terminals. Unsupported hardware behavior must never report invented success. Conventional POSIX aliases retain their separate startup and signal-delivery requirements.

Authority, security and reliability

Mint views from the actual admitted terminal owner. Do not forward its session-lifecycle endpoint, grant hangup or trusted UI operations, or widen existing stdin/stdout loans. Byte-only realms receive no new terminal authority.

Retain the original view, stream association, caller and descriptor occupation through pending calls, aliases and close/dup races. Revoking a recipient's view must preserve the lender's PTY and streams. Preflight fallible reservations before effects; retain original request/reply evidence and first failure through cancellation or uncertain cleanup. Publish C outputs only after original call retirement.

Acceptance criteria

  • Implement restricted view creation, per-operation rights, authenticated stream association, counted retention, revocation and cleanup.
  • Define truthful terminal/non-terminal classification and assigned compatibility errors, including ENOTTY. Missing control authority cannot establish non-terminal identity; names and IDs confer no authority.
  • Implement the attribute, queue, speed, control-character, window and job-control semantics above, including explicit virtual/physical distinctions.
  • Supply namespaced C/Rust adapters with checked buffers, thread-local errno, independent concurrent call storage and retirement before output publication.
  • Cover malformed requests/replies, denied rights, stale associations, close/dup races, interruption, partial effects and uncertain cleanup. Preserve existing byte-only and session-owner denials.
  • Adopt coherent component revisions, a native C workload, Integration coverage and component/manual documentation. Demonstrate actual guest behavior separately from source checks.

Alternatives and tradeoffs

Reusing the session-owner endpoint would carry unrelated operations; widening byte endpoints would change existing loans. Direct TTY or host-system calls would bypass descriptor mediation. A mode-bit wrapper alone would leave required terminal behavior missing.

Tracking and rollout

Part of the libc plan and Phase 6 tracking. Related work: descriptor bridge, C library PR, Posixd PR.

Publish the native control contract first, followed by mediator/ABI support, libc adapters and the guest workload. Keep producer/consumer revisions coherent and remove superseded paths.

## Problem and motivation Compatibility programs need terminal controls through their Posixd descriptors. Existing TTY byte endpoints do not provide those controls, and the separate session-owner route carries unrelated authority. ## Proposed behavior and scope Provide restricted Ttyd control views, then adopt them through LibIPC, LibPosixABI, Posixd and namespaced LibCstd interfaces. Bind each view to its original live PTY and byte stream, with explicit operation rights. Cover terminal identification and naming, attributes and control characters, speeds, window dimensions, drain/flush/flow/break, and compatibility session/foreground-group operations. Specify real effects and errors for virtual PTYs and physical serial terminals. Unsupported hardware behavior must never report invented success. Conventional POSIX aliases retain their separate startup and signal-delivery requirements. ## Authority, security and reliability Mint views from the actual admitted terminal owner. Do not forward its session-lifecycle endpoint, grant hangup or trusted UI operations, or widen existing stdin/stdout loans. Byte-only realms receive no new terminal authority. Retain the original view, stream association, caller and descriptor occupation through pending calls, aliases and close/dup races. Revoking a recipient's view must preserve the lender's PTY and streams. Preflight fallible reservations before effects; retain original request/reply evidence and first failure through cancellation or uncertain cleanup. Publish C outputs only after original call retirement. ## Acceptance criteria - [ ] Implement restricted view creation, per-operation rights, authenticated stream association, counted retention, revocation and cleanup. - [ ] Define truthful terminal/non-terminal classification and assigned compatibility errors, including ENOTTY. Missing control authority cannot establish non-terminal identity; names and IDs confer no authority. - [ ] Implement the attribute, queue, speed, control-character, window and job-control semantics above, including explicit virtual/physical distinctions. - [ ] Supply namespaced C/Rust adapters with checked buffers, thread-local errno, independent concurrent call storage and retirement before output publication. - [ ] Cover malformed requests/replies, denied rights, stale associations, close/dup races, interruption, partial effects and uncertain cleanup. Preserve existing byte-only and session-owner denials. - [ ] Adopt coherent component revisions, a native C workload, Integration coverage and component/manual documentation. Demonstrate actual guest behavior separately from source checks. ## Alternatives and tradeoffs Reusing the session-owner endpoint would carry unrelated operations; widening byte endpoints would change existing loans. Direct TTY or host-system calls would bypass descriptor mediation. A mode-bit wrapper alone would leave required terminal behavior missing. ## Tracking and rollout Part of the [libc plan](https://git.erikinkinen.fi/erix/lib-cstd/issues/1) and [Phase 6 tracking](https://git.erikinkinen.fi/erix/integration/issues/65). Related work: [descriptor bridge](https://git.erikinkinen.fi/erix/lib-cstd/issues/13), [C library PR](https://git.erikinkinen.fi/erix/lib-cstd/pulls/3), [Posixd PR](https://git.erikinkinen.fi/erix/posixd/pulls/5). Publish the native control contract first, followed by mediator/ABI support, libc adapters and the guest workload. Keep producer/consumer revisions coherent and remove superseded paths.
Author
Owner

Terminal-control creation will use a separate provisioning endpoint because transferring its two capability inputs requires SEND|GRANT. The existing session-provision grants will stay unchanged. An explicit, versioned Procd BootConfig policy will enable the new route; storage counts will remain independent of authority. Rootd will create and delegate the endpoint, with exact optional intake policies and startup checks in Procd and Ttyd. Disabled deployments must have no alias for this route; malformed policy or inconsistent roles and capacity will refuse before startup.

Terminal-control creation will use a separate provisioning endpoint because transferring its two capability inputs requires SEND|GRANT. The existing session-provision grants will stay unchanged. An explicit, versioned Procd BootConfig policy will enable the new route; storage counts will remain independent of authority. Rootd will create and delegate the endpoint, with exact optional intake policies and startup checks in Procd and Ttyd. Disabled deployments must have no alias for this route; malformed policy or inconsistent roles and capacity will refuse before startup.
Author
Owner

The restricted terminal-control route is implemented across Ttyd, Rootd, Procd, Launchd and Posixd. Per-view rights stay tied to the original stream; boot policy explicitly requests the separate route, and Posixd retains control owners through aliases and teardown. The C identification/window adapters are next; complete termios behavior remains open.

The restricted terminal-control route is implemented across [Ttyd](https://git.erikinkinen.fi/erix/ttyd/commit/1a22d50e813ab128c36b589f2b023ec744e13d59), Rootd, Procd, Launchd and Posixd. Per-view rights stay tied to the original stream; boot policy explicitly requests the separate route, and Posixd retains control owners through aliases and teardown. The [C identification/window adapters](https://git.erikinkinen.fi/erix/lib-cstd/issues/19) are next; complete termios behavior remains open.
Author
Owner

The C identification/window adapters now use the retained native views through Posixd. The explicit terminal workload requests STATE and RESIZE, keeps its peer byte-only, and includes window restoration and last-alias cleanup checks. Full termios and native workload acceptance remain open.

The [C identification/window adapters](https://git.erikinkinen.fi/erix/lib-cstd/issues/19) now use the retained native views through Posixd. The explicit terminal workload requests STATE and RESIZE, keeps its peer byte-only, and includes window restoration and last-alias cleanup checks. Full termios and native workload acceptance remain open.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:35:15 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/ttyd#5
No description provided.