Add Remote relay library and secure settings storage
Add bounded NVDA-v2 framing, TLS transport, peer validation, speech and Braille decoding, and private transport fixtures. Store settings and explicitly remembered endpoint-bound keys using owner-only atomic files. Include the implementation plan and status records. Remote remains a source library without an installable package or desktop integration.
This commit is contained in:
1 parent
bc305993b8
commit
63e84e9ac7
20 files changed
+3984
No files matched your search
@@ -0,0 +1,69 @@
|
||||
# Remote settings and remembered credentials
|
||||
|
||||
The source library now includes Linux filesystem storage. It is not connected to
|
||||
a command or connection UI yet. Opening, reading and writing this store performs
|
||||
no network I/O and creates no session consent. Nothing auto-connects at startup.
|
||||
|
||||
`settings.toml` contains format version 1, plain-language role (`controller` or
|
||||
`controlled`), relay host/port and an optional previously approved SHA-256 pin.
|
||||
The pin repeats its host and port; a mismatch or invalid/zero digest is rejected.
|
||||
Pin validation uses the same endpoint contract as the TLS transport. There is no
|
||||
trust-on-first-use, changed-pin replacement, or certificate approval action in
|
||||
this storage layer. A future local UI must obtain that decision explicitly.
|
||||
|
||||
The schema contains no channel key, connection epoch, peer, lease, keyboard grant,
|
||||
clipboard consent, reconnect switch or startup-connect switch. Unknown fields,
|
||||
duplicate fields, unsupported versions and invalid endpoints are rejected.
|
||||
|
||||
`channel-key.toml` is separate and written only by an explicit `rememberKey`
|
||||
call. It contains version 1, relay host/port and the key. A key is returned only
|
||||
for the exact saved endpoint. Changing relay settings does not copy a key to the
|
||||
new endpoint; the old saved key remains unused until explicitly replaced or
|
||||
forgotten. `forgetKey` removes and syncs the credential file and is idempotent.
|
||||
Removal is not a promise of secure disk erasure. Saving ordinary settings never
|
||||
saves a key, and there is no saved-key flag that silently triggers a connection.
|
||||
|
||||
Keys use the transport's existing validation: nonempty valid UTF-8, at most 512
|
||||
bytes, without C0 controls or DEL. The transport and store share that validator.
|
||||
Settings and credential files are each bounded to 8 KiB on read. Parser errors
|
||||
are replaced with a generic error, without the file path, parser excerpt or key.
|
||||
Ordinary settings can therefore be inspected separately from credential content.
|
||||
|
||||
The caller supplies an absolute, clean directory path whose parents already
|
||||
exist. The final directory is created with mode 0700 if absent. Every component
|
||||
is opened relative to the preceding directory with no symlink following. A
|
||||
symlinked settings location is refused. The final directory must belong to the
|
||||
current user and have no group/other permissions; existing unsafe permissions
|
||||
are rejected rather than changed automatically.
|
||||
|
||||
All files, including the cooperating-process lock, must be current-user regular
|
||||
files with no group/other permissions and exactly one hard link. Symlinks, FIFOs,
|
||||
devices and hard links are refused. File opens use nonblocking/no-follow flags so
|
||||
an unexpected FIFO cannot hang the reader. Credential operations run on a future
|
||||
session worker, not an input or native UI callback.
|
||||
|
||||
Writers use an exclusive mode-0600 temporary file under the owned directory
|
||||
descriptor, sync it, rename within the directory, and sync the directory. They
|
||||
never follow or truncate an existing destination. A mutex serializes callers;
|
||||
a nonblocking flock excludes cooperating processes. Temporary files are removed
|
||||
after normal failures. Abrupt process death can leave an owner-only `.pending-*`
|
||||
file; it is never read as live settings. A directory-sync failure after rename
|
||||
can leave the new version present despite an error, so the UI must report the
|
||||
failure and re-read before claiming which value was saved. The two files are
|
||||
independent atomic records, not a cross-file transaction.
|
||||
|
||||
The key is plaintext protected by filesystem ownership and permissions. This is
|
||||
not encryption, an OS keyring, or protection against malicious same-user code.
|
||||
No runtime data is added to release archives; Remote still has no package entry.
|
||||
|
||||
Tests use disposable directories and synthetic keys. They cover restart, exact
|
||||
endpoint scoping, atomic inode replacement, permission modes, temporary-file
|
||||
cleanup, explicit forgetting, host/port pin mismatch, unknown fields/versions,
|
||||
malformed and oversized files, symlinked ancestors, file symlinks, hard links,
|
||||
FIFOs, unsafe lock files, competing locks and secret-free errors. They do not
|
||||
establish a completed Remember key UI or power-loss durability on every filesystem.
|
||||
|
||||
```sh
|
||||
GOCACHE=/tmp/cthulhu-cache GOPROXY=off go test -race ./remote/src -count=1 -timeout=60s
|
||||
make check
|
||||
```
|
||||
Reference in new issue
Block a user