demo: each session's transcript, kept 7 days in a write-only drop box (#192)
Ruled 2026-11-21, "Write-only drop box": console.py writes each session's transcript, mode 0600, into /var/lib/starshipos-demo-transcripts (the owner's, group starshipos-demo, mode 1730: a session adds a file but cannot list or read the directory). transcripts-tidy.sh, run as root every 5 minutes by starshipos-demo-transcripts.timer, hands each file to the owner and deletes those over 7 days. starshipos-demo.service gets the directory writable and DEMO_TRANSCRIPTS; DEPLOY.md step 4 has the server steps and the check. "Nothing you do is kept" was no longer true. Ruled 2026-11-24, "Machine not kept; log 7 days": the session's banner, the Try it page and the old wiki page say nothing is kept on the machine and a transcript is kept for up to 7 days, then deleted, and the page says so before the console. demo/test_transcripts.py failed first (logs/20261121-demo-transcripts/before.txt) and passes its 10 checks (after.txt). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -10,6 +10,13 @@ A resumed machine takes a moment to load. Anything typed meanwhile would reach a
|
||||
whose state is about to be replaced, and be lost half-way through a line ("3 4 + ." arriving as
|
||||
"4 + ."). So: wait until QEMU says the machine is running, throw away what was typed before,
|
||||
say so, and only then pass bytes both ways. Ends when either side closes.
|
||||
|
||||
The transcript (#192, ruled 2026-11-13 and 2026-11-21): what the machine sends -- its prompt, the visitor's
|
||||
line as it echoes it, what it prints -- is also written to DEMO_TRANSCRIPTS
|
||||
(/var/lib/starshipos-demo-transcripts), one file a session, named by its UTC start and this process, mode 0600.
|
||||
The directory is a drop box this user can write in but not list or read (DEPLOY.md); transcripts-tidy.sh
|
||||
hands each file to its owner and deletes it after 7 days. The Try It page says so. If it cannot be written,
|
||||
the session goes on without one.
|
||||
"""
|
||||
import json, os, select, socket, sys, termios, time, tty
|
||||
|
||||
@@ -38,6 +45,14 @@ while True: # until the machine runs
|
||||
time.sleep(0.1)
|
||||
|
||||
con = connect(con_path)
|
||||
transcript = None
|
||||
try:
|
||||
tdir = os.environ.get("DEMO_TRANSCRIPTS", "/var/lib/starshipos-demo-transcripts")
|
||||
name = os.path.join(tdir, time.strftime("%Y%m%d-%H%M%S", time.gmtime()) + "-%d.log" % os.getpid())
|
||||
transcript = os.open(name, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
|
||||
os.write(transcript, ("# StarshipOS demo session, %s UTC\n" % time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())).encode())
|
||||
except OSError:
|
||||
transcript = None # no transcript, the session as before
|
||||
stdin, stdout = sys.stdin.fileno(), sys.stdout.fileno()
|
||||
saved = None
|
||||
if os.isatty(stdin):
|
||||
@@ -56,7 +71,13 @@ try:
|
||||
data = con.recv(4096)
|
||||
if not data: break
|
||||
os.write(stdout, data)
|
||||
if transcript is not None:
|
||||
try: os.write(transcript, data)
|
||||
except OSError: transcript = None
|
||||
except OSError:
|
||||
pass # the visitor's terminal went away
|
||||
finally:
|
||||
if saved: termios.tcsetattr(stdin, termios.TCSADRAIN, saved)
|
||||
if transcript is not None:
|
||||
os.write(transcript, ("\n# ended %s UTC\n" % time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())).encode())
|
||||
os.close(transcript)
|
||||
|
||||
Reference in New Issue
Block a user