diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21b61135..a1231a50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,12 +148,15 @@ jobs: /opt/teaport/brain/bin/teaport-brain --help >/dev/null test -x /usr/bin/teaport && bash -n /usr/bin/teaport # compile(), not py_compile: that would write a __pycache__ beside the helper. - for p in /usr/lib/teaport/config_apply.py /usr/lib/teaport/update_apply.py /usr/lib/teaport/wifi_apply.py /usr/lib/teaport/login_apply.py; do + for p in /usr/lib/teaport/config_apply.py /usr/lib/teaport/update_apply.py /usr/lib/teaport/wifi_apply.py /usr/lib/teaport/login_apply.py /usr/lib/teaport/license_accept.py /usr/lib/teaport/license_link.py; do /usr/bin/python3 -I -c 'import sys; p = sys.argv[1]; compile(open(p).read(), p, "exec")' "$p" done # The update's unit, as systemd reads it (it is static: nothing enables it). systemd-analyze verify /usr/lib/systemd/system/teaport-update.service [ "$(systemctl show -p UnitFileState --value teaport-update.service)" = static ] + # The owner's license retry (#465): enabled by the package's own link. + systemd-analyze verify /usr/lib/systemd/system/teaport-license-owner.service /usr/lib/systemd/system/teaport-license-owner.timer + [ "$(readlink /usr/lib/systemd/system/timers.target.wants/teaport-license-owner.timer)" = /usr/lib/systemd/system/teaport-license-owner.timer ] - name: dpkg -V is clean, and the package owns every file under its root run: | out="$(dpkg -V teaport-brain)" diff --git a/brain/teaport_brain/config_apply.py b/brain/teaport_brain/config_apply.py index 40d9ebb0..a56c10df 100644 --- a/brain/teaport_brain/config_apply.py +++ b/brain/teaport_brain/config_apply.py @@ -68,6 +68,18 @@ STOPPABLE = ("teaport-wifi-setup",) MAX_BYTES = 64 * 1024 BACKUPS = 5 +# The engine's license files (teaport#474 F1): nothing here writes, renames or removes them, +# whatever a path above comes to name. The same tuple in every root helper the run user +# reaches (license_link.PROTECTED is the one list; tests hold the copies to it). +PROTECTED = ("/etc/teaport/license.json", "/etc/teaport/license-revocations.json", + "/etc/teaport/license-link.secret") + + +def protected(path: str) -> bool: + """`path` is one of PROTECTED, by name or through a link.""" + return os.path.abspath(path) in PROTECTED or os.path.realpath(path) in PROTECTED + + # Only backups THIS code named are ever pruned. Operators keep their own beside # them (brain.env.bak-gptoss, brain.env.bak-20260901-154338-stopsecs on the dev # box) and those are not ours to rotate out. @@ -102,6 +114,8 @@ def write(name: str, content: str) -> str: if content and not content.endswith("\n"): content += "\n" path = os.path.join(ETC, name) + if protected(path): + raise SystemExit(f"refusing to write {name!r}: it is the engine's license") mode, uid, gid = 0o640, 0, int(os.environ.get("SUDO_GID", "0")) if os.path.exists(path): st = os.stat(path) @@ -138,7 +152,8 @@ def _backup(path: str, mode: int, uid: int, gid: int) -> None: older = sorted(f for f in os.listdir(os.path.dirname(path)) if f.startswith(base + ".bak-") and BACKUP_RE.search(f)) for name in older[:-BACKUPS]: - os.unlink(os.path.join(os.path.dirname(path), name)) + if not protected(os.path.join(os.path.dirname(path), name)): + os.unlink(os.path.join(os.path.dirname(path), name)) def restart(unit: str) -> None: diff --git a/brain/teaport_brain/config_ui.py b/brain/teaport_brain/config_ui.py index d0dc5286..ed8e443d 100644 --- a/brain/teaport_brain/config_ui.py +++ b/brain/teaport_brain/config_ui.py @@ -13,6 +13,10 @@ POST /api/restart {unit} — deferred restart through config_apply GET /api/login whether the owner's login is pending (#421), and its words POST /api/login {password, again} — creates it, through owner_login + GET /api/eula whether the owner's license step is pending (#465), the + license's text, and the step's words + POST /api/eula {email, accept, eula_sha256} — the owner accepts it, through + owner_license GET /licenses the open-source licenses page (static/licenses.html); its data is GET /api/licenses and GET /api/licenses/{package} (licenses.py) @@ -904,14 +908,92 @@ async def login_create(request: Request): password, again = _login_body(await request.json()) except ValueError: raise HTTPException(status_code=400, detail="the request is not JSON") from None + t = _reader(request) + # Setup is unfinished until the license is accepted, as on the setup page, where it comes + # first (#465): while it waits, the login waits for it too. + from teaport_brain import owner_license + if await asyncio.to_thread(_owner_license().pending): + logger.info("config: the owner's login not created (the license first) from Settings") + return {"ok": False, "why": "license_first", + "message": owner_license.say(t, owner_license.TEXT["login_first"])} ok, why = await asyncio.to_thread(_owner_login().create, password, again) logger.info("config: the owner's login " + ("created" if ok else f"not created ({why})") + " from Settings") - t = _reader(request) msgid = owner_login.TEXT["created"] if ok else owner_login.WHY[why] return {"ok": ok, "why": why or None, "message": owner_login.say(t, msgid)} +# ------------------------------------------------------------------ the owner's license +# The "Read the license" card (#465), beside "Create your login": offered while setup is +# unfinished on a box provisioning marked for it and nobody has accepted the license there +# yet, for an owner whose box got online without the setup page (or whose setup page had no +# copy of the license to show). Setup finishes only once it is accepted, and the login card +# waits for it (login_create); nothing else on the box does (the engine runs under the box's +# appliance key). An acceptance made, while it may still be replaced, shows its email masked, +# with "Not you? Accept again". The recording is +# owner_license's, through license_accept and license_link as root; the email goes there +# and nowhere else (no log line, no answer). + + +def _owner_license(): + """Replaced in tests.""" + from teaport_brain import owner_license + return owner_license.License() + + +@router.get("/api/eula") +async def eula_state(request: Request): + """Whether the card is offered, the license's text when it is, and the card's words in + the reader's language. The text is the helper's (the channel's manifest, checked).""" + from teaport_brain import owner_license + _authorize(request) + t = _reader(request) + lic = _owner_license() + state = await asyncio.to_thread(lic.state) + # Accepted while setup is unfinished: whose email (masked), and whether it may still be + # replaced ("Not you? Accept again"; license_accept.py says why it is shown). + accepted = await asyncio.to_thread(lic.accepted) if state in (owner_license.QUEUED, owner_license.RECORDED) else None + wanted = state == owner_license.PENDING or bool(accepted and accepted["replaceable"]) + doc = await asyncio.to_thread(lic.text) if wanted else None + words = {k: owner_license.say(t, v) for k, v in owner_license.TEXT.items() if k != "accepted_as"} + if accepted: + words["accepted_as"] = owner_license.say(t, owner_license.TEXT["accepted_as"], email=accepted["email"]) + lost = await asyncio.to_thread(lic.link_lost) + if lost: + words["link_lost"] = owner_license.say(t, owner_license.TEXT[lost]) + return {"offered": state == owner_license.PENDING, "state": state, "accepted": accepted, "link_lost": bool(lost), + "license": doc, "lang": t.lang.replace("_", "-"), "dir": t.dir, "text": words, + "why_unavailable": (owner_license.say(t, owner_license.WHY["unavailable"]) + if wanted and doc is None else None)} + + +@router.post("/api/eula") +async def eula_accept(request: Request): + """{email, accept: true, eula_sha256 (of the text shown), owner_use (personal or + business), replace}: the owner's + acceptance, recorded (or queued) and linked; with replace, in place of the one on the box + while it may still be replaced. {ok, why, state, message}: a refusal is a 200 with ok + false, as the card shows it in place.""" + from teaport_brain import owner_license + _authorize(request) + try: + body = await request.json() + except ValueError: + raise HTTPException(status_code=400, detail="the request is not JSON") from None + if not isinstance(body, dict) or not isinstance(body.get("email"), str) \ + or not isinstance(body.get("eula_sha256"), str): + raise HTTPException(status_code=400, detail="email and eula_sha256 must be text") + ok, why = await asyncio.to_thread(_owner_license().accept, body["email"], body["eula_sha256"], + body.get("accept") is True, body.get("owner_use"), + body.get("replace") is True) + logger.info("config: the owner's license acceptance " + (why if ok else f"not recorded ({why})") + + " from Settings") + t = _reader(request) + msgid = owner_license.TEXT[why] if ok else owner_license.WHY[why] + return {"ok": ok, "why": None if ok else why, "state": why if ok else None, + "message": owner_license.say(t, msgid)} + + @router.post("/api/restart") async def restart(request: Request): _authorize(request) diff --git a/brain/teaport_brain/license_accept.py b/brain/teaport_brain/license_accept.py new file mode 100644 index 00000000..1bc2e0a1 --- /dev/null +++ b/brain/teaport_brain/license_accept.py @@ -0,0 +1,696 @@ +# +# teaport — the owner's acceptance of the Teaport Engine License at setup (#465): the one +# way the run user can have the box record who accepted it. As root, behind sudo. +# +# A factory box ships with its engine installed under Teaspoon AI's maker record and its +# appliance key (#464, #474), and no one's acceptance of the license: its owner accepts it +# at setup, on the setup page (wifi_setup.py, offline) or in Settings (config_ui.py, +# online), both through owner_license.py. This helper records that acceptance, and nothing +# else. The run user is the agent's (#416, #418): it may ask, never decide. So: +# - it takes the owner's email and nothing else that says who accepted: never an +# acceptance id (a request that names one, or anything not listed below, is refused). +# It makes POST /accept itself and records the id the license server returns, so +# the record can only ever name an acceptance made here, with the email the owner typed; +# - for the run user, it works only while setup is unfinished: while provisioning's marker +# (GATE_PATH, in the same root-only directory as the login's, login_apply.py) is there. +# An acceptance recorded (RECORD_PATH) or queued (QUEUE_PATH) is replaced only by a +# request that says so (replace: the page's "Not you? Accept again", shown with the +# recorded email masked, status), only until the link is made (license_link.py removes +# the marker then) and only while the owner's login is still to be made (the login's +# marker, LOGIN_PENDING_PATH): the window an agent could accept first in, with any email, +# is the login's, and the page shows the owner whose email is recorded, so they can take +# it back (docs: security.md); +# - an administrator (sudo with their password: SUDO_UID is not the run user's), or root, +# may accept, and replace, at any time, after the link too: the owner holding the box +# puts their own acceptance on it and links it (license_link.py), which is support's +# re-link for a wrong link (the owner's decision, 2026-11-28): possession of the box +# outranks any record. Only online then: no timer sends a queue after setup; +# - the text the owner accepts is the one the page showed: the page names its SHA-256 +# (eula_sha256), and the helper refuses it unless it is the current license's, read +# from the channel's manifest and checked against it (text). +# The record is install.sh's own receipt, /var/lib/teaport/eula-accepted.json (root's, +# 0600): a later `install.sh` or `teaport update` gets its download tokens with it, as from +# an acceptance made at the installer. Never the run user's $STATE: the record is what the +# link helper (license_link.py) puts on the box's license key, so the run user must not be +# able to write it. Beside it, the accepted text (EULA-v.txt, 0644), as install.sh +# keeps it. +# +# Offline (the setup page has no internet: the box is not on the owner's network yet), the +# email waits in QUEUE_PATH, root's 0600, and this helper sends it itself when the box is +# next online: `flush`, which teaport-license-owner.timer runs as root (OnBootSec, then every +# few minutes, only while a queue or the marker is there). A timer, not NetworkManager's +# dispatcher or the brain's own online watcher (first_boot.py): the watcher runs as the run +# user, and a dispatcher hook runs once per event while a POST can fail for a reason that +# lasts (the license server busy, a captive network): it needs a retry either way, and a +# timer is that retry, from boot, whatever brought the box online. A queued acceptance the +# server refuses for good (the license changed meanwhile: 409 eula_changed; or a request it +# does not take) is dropped, and the setup step is offered again; anything else stays queued. +# +# Where: the license server is API, built in, never the manifest's access.api nor a record's: +# the installed manifest and an older installer's receipt may be files the run user could +# write, and the email (and, through the link, the box's secret) would go wherever they said. +# A manifest naming any other server, or a text off its origin, is no license here. +# +# Which device: a factory box (/etc/appliance-id, the serial the station assigned) sends +# SHA-256 of "teaport-appliance:" and its serial, as the station's maker record does +# (docs/engine-license-data.md), so the owner's acceptance and the maker's match; any other +# box, SHA-256 of "teaport-device:" and its machine id, as install.sh sends. Which use: +# "personal", the one POST /api/accept takes without a license_id, and owner_use, what the +# owner says the box is for ("personal" or "business": the step asks; migrations/0006). +# Not "licensed" with the box's key's id: the license server cannot check that id, so it +# would be a link from an email to a key that anyone could claim; the box's key is linked +# to its owner only by the link, with the box's secret (licenses.acceptance_id). Method: +# "tty", as an acceptance read and made at the installer's prompt (the license server's +# acceptances.method takes tty or flag only, a CHECK that only a table rebuild could +# widen), and the installer field says where: "setup:" and the brain's revision. The box's +# own record says "setup". +# +# Verbs (the only argument; the request is a JSON object on stdin, the reply one on stdout; +# a request this does not do gets {"refused": why, "why": code} and exit 2): +# status {state, email, replaceable}: PENDING (setup unfinished, nothing accepted), +# QUEUED, RECORDED (an acceptance is on the box, the installer's included), +# NOT_OFFERED (no marker: a box no provisioning marked, or a setup that finished); +# the accepted email masked (mask(): o***@e***.com), and whether accept with +# replace may still replace it; +# text {version, sha256, text}: the license to accept now, only while the marker is +# there: from the channel's manifest (the installed one when offline) and the text +# kept on the box, or downloaded and checked against the manifest's SHA-256; +# accept {email, eula_sha256, owner_use, replace} -> {ok, state}: RECORDED, or QUEUED +# (offline); +# flush {} -> {ok, state}: a queued acceptance sent, if there is one (while the marker +# is there). +# One send at a time (LOCK_NAME, an flock in the state directory): accept and the timer's +# flush at once would each POST the queue; and each queued acceptance carries a request_id +# of its own (random), sent with every try, so one sent again after its answer was lost (a +# caller killed mid-POST) is one row at the license server, not two (migrations/0006). A request waits for it at most LOCK_SECS, well +# within the caller's own limit (owner_license.HELPER_SECS), then is refused as BUSY. The email reaches the license server, the queue +# and the record, and nothing else: no reply carries it but masked, no log line or error. Nothing here writes, renames or removes +# PROTECTED (the engine's license files, teaport#474 F1). +# +# Run as the sudoers line (packaging/deb/sudoers-sync) names it: +# /usr/bin/python3 /usr/lib/teaport/license_accept.py +# the root-owned copy the teaport-brain package ships, on the SYSTEM python, never the +# venv's (like login_apply.py). Standard library only. Tests run it in-process (handle()) +# against a pretend license server and a temporary tree (Box). +# +import fcntl +import hashlib +import json +import os +import pwd +import re +import secrets +import stat +import subprocess +import sys +import tempfile +import time +import unicodedata +import urllib.error +import urllib.request + +STATE_DIR = "/var/lib/teaport" +RECORD_PATH = STATE_DIR + "/eula-accepted.json" # install.sh's EULA_RECEIPT +QUEUE_PATH = STATE_DIR + "/eula-queued.json" +# Setup is unfinished while this is there: provisioning writes it at seal (beside the +# login's pending marker, Teaspoon-AI/teaport-appliance#3), the link helper removes it once +# the owner's acceptance is on the box's key (license_link.py). Nothing in this package +# writes it. +GATE_PATH = "/var/lib/teaport-owner/license-pending" +INSTALLED_MANIFEST = "/opt/teaport/manifest.json" +# The license server and the files it publishes: install.sh's own (its default manifest, +# https://get.teaspoon.tech/manifest/stable.json, whose access.api this is). +ORIGIN = "https://get.teaspoon.tech" +API = ORIGIN + "/api" +MANIFEST_BASE = ORIGIN + "/manifest" +LINKED_PATH = STATE_DIR + "/license-link.json" # license_link.LINKED_PATH +LOCK_NAME = ".eula-accept.lock" +LOCK_SECS = 30 +# The owner's login is still to be made while this is there (login_apply.PENDING_PATH). +LOGIN_PENDING_PATH = "/var/lib/teaport-owner/pending" +BRAIN_UNIT = "teaport-brain.service" +TOOL_ENV = {"PATH": "/usr/sbin:/usr/bin:/sbin:/bin", "LC_ALL": "C"} +OWNER_USES = ("personal", "business") +APPLIANCE_ID = "/etc/appliance-id" +MACHINE_ID = "/etc/machine-id" +BUILD_RECORD = "/opt/teaport/brain/teaport-build.json" +# The engine's license files (teaport#474 F1): no root helper the run user reaches writes, +# renames or removes them. The same tuple in every one of them (tests hold them equal). +PROTECTED = ("/etc/teaport/license.json", "/etc/teaport/license-revocations.json", + "/etc/teaport/license-link.secret") +CHANNELS = ("stable", "beta") +MAX_REQUEST = 4096 +MAX_MANIFEST = 1 << 20 +MAX_TEXT = 1 << 20 +NET_SECS = 20 +# The license server's own rule for an email (worker/src/index.js accept()), so a typo is +# the page's to show, not a queued request the server later refuses. +EMAIL = re.compile(r"^[^\s@]+@[^\s@]+\.[^\s@]+$") +CONTROL = re.compile(r"[\x00-\x1f\x7f]") +ACCEPTANCE_ID = re.compile(r"[A-Za-z0-9_-]{8,64}") +# status's answers. +PENDING, QUEUED, RECORDED, NOT_OFFERED = "pending", "queued", "recorded", "not_offered" +# Why a request was refused, as codes; owner_license.py turns them into the words people see. +REFUSED, ACCEPTED, EMAIL_BAD, CHANGED, UNAVAILABLE, DROPPED, FAILED, USE, BUSY = ( + "refused", "accepted", "email", "changed", "unavailable", "dropped", "failed", "use", "busy") +# What each verb takes: nothing else, an acceptance id least of all. +FIELDS = {"status": set(), "text": set(), "accept": {"email", "eula_sha256", "owner_use", "replace"}, + "flush": set()} + + +class Refused(Exception): + """A request this helper does not do. `why` is one of the codes above.""" + + def __init__(self, text: str, why: str = REFUSED): + super().__init__(text) + self.why = why + + +def guard(path: str) -> str: + """`path`, unless it is one of PROTECTED, by name or through a link (teaport#474 F1).""" + if os.path.abspath(path) in PROTECTED or os.path.realpath(path) in PROTECTED: + raise Refused(f"{path} is the engine's license, which this helper never writes") + return path + + +class Marker: + """Provisioning's marker: there, and root's alone (login_apply.Marker's rule): one in a + directory the run user can write, or a file that is not root's or is a link, is none.""" + + def __init__(self, path: str = GATE_PATH, owner: int = 0): + self.path, self.owner = path, owner + + def _roots(self, st: os.stat_result, kind) -> bool: + return kind(st.st_mode) and st.st_uid == self.owner and not st.st_mode & 0o022 + + def present(self) -> bool: + try: + directory = os.lstat(os.path.dirname(self.path)) + marker = os.lstat(self.path) + except FileNotFoundError: + return False + return self._roots(directory, stat.S_ISDIR) and self._roots(marker, stat.S_ISREG) + + +def _no_redirect(): + """An opener that follows no redirect: every URL here is https and named by the + manifest, and a redirect would let whoever answers send the email elsewhere.""" + class Refuse(urllib.request.HTTPRedirectHandler): + def redirect_request(self, *a, **k): + return None + return urllib.request.build_opener(Refuse) + + +def fetch(url: str, body: dict | None = None, limit: int = MAX_MANIFEST) -> tuple[int, bytes]: + """GET `url`, or POST `body` as JSON: (status, at most `limit` bytes of the answer); + status 0 when there is no answer (offline, a timeout, a URL that is not https).""" + if not url.startswith("https://"): + return 0, b"" + data = json.dumps(body).encode() if body is not None else None + req = urllib.request.Request(url, data=data, method="POST" if data is not None else "GET", + headers={"content-type": "application/json", + "user-agent": "teaport-license-accept"}) + try: + with _no_redirect().open(req, timeout=NET_SECS) as r: # noqa: S310 -- https only + return r.status, r.read(limit + 1)[:limit] + except urllib.error.HTTPError as e: + try: + return e.code, e.read(limit) + except OSError: + return e.code, b"" + except (OSError, ValueError): + return 0, b"" + + +class Box: + """Where this helper reads and writes, and how it reaches the network (a test's own).""" + + def __init__(self, state_dir: str = STATE_DIR, gate: Marker | None = None, + installed_manifest: str = INSTALLED_MANIFEST, appliance_id: str = APPLIANCE_ID, + machine_id: str = MACHINE_ID, build_record: str = BUILD_RECORD, + net=fetch, now=time.time, login: Marker | None = None, + caller: int | None = None, run_uid=None, token=lambda: secrets.token_urlsafe(18)): + """`login`: the login's pending marker; `caller`: SUDO_UID as sudo set it (None: + root's own call); `run_uid`: the brain's user's uid, or a function giving it (None: + it cannot be told). The defaults are a test's: root's own call.""" + self.state_dir, self.gate = state_dir, gate or Marker() + self.login = login or Marker(LOGIN_PENDING_PATH) + self.caller, self._run_uid = caller, run_uid + self.token = token # a queued acceptance's own request_id (send()) + self.record = os.path.join(state_dir, os.path.basename(RECORD_PATH)) + self.queue = os.path.join(state_dir, os.path.basename(QUEUE_PATH)) + self.installed_manifest, self.appliance_id = installed_manifest, appliance_id + self.machine_id, self.build_record = machine_id, build_record + self.linked = os.path.join(state_dir, os.path.basename(LINKED_PATH)) + self.lock = os.path.join(state_dir, LOCK_NAME) + self.net, self.now = net, now + + def text_path(self, version: str) -> str: + return os.path.join(self.state_dir, f"EULA-v{version}.txt") + + def run_uid(self) -> int | None: + return self._run_uid() if callable(self._run_uid) else self._run_uid + + def by_run_user(self) -> bool: + """The request is the run user's (its sudoers line), or cannot be told from one: + SUDO_UID is set, not root's, and is the brain's user's or that cannot be told.""" + if self.caller is None or self.caller == 0: + return False + run = self.run_uid() + return run is None or self.caller == run + + @classmethod + def real(cls) -> "Box": + raw = os.environ.get("SUDO_UID") # sudo sets it itself: the run user cannot + return cls(caller=int(raw) if raw and raw.isdigit() else None, run_uid=_run_uid) + + +def _run_uid() -> int | None: + """The brain's User='s uid (as sudoers-sync reads it), None when it cannot be told.""" + try: + p = subprocess.run(["systemctl", "show", "-p", "User", "--value", BRAIN_UNIT], + capture_output=True, text=True, timeout=10, env=TOOL_ENV) + return pwd.getpwnam(p.stdout.strip()).pw_uid if p.returncode == 0 and p.stdout.strip() else None + except (OSError, KeyError, subprocess.SubprocessError): + return None + + +# ------------------------------------------------------------------ files + +def _read_json(path: str, limit: int = MAX_MANIFEST) -> dict | None: + """A JSON object from a regular file (not a link), else None.""" + try: + fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW) + except OSError: + return None + try: + with os.fdopen(fd, "rb") as f: + if not stat.S_ISREG(os.fstat(f.fileno()).st_mode): + return None + data = json.loads(f.read(limit + 1)[:limit]) + except (OSError, ValueError): + return None + return data if isinstance(data, dict) else None + + +def _read_text(path: str) -> str | None: + try: + fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW) + with os.fdopen(fd, "rb") as f: + return f.read(MAX_TEXT + 1)[:MAX_TEXT].decode("utf-8") if stat.S_ISREG(os.fstat(f.fileno()).st_mode) else None + except (OSError, ValueError): + return None + + +def write_file(path: str, data: bytes, mode: int) -> None: + """`data` into `path`, whole or not at all: a temporary file of root's own in the same + directory (made root's 0755 if it is not there), at `mode` before a byte is written, + synced, renamed into place, and the directory synced.""" + guard(path) + directory = os.path.dirname(path) + os.makedirs(directory, mode=0o755, exist_ok=True) + fd, tmp = tempfile.mkstemp(dir=directory, prefix="." + os.path.basename(path) + ".") + try: + os.fchmod(fd, mode) + with os.fdopen(fd, "wb") as f: + f.write(data) + f.flush() + os.fsync(f.fileno()) + os.replace(tmp, path) + except BaseException: + try: + os.unlink(tmp) + except OSError: + pass + raise + dfd = os.open(directory, os.O_RDONLY) + try: + os.fsync(dfd) + finally: + os.close(dfd) + + +def _remove(path: str) -> None: + guard(path) + try: + os.unlink(path) + except FileNotFoundError: + pass + + +# ------------------------------------------------------------------ what the box is + +def device_id(box: Box) -> str: + """Which device the acceptance names (the module comment): the appliance serial's hash + on a factory box, the machine id's elsewhere; "" when the box has neither.""" + serial = _read_text(box.appliance_id) + if serial is not None: + serial = serial[:-1] if serial.endswith("\n") else serial + if serial and not re.search(r"\s", serial) and not CONTROL.search(serial): + return hashlib.sha256(f"teaport-appliance:{serial}".encode()).hexdigest() + machine = re.sub(r"\s", "", _read_text(box.machine_id) or "") + return hashlib.sha256(f"teaport-device:{machine}".encode()).hexdigest() if machine else "" + + +def installer(box: Box) -> str: + """Where the acceptance was made, for its `installer` (the license server's rule: at + most 64 of [A-Za-z0-9._:+-]): the setup page, and the brain's revision.""" + rev = (_read_json(box.build_record) or {}).get("revision") + if isinstance(rev, str) and re.fullmatch(r"[0-9a-f]{7,40}(-dirty)?", rev): + return f"setup:git:{rev}"[:64] + return "setup:unknown" + + +def _eula_of(manifest: dict) -> dict | None: + """{channel, version, url, sha256} of a manifest's license; None when it has no released + license, or names a license server other than API or a text off ORIGIN.""" + e = (manifest.get("engine") or {}).get("eula") if isinstance(manifest.get("engine"), dict) else None + api = (manifest.get("access") or {}).get("api") if isinstance(manifest.get("access"), dict) else None + if not isinstance(e, dict) or not isinstance(api, str) or api.rstrip("/") != API: + return None # another license server, whoever wrote the manifest: no license here + version, url, sha = e.get("version"), e.get("url"), e.get("sha256") + if not (isinstance(version, str) and re.fullmatch(r"[A-Za-z0-9._-]{1,32}", version) + and isinstance(url, str) and url.startswith(ORIGIN + "/") and "TODO" not in url + and isinstance(sha, str) and re.fullmatch(r"[0-9a-f]{64}", sha)): + return None + channel = manifest.get("channel") if manifest.get("channel") in CHANNELS else "stable" + return {"channel": channel, "version": version, "url": url, "sha256": sha} + + +def current(box: Box) -> dict | None: + """The license to accept now (_eula_of): the channel's manifest, else (offline) the + installed one's.""" + installed = _read_json(box.installed_manifest) or {} + channel = installed.get("channel") if installed.get("channel") in CHANNELS else "stable" + status, data = box.net(f"{MANIFEST_BASE}/{channel}.json") + if status == 200: + try: + fresh = _eula_of(json.loads(data)) + except ValueError: + fresh = None + if fresh: + return fresh + return _eula_of(installed) + + +def license_text(box: Box, eula: dict) -> str | None: + """The text of `eula`, checked against its SHA-256: the copy on the box, else downloaded + and kept there (0644, as install.sh keeps it); None when neither can be had.""" + path = box.text_path(eula["version"]) + try: + with open(path, "rb") as f: + data = f.read(MAX_TEXT + 1) + except OSError: + data = None + if data is None or hashlib.sha256(data).hexdigest() != eula["sha256"]: + status, data = box.net(eula["url"], limit=MAX_TEXT) + if status != 200 or hashlib.sha256(data).hexdigest() != eula["sha256"]: + return None + write_file(path, data, 0o644) + try: + return data.decode("utf-8") + except ValueError: + return None + + +# ------------------------------------------------------------------ the record + +def recorded(box: Box) -> dict | None: + """The acceptance on the box: a receipt with an acceptance id that is not the factory's + (install.sh's, or this helper's), else None.""" + r = _read_json(box.record) + if not r or r.get("method") == "factory": + return None + aid = r.get("acceptance_id") + return r if isinstance(aid, str) and ACCEPTANCE_ID.fullmatch(aid) and not aid.startswith("maker-") else None + + +def valid_email(email) -> bool: + """An address the license server takes (its own rule, worker/src/index.js accept()): at + most 254 bytes of UTF-8 (both count bytes); no control or format character anywhere + (Unicode Cc, Cf: a zero-width space, a right-to-left override; also ZWNJ and ZWJ, which + some Persian and Indic domains need: refused all the same, a trade-off accepted); and as + NFKC leaves it (a fullwidth letter, a Kelvin sign, a Roman numeral would read as another + address's, and the mask's IDNA step would fold them): what would make one address look + like another.""" + if not isinstance(email, str): + return False + e = email.strip() + return (len(e.encode("utf-8", "surrogatepass")) <= 254 and bool(EMAIL.match(e)) + and not any(unicodedata.category(c) in ("Cc", "Cf", "Cs") for c in email) + and unicodedata.normalize("NFKC", email) == email) + + +def mask(email) -> str | None: + """An email as the page shows it, to tell the owner whose it is without saying it whole + to the run user: the whole domain, in its ASCII form (IDNA, punycode: a lookalike letter + from another script shows as xn--), and of the part before it the first and last + character, with one * for each in between, so its length shows (owner@example.com: + o***r@example.com; ox@ex.com: o*@ex.com). A hint, not a proof: another address with the + same first and last character, length and domain looks the same, and support re-links + a box whose acceptance is not its owner's (docs: security.md).""" + if not isinstance(email, str) or "@" not in email: + return None + local, _, domain = email.strip().rpartition("@") + try: + domain = domain.encode("idna").decode("ascii") + except UnicodeError: + domain = "".join(c if c.isascii() else "?" for c in domain) + if len(local) == 1: + return f"*@{domain}" # its one character would be all of it + if len(local) == 2: + return f"{local[0]}*@{domain}" + return f"{local[0]}{'*' * (len(local) - 2)}{local[-1]}@{domain}" + + +def linked(box: Box, aid: str) -> bool: + """`aid` is on the box's key already (license_link.py's record of the link).""" + done = _read_json(box.linked) or {} + return done.get("linked") is True and done.get("acceptance_id") == aid + + +def state(box: Box) -> str: + """QUEUED while an acceptance waits to be sent during setup, even one in place of the + record (the newer one), else RECORDED, PENDING or NOT_OFFERED.""" + if box.gate.present() and _read_json(box.queue): + return QUEUED + if recorded(box): + return RECORDED + return PENDING if box.gate.present() else NOT_OFFERED + + +def open_to(box: Box) -> bool: + """Who asks may accept here now: anyone while setup is unfinished (the marker), and an + administrator (sudo with their password, or root) at any time: the owner holding the box + puts their own acceptance on it (support's re-link: possession outranks any record).""" + return box.gate.present() or not box.by_run_user() + + +def replaceable(box: Box) -> bool: + """The acceptance on the box may still be replaced (accept with replace), by whoever asks: + this helper's, recorded or queued. For the run user, only while setup is unfinished, + before its link is made and while the owner's login is still to be made; for an + administrator, at any time (open_to).""" + rec = recorded(box) + if not box.by_run_user(): + return rec is None or rec.get("method") == "setup" + if not box.gate.present() or not box.login.present(): + return False + if rec: + return rec.get("method") == "setup" and not linked(box, rec["acceptance_id"]) + return _read_json(box.queue) is not None + + +def status(box: Box) -> dict: + got = state(box) + who = (recorded(box) or {}).get("email") if got == RECORDED else (_read_json(box.queue) or {}).get("email") + return {"state": got, "email": mask(who) if got in (QUEUED, RECORDED) else None, + "replaceable": got in (QUEUED, RECORDED) and replaceable(box)} + + +class _Locked: + """One send at a time (the module comment): an flock on root's own file in the state + directory, held until the block ends. A second one waits for the first, at most `wait` + seconds: then BUSY, said as "busy, try again".""" + + def __init__(self, box: Box, wait: float | None = None): + self.path, self.fd, self.wait = guard(box.lock), None, LOCK_SECS if wait is None else wait + + def __enter__(self): + os.makedirs(os.path.dirname(self.path), mode=0o755, exist_ok=True) + self.fd = os.open(self.path, os.O_RDWR | os.O_CREAT | os.O_NOFOLLOW, 0o600) + deadline = time.monotonic() + self.wait + while True: + try: + fcntl.flock(self.fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + return self + except BlockingIOError: + if time.monotonic() >= deadline: + os.close(self.fd) + raise Refused("another acceptance is being sent: try again in a moment", BUSY) from None + time.sleep(0.2) + + def __exit__(self, *exc): + os.close(self.fd) # the lock goes with it + + +def send(box: Box) -> str: + """The queued acceptance, sent to API: RECORDED (the record written, the queue gone), + QUEUED (no answer, or one that may change: it waits), or DROPPED (refused for good: the + queue goes, and the step is offered again). The caller holds _Locked.""" + q = _read_json(box.queue) + if not q: + return RECORDED if recorded(box) else PENDING + body = {"channel": q.get("channel"), "eula_version": q.get("version"), "eula_sha256": q.get("sha256"), + "email": q.get("email"), "use": "personal", "owner_use": q.get("owner_use"), + "device_id": q.get("device_id") or None, "method": "tty", "installer": q.get("installer")} + # The queue's own id, the same at every send of it: a send whose answer was lost (the + # caller killed mid-POST, the network) and is sent again records no second row. + if isinstance(q.get("request_id"), str): + body["request_id"] = q["request_id"] + status, data = box.net(f"{API}/accept", body) + try: + answer = json.loads(data) if status else {} + except ValueError: + answer = {} + aid = answer.get("acceptance_id") if isinstance(answer, dict) else None + if status == 200 and isinstance(aid, str) and ACCEPTANCE_ID.fullmatch(aid) and not aid.startswith("maker-"): + rec = {"version": q["version"], "sha256": q["sha256"], + "date": time.strftime("%Y-%m-%dT%H:%M:%S%z", time.localtime(box.now())), + "method": "setup", "acceptance_id": aid, "recorded_with": API, + "email": q["email"], "use": "personal", "owner_use": q.get("owner_use"), + "channel": q["channel"]} + # The record first, then the queue: a cut between the two leaves both, and the next + # flush sends the queue again, which its request_id makes the same acceptance. + write_file(box.record, (json.dumps(rec) + "\n").encode(), 0o600) + _remove(box.queue) + return RECORDED + if status in (400, 404, 409): # the license changed meanwhile, or a request it refuses + _remove(box.queue) + return DROPPED + return QUEUED + + +def text(box: Box) -> dict: + if not open_to(box): + raise Refused("setup is finished on this box: the license is accepted through it no more", NOT_OFFERED) + eula = current(box) + body = license_text(box, eula) if eula else None + if body is None: + raise Refused("the license text is not on this box, and it cannot be fetched now", UNAVAILABLE) + return {"version": eula["version"], "sha256": eula["sha256"], "text": body} + + +def accept(box: Box, req: dict) -> dict: + with _Locked(box): + if not open_to(box): + raise Refused("setup is finished on this box: the license is accepted through it no more", NOT_OFFERED) + replace = req.get("replace", False) + if replace not in (True, False): + raise Refused("replace is true or false") + if recorded(box) or _read_json(box.queue): + if not replace: + raise Refused("the license is already accepted on this box", ACCEPTED) + if not replaceable(box): + raise Refused("the license's acceptance on this box is no longer replaced from here: " + "it is linked to the box's key, or the owner's login is made", ACCEPTED) + email = req.get("email") + if not valid_email(email): + raise Refused("that is not an email address", EMAIL_BAD) + if req.get("owner_use") not in OWNER_USES: + raise Refused("owner_use: personal or business", USE) + eula = current(box) + if not eula or license_text(box, eula) is None: + raise Refused("the license text is not on this box, and it cannot be fetched now", UNAVAILABLE) + if req.get("eula_sha256") != eula["sha256"]: + raise Refused("the license shown is not the current one: read it again", CHANGED) + q = {"email": email.strip(), "channel": eula["channel"], "version": eula["version"], + "sha256": eula["sha256"], "owner_use": req["owner_use"], "device_id": device_id(box), + "installer": installer(box), "request_id": box.token(), + "queued_at": int(box.now())} + # Replaced (checked above): the queue takes its place, and the record stays until the + # new one is recorded (send() writes it over then): a send that fails, waits or is + # dropped leaves the box's receipt as it was, which install.sh and `teaport update` + # get their tokens with. + write_file(box.queue, (json.dumps(q) + "\n").encode(), 0o600) + got = send(box) + if got == QUEUED and not box.gate.present(): + # An administrator's, after setup: no timer sends a queue then (flush()), so it + # is sent now or not at all. + _remove(box.queue) + raise Refused("the license server cannot be reached now: try again online", UNAVAILABLE) + if got == DROPPED: + return {"ok": False, "why": DROPPED} + return {"ok": True, "state": got} + + +def flush(box: Box) -> dict: + """The queued acceptance, sent; only while setup is unfinished, as a queue is written only + then (and the marker goes only once its acceptance is recorded and linked): a queue found + without it was not this helper's.""" + with _Locked(box): + if not box.gate.present(): + return {"ok": True, "state": RECORDED if recorded(box) else NOT_OFFERED, "sent": False} + queued = _read_json(box.queue) is not None + got = send(box) + return {"ok": got != DROPPED, "state": got, "sent": queued, + **({"why": DROPPED} if got == DROPPED else {})} + + +def handle(box: Box, verb: str, req) -> dict: + """One request: check it, do it, say how it went. Raises Refused for anything else.""" + if not isinstance(req, dict): + raise Refused("the request must be a JSON object") + if verb not in FIELDS: + raise Refused(f"unknown request {verb!r}") + extra = set(req) - FIELDS[verb] + if extra: + # An acceptance id above all: this helper records the one the license server + # returns, never one it is given. + raise Refused(f"{verb} takes no {', '.join(sorted(extra))}") + if verb == "status": + return status(box) + if verb == "text": + return text(box) + if verb == "accept": + return accept(box, req) + return flush(box) + + +def _reply(obj: dict) -> None: + sys.stdout.write(json.dumps(obj) + "\n") + sys.stdout.flush() + + +def main(argv: list[str] | None = None, box: Box | None = None) -> int: + argv = sys.argv[1:] if argv is None else argv + if box is None and os.geteuid() != 0: + _reply({"refused": "run as root, through the sudoers line", "why": REFUSED}) + return 2 + if len(argv) != 1: + _reply({"refused": "usage: license_accept.py (the request as JSON on stdin)", "why": REFUSED}) + return 2 + try: + data = sys.stdin.read(MAX_REQUEST + 1) if not sys.stdin.isatty() else "" + if len(data) > MAX_REQUEST: + raise Refused("the request is too long") + try: + req = json.loads(data) if data.strip() else {} + except ValueError: + raise Refused("the request is not JSON") from None + reply = handle(box or Box.real(), argv[0], req) + except Refused as e: + _reply({"refused": str(e), "why": e.why}) + return 2 + except Exception as e: # noqa: BLE001 -- by its type alone: an exception's text can quote the email + sys.stderr.write(f"license_accept: {type(e).__name__}\n") + _reply({"ok": False, "why": FAILED}) + return 1 + if argv[0] == "flush" and reply.get("sent"): + sys.stderr.write(f"license_accept: the queued acceptance: {reply.get('state')}\n") # the timer's journal + _reply(reply) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/brain/teaport_brain/license_link.py b/brain/teaport_brain/license_link.py new file mode 100644 index 00000000..95025eeb --- /dev/null +++ b/brain/teaport_brain/license_link.py @@ -0,0 +1,637 @@ +# +# teaport — the owner's acceptance put on the box's appliance key (#465): POST +# /license/link, as root, behind sudo, and from teaport-license-owner.timer. +# +# The box's engine license key (/etc/teaport/license.json, #474) holds no personal data: +# the license server links it to its owner's acceptance instead, which the owner made at +# setup (license_accept.py). The link needs proof that the box itself asks, since the box's +# agent can read license.json: the link secret the license server returned with the key at +# the factory, which install.sh is to keep (teaport#475, I1) in +# /etc/teaport/license-link.secret, root's 0600 (the run user, the agent included, cannot +# read it). This helper sends it, with ids only: +# - it takes no acceptance id, nor anything else (a request that names anything is +# refused). It links the acceptance on the box's record (/var/lib/teaport/eula-accepted.json, +# which only root writes: license_accept.py's, or install.sh's), the key in license.json +# and the secret, all three read here; +# - when the run user asks (through its sudoers line), only while setup is unfinished +# (provisioning's marker, GATE_PATH, is there). Setup finishes when the link is made: +# the marker goes. Not "while an owner's session from the setup page is open": the +# session (settings_access.py) is signed with a key in brain.env, which the run user +# reads, so the run user could make one, and no root helper can tell it from the +# owner's. The owner's own login (`teaport`, in the sudo group) reaches it through sudo +# with their password at any time, and root's own call (the timer) does: sudo sets +# SUDO_UID itself, so the run user cannot pass for either; +# - so a prompt-injected agent can at worst have the box linked to the acceptance on its +# own record, the owner's, again: a link to the acceptance already linked changes +# nothing (no request at all: LINKED_PATH says so), and the license server's answer for +# one sent anyway is the same. +# +# Where: API, built in (license_accept.API), never the record's recorded_with: an older +# installer's receipt may be a file the run user could write, and the secret would go wherever +# it said. A record naming another server is not linked at all. +# +# A box without the secret file (installed before install.sh writes it, teaport#475) is +# logged and left as it is: nothing is sent, no refusal remembered, the record and the marker +# kept, so the timer links it once the secret is there. A box with no appliance key, or no +# recorded acceptance, has nothing to link. The license server's answers: +# - linked: the link is recorded (LINKED_PATH) and the marker goes: setup is finished; +# - the acceptance is no longer one it links (409 eula_changed: the license changed before +# the link was made; 404 unknown_acceptance): the setup's record goes (the marker stays), +# so the setup step is offered again and the owner accepts the current license; +# - busy (409 conflict, 429, 5xx) or no answer: asked again, by the timer; +# - any other refusal (the secret, the key): remembered for that acceptance, key and secret +# (LINKED_PATH): root's own call does not ask again until one of them changes; the run +# user or the owner may. +# Every link rotates the secret (the handover): the answer carries a new one, written here +# (write_secret: root's 0600, atomically) in place of the old, and shown to the license +# server at once with the same link (the confirm, answered with no new secret); only then +# is the link recorded and the marker gone. Until the confirm, the license server still +# takes the old secret, so a write that failed, or a confirm that was lost, is retried with +# whichever secret the box holds. After it, a copy of an older secret (a previous owner had +# root on the box) links nothing. +# +# Whoever links first wins: a copy of the secret, made by someone who had root on the box (a +# previous owner), can take the link, and rotates it away from the box. Nothing can tell the +# real box from such a copy, so a contest is made visible and recoverable (the owner's +# decision, 2026-11-28: support fixes a wrong link): a 403 bad_link_secret for a secret that +# linked before is LOST, said in status (the setup page, Settings, `teaport status`) and the +# journal, not remembered as a refusal. Support verifies the owner and sets a one-time +# recovery code as the key's secret (packaging/RELEASING.md); the owner types it on the box +# (`sudo python3 license_link.py link --recovery-code`, at a prompt), it links once, before +# it runs out, and the rotation that follows gives the box a fresh secret (a lost answer +# can be asked again with the code until the confirm, for at most a day). A secret that +# never linked, refused with bad_link_secret (its first try or a later one), is LOST too, +# its cause unknown (CAUSE_UNKNOWN): a secret the factory wrote wrong, a key issued before +# its secret hash (migration 0005), a copy's holder who linked first, a handover answer +# lost; the box cannot tell which (an answer it got would have linked, and made the +# refusal a plain LOST), and only support puts any of them right. A run user that kills +# this helper mid-handover keeps the previous secret alive, which only the box (and +# root) holds: it gives a party without root nothing. +# +# One at a time with license_accept.py's sends (its lock, waited for at most LOCK_SECS, then +# BUSY): a replaced acceptance is never linked as the old one. +# +# Verbs (the only argument; the request is a JSON object on stdin, the reply one on stdout; +# a request this does not do gets {"refused": why, "why": code} and exit 2): +# status {state}: LINKED, UNLINKED, NO_SECRET, NO_KEY or NO_ACCEPTANCE; +# link {} -> {ok, linked, changed} or {ok: false, why}. +# The secret reaches the license server and nothing else: no reply, no log line, no error. +# Nothing here writes, renames or removes PROTECTED (the engine's license files, #474 F1). +# +# Run as the sudoers line (packaging/deb/sudoers-sync) names it: +# /usr/bin/python3 /usr/lib/teaport/license_link.py +# the root-owned copy the teaport-brain package ships, on the SYSTEM python, never the +# venv's. Standard library only. Tests run it in-process (handle()) against a pretend +# license server and a temporary tree (Box). +# +import fcntl +import hashlib +import json +import os +import pwd +import re +import stat +import subprocess +import sys +import tempfile +import time +import urllib.error +import urllib.request + +ORIGIN = "https://get.teaspoon.tech" # license_accept.ORIGIN +API = ORIGIN + "/api" # license_accept.API +RECORD_PATH = "/var/lib/teaport/eula-accepted.json" +LINKED_PATH = "/var/lib/teaport/license-link.json" +GATE_PATH = "/var/lib/teaport-owner/license-pending" # license_accept.GATE_PATH +LICENSE_PATH = "/etc/teaport/license.json" +SECRET_PATH = "/etc/teaport/license-link.secret" +# The engine's license files (teaport#474 F1): no root helper the run user reaches writes, +# renames or removes them, but for one write here: write_secret, the new link secret a link +# answers with (the handover). The one list: every other helper's copy must equal it (tests). +PROTECTED = ("/etc/teaport/license.json", "/etc/teaport/license-revocations.json", + "/etc/teaport/license-link.secret") +BRAIN_UNIT = "teaport-brain.service" +MAX_REQUEST = 4096 +NET_SECS = 20 +# The secret as install.sh writes it: 32 bytes, base64url without padding (43 characters), +# then at most a newline. +SECRET = re.compile(r"[A-Za-z0-9_-]{43}\n?") +ACCEPTANCE_ID = re.compile(r"[A-Za-z0-9_-]{8,64}") +LICENSE_ID = re.compile(r"[A-Z0-9][A-Z0-9-]{3,39}") +TPDEV2 = re.compile(r"tpdev2-[0-9a-f]{32}") +SERVER_CODE = re.compile(r"[a-z_]{1,40}") +LINKED, UNLINKED, NO_SECRET, NO_KEY, NO_ACCEPTANCE, LOST, QUEUED = ( + "linked", "unlinked", "no_secret", "no_key", "no_acceptance", "lost", "queued") +# A lost link whose secret never linked on this box, refused with bad_link_secret: the +# box cannot tell why (the module comment). Shown as LOST (status), told +# apart in the reply and log, in neutral words: the link failed, ask support. +CAUSE_UNKNOWN = "cause_unknown" +QUEUE_NAME = "eula-queued.json" # license_accept.QUEUE_PATH's +# A link's handover not yet settled: root's, written before the link, gone once it is +# confirmed or refused for good; teaport-license-owner.service runs while it is there. +HANDOVER_NAME = "license-handover" +HANDOVER_PATH = "/var/lib/teaport/" + HANDOVER_NAME +REFUSED, SETUP_DONE, UNREACHABLE, FAILED, OTHER_SERVER, ACCEPT_AGAIN = ( + "refused", "setup_done", "unreachable", "failed", "other_server", "accept_again") +# The license server's answers that mean the acceptance is no longer one it links: the setup +# step is offered again (the module comment). +STALE = {(409, "eula_changed"), (404, "unknown_acceptance")} +LOCK_NAME = ".eula-accept.lock" # license_accept.LOCK_NAME +LOCK_SECS = 30 # license_accept.LOCK_SECS +# A link and its confirm, and a retry of each: the handover (the module comment). +HANDOVERS = 4 +BUSY = "busy" +TOOL_ENV = {"PATH": "/usr/sbin:/usr/bin:/sbin:/bin", "LC_ALL": "C"} + + +class Refused(Exception): + def __init__(self, text: str, why: str = REFUSED): + super().__init__(text) + self.why = why + + +def guard(path: str) -> str: + """`path`, unless it is one of PROTECTED, by name or through a link (teaport#474 F1).""" + if os.path.abspath(path) in PROTECTED or os.path.realpath(path) in PROTECTED: + raise Refused(f"{path} is the engine's license, which this helper never writes") + return path + + +class Marker: + """Provisioning's marker (license_accept.Marker): there, and root's alone.""" + + def __init__(self, path: str = GATE_PATH, owner: int = 0): + self.path, self.owner = path, owner + + def _roots(self, st: os.stat_result, kind) -> bool: + return kind(st.st_mode) and st.st_uid == self.owner and not st.st_mode & 0o022 + + def present(self) -> bool: + try: + directory = os.lstat(os.path.dirname(self.path)) + marker = os.lstat(self.path) + except FileNotFoundError: + return False + return self._roots(directory, stat.S_ISDIR) and self._roots(marker, stat.S_ISREG) + + def remove(self) -> None: + guard(self.path) + try: + os.unlink(self.path) + except FileNotFoundError: + pass + + +def _no_redirect(): + class Refuse(urllib.request.HTTPRedirectHandler): + def redirect_request(self, *a, **k): + return None + return urllib.request.build_opener(Refuse) + + +def post(url: str, body: dict) -> tuple[int, bytes]: + """POST `body` as JSON to an https `url`: (status, the answer); 0 for no answer. No + redirect is followed: one would take the secret wherever it said.""" + if not url.startswith("https://"): + return 0, b"" + req = urllib.request.Request(url, data=json.dumps(body).encode(), method="POST", + headers={"content-type": "application/json", + "user-agent": "teaport-license-link"}) + try: + with _no_redirect().open(req, timeout=NET_SECS) as r: # noqa: S310 -- https only + return r.status, r.read(65536) + except urllib.error.HTTPError as e: + try: + return e.code, e.read(65536) + except OSError: + return e.code, b"" + except (OSError, ValueError): + return 0, b"" + + +def run_user(run=subprocess.run) -> str: + """The brain's User= (as sudoers-sync reads it): "" when it cannot be told.""" + try: + p = run(["systemctl", "show", "-p", "User", "--value", BRAIN_UNIT], + capture_output=True, text=True, timeout=10, env=TOOL_ENV) + return p.stdout.strip() if p.returncode == 0 else "" + except (OSError, subprocess.SubprocessError): + return "" + + +def uid_of(name: str) -> int | None: + try: + return pwd.getpwnam(name).pw_uid + except (KeyError, TypeError): + return None + + +class Box: + """Where this helper reads and writes, who asks, and how it reaches the network (a + test's own). `caller`: SUDO_UID as sudo set it (None: root's own call, the timer); + `run_uid`: the brain's user's uid (None when it cannot be told).""" + + def __init__(self, record: str = RECORD_PATH, linked: str = LINKED_PATH, + gate: Marker | None = None, license_path: str = LICENSE_PATH, + secret: str = SECRET_PATH, net=post, caller: int | None = None, + run_uid=None, now=time.time, secret_owner: int = 0): + self.record, self.linked, self.gate = record, linked, gate or Marker() + self.license_path, self.secret, self.net, self.now = license_path, secret, net, now + self.caller, self.secret_owner = caller, secret_owner + self.recovery_prompt = _prompt # main()'s for --recovery-code (a test's own) + self._run_uid = run_uid + + def run_uid(self) -> int | None: + if callable(self._run_uid): + return self._run_uid() + return self._run_uid + + def by_run_user(self) -> bool: + """The request is the run user's (its sudoers line), or cannot be told from one + (license_accept.Box.by_run_user's rule).""" + if self.caller is None or self.caller == 0: + return False + run = self.run_uid() + return run is None or self.caller == run + + @classmethod + def real(cls) -> "Box": + raw = os.environ.get("SUDO_UID") + caller = int(raw) if raw and raw.isdigit() else None + return cls(caller=caller, run_uid=lambda: uid_of(run_user())) + + +def _read_json(path: str, limit: int = 65536) -> dict | None: + try: + fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW) + except OSError: + return None + try: + with os.fdopen(fd, "rb") as f: + if not stat.S_ISREG(os.fstat(f.fileno()).st_mode): + return None + data = json.loads(f.read(limit + 1)[:limit]) + except (OSError, ValueError): + return None + return data if isinstance(data, dict) else None + + +def _handover(box: Box) -> str: + """The marker of a handover not yet settled (HANDOVER_NAME, beside the record).""" + return os.path.join(os.path.dirname(box.record), HANDOVER_NAME) + + +def write_secret(box: Box, secret: str) -> None: + """The new link secret a link answered with (the handover), in place of the box's: root's + alone (0600), whole or not at all (a temporary file beside it, synced, renamed, the + directory synced). The one write of a PROTECTED file any helper the run user reaches + makes, and only of what the license server answered over its own TLS to API: the run + user names nothing in it. Never through write_file, whose guard() refuses it.""" + directory = os.path.dirname(box.secret) + fd, tmp = tempfile.mkstemp(dir=directory, prefix=".license-link.secret.") + try: + os.fchmod(fd, 0o600) + if os.geteuid() == 0: + os.fchown(fd, box.secret_owner, 0) + with os.fdopen(fd, "wb") as f: + f.write((secret + "\n").encode("ascii")) + f.flush() + os.fsync(f.fileno()) + os.replace(tmp, box.secret) + except BaseException: + try: + os.unlink(tmp) + except OSError: + pass + raise + dfd = os.open(directory, os.O_RDONLY) + try: + os.fsync(dfd) + finally: + os.close(dfd) + + +def _remove(path: str) -> None: + guard(path) + try: + os.unlink(path) + except FileNotFoundError: + pass + + +def write_file(path: str, data: bytes, mode: int) -> None: + """Whole or not at all, as license_accept.write_file.""" + guard(path) + directory = os.path.dirname(path) + fd, tmp = tempfile.mkstemp(dir=directory, prefix="." + os.path.basename(path) + ".") + try: + os.fchmod(fd, mode) + with os.fdopen(fd, "wb") as f: + f.write(data) + f.flush() + os.fsync(f.fileno()) + os.replace(tmp, path) + except BaseException: + try: + os.unlink(tmp) + except OSError: + pass + raise + + +# ------------------------------------------------------------------ what there is to link + +def acceptance(box: Box) -> tuple[str, str] | None: + """(acceptance id, the license server it was recorded with) from the box's record: an + acceptance's, not the factory's maker record; None when there is none. The server is + whatever the record says: link() sends nothing unless it is API.""" + r = _read_json(box.record) + if not r or r.get("method") == "factory": + return None + aid, api = r.get("acceptance_id"), r.get("recorded_with") + if not (isinstance(aid, str) and ACCEPTANCE_ID.fullmatch(aid) and not aid.startswith("maker-")): + return None + return aid, api.rstrip("/") if isinstance(api, str) else "" + + +def appliance_key(box: Box) -> tuple[str, str] | None: + """(license_id, device) of the box's appliance key, read only; None for no key, or one + of another tier (a personal key's acceptance is the one it was issued under).""" + doc = _read_json(box.license_path) or {} + p = doc.get("payload") if isinstance(doc.get("payload"), dict) else {} + lid, device = p.get("license_id"), p.get("device") + if p.get("tier") != "appliance" or not (isinstance(lid, str) and LICENSE_ID.fullmatch(lid)) \ + or not (isinstance(device, str) and TPDEV2.fullmatch(device)): + return None + return lid, device + + +def link_secret(box: Box) -> str | None: + """The secret, from a regular file of root's that nobody else can read or write; None + when there is no file. Refused when it is there but not so (it may have been read), or + not one.""" + try: + fd = os.open(box.secret, os.O_RDONLY | os.O_NOFOLLOW) + except FileNotFoundError: + return None + except OSError: + raise Refused(f"{box.secret} cannot be read", FAILED) from None + with os.fdopen(fd, "rb") as f: + st = os.fstat(f.fileno()) + if not stat.S_ISREG(st.st_mode) or st.st_uid != box.secret_owner or st.st_mode & 0o077: + raise Refused(f"{box.secret} must be a file of root's, mode 0600", FAILED) + data = f.read(64).decode("ascii", "replace") + if not SECRET.fullmatch(data): + raise Refused(f"{box.secret} is not a link secret", FAILED) + return data.rstrip("\n") + + +def _fingerprint(aid: str, lid: str, secret: str) -> str: + """What a remembered refusal was for: the acceptance, the key and the secret's hash.""" + return hashlib.sha256(f"{aid}\0{lid}\0{secret}".encode()).hexdigest() + + +def status(box: Box) -> dict: + acc, key = acceptance(box), appliance_key(box) + if not key: + return {"state": NO_KEY} + done = _read_json(box.linked) or {} + if done.get("lost") is True and done.get("license_id") == key[0]: + return {"state": LOST, "why": done.get("why") or LOST} + if not acc: + return {"state": NO_ACCEPTANCE} + if not os.path.lexists(box.secret): + return {"state": NO_SECRET} + ok = done.get("acceptance_id") == acc[0] and done.get("license_id") == key[0] and done.get("linked") is True + return {"state": LINKED if ok else UNLINKED} + + +def _allowed(box: Box) -> None: + """The run user asks only while setup is unfinished (the module comment). Who asks is + sudo's SUDO_UID: none is root's own call; one that is not the brain's user is another + administrator's, who gave sudo a password. A brain's user that cannot be told counts as + the caller's: refused unless setup is unfinished.""" + if box.caller is None or box.caller == 0: + return + run = box.run_uid() + if (run is None or box.caller == run) and not box.gate.present(): + raise Refused("setup is finished on this box: its owner's acceptance is linked through it no more", + SETUP_DONE) + + +class _Busy(Exception): + """The lock was held past LOCK_SECS.""" + + +class _Locked: + """license_accept's lock (the module comment): an flock on root's file beside the record.""" + + def __init__(self, box: Box): + self.path, self.fd = guard(os.path.join(os.path.dirname(box.record), LOCK_NAME)), None + + def __enter__(self): + self.fd = os.open(self.path, os.O_RDWR | os.O_CREAT | os.O_NOFOLLOW, 0o600) + deadline = time.monotonic() + LOCK_SECS + while True: + try: + fcntl.flock(self.fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + return self + except BlockingIOError: + if time.monotonic() >= deadline: + os.close(self.fd) + raise _Busy from None + time.sleep(0.2) + + def __exit__(self, *exc): + os.close(self.fd) + + +def link(box: Box, log=lambda line: sys.stderr.write(f"license_link: {line}\n"), + recovery: str | None = None) -> dict: + """The recorded acceptance on the box's key. `recovery`: a one-time recovery code support + gave the box's verified owner (the module comment), presented in place of the secret; + only an administrator's or root's (it was typed at their prompt, main).""" + _allowed(box) + if recovery is not None: + if box.by_run_user(): + raise Refused("a recovery code is an administrator's: run it with sudo, as your login") + if not (isinstance(recovery, str) and SECRET.fullmatch(recovery) and not recovery.endswith("\n")): + raise Refused("that is not a recovery code: 43 letters, digits, - and _", FAILED) + if not os.path.isdir(os.path.dirname(box.record)): + return {"ok": True, "linked": False, "why": NO_ACCEPTANCE} + try: + with _Locked(box): + return _link(box, log, recovery) + except _Busy: + # Held by a send or a link that takes its time: the next call (the timer's) links. + return {"ok": False, "why": BUSY} + + +def _link(box: Box, log, recovery: str | None = None) -> dict: + acc, key = acceptance(box), appliance_key(box) + if not key: + return {"ok": True, "linked": False, "why": NO_KEY} + if not acc: + return {"ok": True, "linked": False, "why": NO_ACCEPTANCE} + if os.path.lexists(os.path.join(os.path.dirname(box.record), QUEUE_NAME)): + # A newer acceptance waits to be sent (one in place of this record's): never link + # the one it replaces. The timer sends it, then links it. + return {"ok": True, "linked": False, "why": QUEUED} + secret = recovery or link_secret(box) + if secret is None: + log(f"no link secret on this box ({box.secret}, written by install.sh since teaport#475): " + "nothing is linked; Teaspoon AI links the owner by hand") + return {"ok": True, "linked": False, "why": NO_SECRET} + (aid, api), (lid, device) = acc, key + if api != API: + log("the box's record names another license server than this helper's: nothing is sent") + return {"ok": False, "why": OTHER_SERVER} + done = _read_json(box.linked) or {} + if recovery is None and done.get("acceptance_id") == aid and done.get("license_id") == lid \ + and done.get("linked") is True: + box.gate.remove() # linked already: setup is finished, if a cut left the marker + _remove(_handover(box)) # and the handover with it: a crash cannot keep the timer on + return {"ok": True, "linked": True, "changed": False} + # The secret has linked before (a link answered 200 for this key): a 403 for it now is a + # lost link, not a refusal (the module comment). + worked = done.get("license_id") == lid and done.get("worked") is True + mark = _fingerprint(aid, lid, secret) + if box.caller is None and recovery is None and mark in (done.get("refused_for"), done.get("lost_for")): + return {"ok": False, "why": done.get("why") or (LOST if done.get("lost_for") == mark else REFUSED)} + changed = False + # Until the handover settles (confirmed, or refused for good), the timer runs whatever + # setup's state (teaport-license-owner.service's conditions): a confirm lost after setup, + # or after an administrator's re-link, is sent again, before the license server lets the + # previous secret go (link_secret_prev_expires). + write_file(_handover(box), (json.dumps({"license_id": lid, "at": int(box.now())}) + "\n").encode(), 0o600) + for _ in range(HANDOVERS): + status_code, data = box.net(f"{API}/license/link", + {"acceptance_id": aid, "license_id": lid, "device": device, "link_secret": secret}) + try: + answer = json.loads(data) if status_code else {} + except ValueError: + answer = {} + answer = answer if isinstance(answer, dict) else {} + if not (status_code == 200 and answer.get("linked") is True): + break + changed = changed or answer.get("changed") is not False + worked = True + new = answer.get("link_secret") + if new is None: + # No new secret: the handover is confirmed (the one sent is the current one), so + # the link is made and setup is finished. + write_file(box.linked, (json.dumps({"acceptance_id": aid, "license_id": lid, "linked": True, + "worked": True, "at": int(box.now())}) + "\n").encode(), 0o600) + box.gate.remove() + _remove(_handover(box)) + log("the owner's acceptance is linked to this box's license key" + + ("" if changed else " (it was already)")) + return {"ok": True, "linked": True, "changed": changed} + # The handover (the module comment): the new secret written, then shown at once. A + # write that fails leaves the old one, which the license server still takes. + if not (isinstance(new, str) and SECRET.fullmatch(new) and not new.endswith("\n")): + log("the license server answered a link secret that is not one: nothing written") + return {"ok": False, "why": FAILED} + write_secret(box, new) + secret = new + # The secret has linked: a later 403 for it is a lost link (said, not remembered as a + # refusal), whatever comes of the confirm. + write_file(box.linked, (json.dumps({"license_id": lid, "acceptance_id": aid, "worked": True, + "at": int(box.now())}) + "\n").encode(), 0o600) + else: + log("the license server's handover did not settle: the timer asks again") + return {"ok": False, "why": UNREACHABLE} + code = answer.get("error") if isinstance(answer.get("error"), str) and SERVER_CODE.fullmatch(answer["error"]) else None + if (status_code, code) in STALE: + # Accepted again from the setup step: the setup's record goes, the marker stays. An + # installer's receipt is the installer's to ask again for. + rec = _read_json(box.record) or {} + if rec.get("method") == "setup" and rec.get("acceptance_id") == aid: + _remove(box.record) + write_file(box.linked, (json.dumps({"license_id": lid, "worked": worked, + "at": int(box.now())}) + "\n").encode(), 0o600) + _remove(_handover(box)) + log(f"the license server no longer links this acceptance (HTTP {status_code}, {code}): " + "the owner accepts the license again at setup") + return {"ok": False, "why": ACCEPT_AGAIN} + if status_code == 403 and code == "bad_link_secret" and recovery is None: + # Another link was made with a copy of this box's secret (someone who had root on it), + # and rotated it away from the box; or, a secret that never linked (on its first try + # too), a cause the box cannot tell (CAUSE_UNKNOWN). Either way only support can put + # it right, so it is said as lost, not remembered as an ordinary refusal. + why = LOST if worked else CAUSE_UNKNOWN + write_file(box.linked, (json.dumps({"license_id": lid, "worked": worked, "lost": True, "lost_for": mark, + "why": why, "at": int(box.now())}) + "\n").encode(), 0o600) + _remove(_handover(box)) + log("license link lost: this box's secret no longer links its license key (someone linked it " + "with a copy of the secret): contact Teaspoon AI support" if worked else + "license link failed: this box's secret, which never linked, is refused for its license " + "key (cause unknown): contact Teaspoon AI support") + return {"ok": False, "why": why} + if status_code in (400, 403, 404, 409) and code != "conflict": + write_file(box.linked, (json.dumps({"license_id": lid, "worked": worked, "refused_for": mark, + "why": code or REFUSED, "status": status_code, + "at": int(box.now())}) + "\n").encode(), 0o600) + _remove(_handover(box)) + log(f"the license server refused the link (HTTP {status_code}{', ' + code if code else ''})") + return {"ok": False, "why": code or REFUSED} + log(f"the license server could not be asked now (HTTP {status_code or 'none'}): the timer asks again") + return {"ok": False, "why": UNREACHABLE} + + +def handle(box: Box, verb: str, req, recovery: str | None = None) -> dict: + if not isinstance(req, dict): + raise Refused("the request must be a JSON object") + if verb not in ("status", "link"): + raise Refused(f"unknown request {verb!r}") + if req: + # An acceptance id above all: this links the one on the box's record, never one given. + raise Refused(f"{verb} takes nothing: not {', '.join(sorted(map(str, req)))}") + return status(box) if verb == "status" else link(box, recovery=recovery) + + +def _prompt() -> str: + import getpass + return getpass.getpass("Recovery code from Teaspoon AI support: ") + + +def _reply(obj: dict) -> None: + sys.stdout.write(json.dumps(obj) + "\n") + sys.stdout.flush() + + +def main(argv: list[str] | None = None, box: Box | None = None) -> int: + argv = sys.argv[1:] if argv is None else argv + if box is None and os.geteuid() != 0: + _reply({"refused": "run as root, through the sudoers line", "why": REFUSED}) + return 2 + recovering = argv == ["link", "--recovery-code"] + if len(argv) != 1 and not recovering: + _reply({"refused": "usage: license_link.py (nothing on stdin, or {}) | link --recovery-code", + "why": REFUSED}) + return 2 + try: + data = sys.stdin.read(MAX_REQUEST + 1) if not sys.stdin.isatty() else "" + if len(data) > MAX_REQUEST: + raise Refused("the request is too long") + try: + req = json.loads(data) if data.strip() else {} + except ValueError: + raise Refused("the request is not JSON") from None + # The code is typed at a prompt on the terminal, never a command line (ps shows those) + # nor stdin a caller could have filled. + code = (box.recovery_prompt if box is not None else _prompt)() if recovering else None + reply = handle(box or Box.real(), argv[0], req, recovery=code.strip() if code else None) + except Refused as e: + _reply({"refused": str(e), "why": e.why}) + return 2 + except Exception as e: # noqa: BLE001 -- by its type alone: never the secret + sys.stderr.write(f"license_link: {type(e).__name__}\n") + _reply({"ok": False, "why": FAILED}) + return 1 + _reply(reply) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.mo index 834e8a1e..9de41f60 100644 Binary files a/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.po index e883e196..c3ed4f2e 100644 --- a/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/ar/LC_MESSAGES/teaport.po @@ -872,3 +872,90 @@ msgstr "تعذّر على Teaport إنشاء حساب تسجيل الدخول. msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "تعذّر على Teaport إنشاء حساب تسجيل الدخول. يمكنك الاتصال الآن وإنشاؤه لاحقًا من الإعدادات." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "اقرأ الترخيص" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "يأتي محرك الكلام في Teaport مع ترخيص Teaport Engine License. اقرأه ثم وافق عليه لإكمال إعداد Teaport." + +msgid "Your email address" +msgstr "عنوان بريدك الإلكتروني" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "تسجّل Teaspoon AI من وافق على الترخيص، مع هذا العنوان." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "قرأت ترخيص Teaport Engine License وأوافق عليه." + +msgid "I accept" +msgstr "أوافق" + +msgid "Recording your acceptance…" +msgstr "جارٍ تسجيل موافقتك…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "شكرًا. تم تسجيل موافقتك على الترخيص." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "شكرًا. سيسجّل Teaport موافقتك لدى Teaspoon AI بمجرد اتصاله بالإنترنت." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "ستقرأ ترخيص Teaport Engine License وتوافق عليه في الإعدادات بعد اتصال Teaport بالإنترنت." + +msgid "Tick the box to accept the license." +msgstr "ضع علامة في المربع للموافقة على الترخيص." + +msgid "Enter your email address." +msgstr "أدخل عنوان بريدك الإلكتروني." + +msgid "The license is already accepted on this Teaport." +msgstr "تمت الموافقة على الترخيص بالفعل على جهاز Teaport هذا." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "الموافقة على الترخيص غير متاحة على جهاز Teaport هذا." + +msgid "The license changed while you were reading it. Read it again." +msgstr "تغيّر الترخيص أثناء قراءتك له. اقرأه مرة أخرى." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "لا يستطيع Teaport عرض الترخيص الآن. حاول مرة أخرى بعد اتصاله بالإنترنت." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "لم تقبل Teaspoon AI هذه الموافقة. اقرأ الترخيص مرة أخرى ووافق عليه." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "تعذّر على Teaport تسجيل موافقتك. حاول مرة أخرى." + +msgid "The license is accepted as {email}." +msgstr "تمت الموافقة على الترخيص باسم {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "لست أنت؟ اقرأ الترخيص ووافق عليه مرة أخرى بعنوان بريدك الإلكتروني." + +msgid "Accept again" +msgstr "الموافقة مرة أخرى" + +msgid "Accept the license first, then create your login." +msgstr "وافق على الترخيص أولًا، ثم أنشئ حساب تسجيل الدخول." + +msgid "What will you use Teaport for?" +msgstr "لأي غرض ستستخدم Teaport؟" + +msgid "Personal use" +msgstr "استخدام شخصي" + +msgid "A business" +msgstr "نشاط تجاري" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "اختر ما إذا كان Teaport للاستخدام الشخصي أو لنشاط تجاري." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "يسجّل Teaport موافقة الآن. حاول مرة أخرى بعد قليل." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "فُقد ربط ترخيص جهاز Teaport هذا: رُبط مفتاح ترخيصه بنسخة من سرّ Teaport. تواصل مع دعم Teaspoon AI لاستعادته." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "فشل ربط ترخيص جهاز Teaport هذا. تواصل مع دعم Teaspoon AI." diff --git a/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.mo index 36a60dd2..9a742ed5 100644 Binary files a/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.po index d3fc6fed..4ea62a6c 100644 --- a/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/de/LC_MESSAGES/teaport.po @@ -861,3 +861,90 @@ msgstr "Teaport konnte deine Anmeldung nicht erstellen. Versuch es noch einmal." msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport konnte deine Anmeldung nicht erstellen. Du kannst dich jetzt verbinden und die Anmeldung später in den Einstellungen erstellen." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Lies die Lizenz" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Die Sprach-Engine von Teaport kommt mit der Teaport Engine License. Lies sie und akzeptiere sie, um die Einrichtung von Teaport abzuschließen." + +msgid "Your email address" +msgstr "Deine E-Mail-Adresse" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI speichert mit dieser Adresse, wer die Lizenz akzeptiert hat." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Ich habe die Teaport Engine License gelesen und akzeptiere sie." + +msgid "I accept" +msgstr "Ich akzeptiere" + +msgid "Recording your acceptance…" +msgstr "Deine Zustimmung wird gespeichert…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Danke. Deine Zustimmung zur Lizenz ist gespeichert." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Danke. Teaport meldet deine Zustimmung an Teaspoon AI, sobald es online ist." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Du liest und akzeptierst die Teaport Engine License in den Einstellungen, sobald Teaport online ist." + +msgid "Tick the box to accept the license." +msgstr "Setze das Häkchen, um die Lizenz zu akzeptieren." + +msgid "Enter your email address." +msgstr "Gib deine E-Mail-Adresse ein." + +msgid "The license is already accepted on this Teaport." +msgstr "Die Lizenz ist auf diesem Teaport schon akzeptiert." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "Die Lizenz kann auf diesem Teaport nicht akzeptiert werden." + +msgid "The license changed while you were reading it. Read it again." +msgstr "Die Lizenz hat sich geändert, während du sie gelesen hast. Lies sie noch einmal." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport kann die Lizenz gerade nicht anzeigen. Versuch es noch einmal, sobald es online ist." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI hat diese Zustimmung nicht angenommen. Lies die Lizenz noch einmal und akzeptiere sie." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport konnte deine Zustimmung nicht speichern. Versuch es noch einmal." + +msgid "The license is accepted as {email}." +msgstr "Die Lizenz ist akzeptiert als {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "Nicht du? Lies die Lizenz und akzeptiere sie noch einmal mit deiner eigenen E-Mail-Adresse." + +msgid "Accept again" +msgstr "Erneut akzeptieren" + +msgid "Accept the license first, then create your login." +msgstr "Akzeptiere zuerst die Lizenz, dann erstelle deine Anmeldung." + +msgid "What will you use Teaport for?" +msgstr "Wofür nutzt du Teaport?" + +msgid "Personal use" +msgstr "Private Nutzung" + +msgid "A business" +msgstr "Ein Unternehmen" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Wähle, ob Teaport privat oder für ein Unternehmen genutzt wird." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport speichert gerade eine Zustimmung. Versuch es gleich noch einmal." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "Die Lizenzverknüpfung dieses Teaport ging verloren: Sein Lizenzschlüssel wurde mit einer Kopie des Geheimnisses dieses Teaport verknüpft. Wende dich an den Support von Teaspoon AI, um sie zurückzubekommen." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "Die Lizenzverknüpfung dieses Teaport ist fehlgeschlagen. Wende dich an den Support von Teaspoon AI." diff --git a/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.mo index 43f119eb..b55cabcc 100644 Binary files a/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.po index 25e1b40a..f34b7c5a 100644 --- a/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/es/LC_MESSAGES/teaport.po @@ -863,3 +863,90 @@ msgstr "Teaport no pudo crear tu inicio de sesión. Inténtalo de nuevo." msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport no pudo crear tu inicio de sesión. Puedes conectarte ahora y crearlo más tarde en Ajustes." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Lee la licencia" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "El motor de voz de Teaport viene con la Teaport Engine License. Léela y acéptala para terminar de configurar Teaport." + +msgid "Your email address" +msgstr "Tu correo electrónico" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI registra quién aceptó la licencia, con esta dirección." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "He leído la Teaport Engine License y la acepto." + +msgid "I accept" +msgstr "Acepto" + +msgid "Recording your acceptance…" +msgstr "Registrando tu aceptación…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Gracias. Tu aceptación de la licencia está registrada." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Gracias. Teaport registrará tu aceptación con Teaspoon AI cuando esté en línea." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Leerás y aceptarás la Teaport Engine License en Ajustes cuando Teaport esté en línea." + +msgid "Tick the box to accept the license." +msgstr "Marca la casilla para aceptar la licencia." + +msgid "Enter your email address." +msgstr "Escribe tu correo electrónico." + +msgid "The license is already accepted on this Teaport." +msgstr "La licencia ya está aceptada en este Teaport." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "Aceptar la licencia no está disponible en este Teaport." + +msgid "The license changed while you were reading it. Read it again." +msgstr "La licencia cambió mientras la leías. Vuelve a leerla." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport no puede mostrar la licencia ahora. Inténtalo de nuevo cuando esté en línea." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI no aceptó este registro. Vuelve a leer la licencia y acéptala." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport no pudo registrar tu aceptación. Inténtalo de nuevo." + +msgid "The license is accepted as {email}." +msgstr "La licencia está aceptada como {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "¿No eres tú? Lee la licencia y vuelve a aceptarla con tu propio correo electrónico." + +msgid "Accept again" +msgstr "Aceptar de nuevo" + +msgid "Accept the license first, then create your login." +msgstr "Acepta primero la licencia y después crea tu inicio de sesión." + +msgid "What will you use Teaport for?" +msgstr "¿Para qué usarás Teaport?" + +msgid "Personal use" +msgstr "Uso personal" + +msgid "A business" +msgstr "Una empresa" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Elige si Teaport es para uso personal o para una empresa." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport está registrando una aceptación. Inténtalo de nuevo en un momento." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "Se perdió el vínculo de licencia de este Teaport: su clave de licencia se vinculó con una copia del secreto del Teaport. Contacta con el soporte de Teaspoon AI para recuperarlo." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "Falló el vínculo de licencia de este Teaport. Contacta con el soporte de Teaspoon AI." diff --git a/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.mo index 43302b29..71c8c77e 100644 Binary files a/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.po index 425c130c..0ed4cb44 100644 --- a/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/fr/LC_MESSAGES/teaport.po @@ -866,3 +866,90 @@ msgstr "Teaport n'a pas pu créer votre identifiant. Réessayez." msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport n'a pas pu créer votre identifiant. Vous pouvez vous connecter maintenant et le créer plus tard dans les Réglages." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Lisez la licence" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Le moteur vocal de Teaport est fourni avec la Teaport Engine License. Lisez-la, puis acceptez-la pour terminer la configuration de Teaport." + +msgid "Your email address" +msgstr "Votre adresse e-mail" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI enregistre, avec cette adresse, qui a accepté la licence." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "J'ai lu la Teaport Engine License et je l'accepte." + +msgid "I accept" +msgstr "J'accepte" + +msgid "Recording your acceptance…" +msgstr "Enregistrement de votre acceptation…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Merci. Votre acceptation de la licence est enregistrée." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Merci. Teaport enregistre votre acceptation auprès de Teaspoon AI dès qu'il est en ligne." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Vous lirez et accepterez la Teaport Engine License dans les Réglages une fois Teaport en ligne." + +msgid "Tick the box to accept the license." +msgstr "Cochez la case pour accepter la licence." + +msgid "Enter your email address." +msgstr "Saisissez votre adresse e-mail." + +msgid "The license is already accepted on this Teaport." +msgstr "La licence est déjà acceptée sur ce Teaport." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "L'acceptation de la licence n'est pas disponible sur ce Teaport." + +msgid "The license changed while you were reading it. Read it again." +msgstr "La licence a changé pendant que vous la lisiez. Relisez-la." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport ne peut pas afficher la licence pour le moment. Réessayez une fois qu'il sera en ligne." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI n'a pas pris en compte cette acceptation. Relisez la licence et acceptez-la." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport n'a pas pu enregistrer votre acceptation. Réessayez." + +msgid "The license is accepted as {email}." +msgstr "La licence est acceptée au nom de {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "Ce n'est pas vous ? Lisez la licence et acceptez-la à nouveau avec votre propre adresse e-mail." + +msgid "Accept again" +msgstr "Accepter à nouveau" + +msgid "Accept the license first, then create your login." +msgstr "Acceptez d'abord la licence, puis créez votre identifiant." + +msgid "What will you use Teaport for?" +msgstr "À quoi servira Teaport ?" + +msgid "Personal use" +msgstr "Usage personnel" + +msgid "A business" +msgstr "Une entreprise" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Choisissez si Teaport est pour un usage personnel ou pour une entreprise." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport enregistre déjà une acceptation. Réessayez dans un instant." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "Le lien de licence de ce Teaport a été perdu : sa clé de licence a été liée avec une copie du secret du Teaport. Contactez le support de Teaspoon AI pour le récupérer." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "Le lien de licence de ce Teaport a échoué. Contactez le support de Teaspoon AI." diff --git a/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.mo index 759fa9b2..c4e5d263 100644 Binary files a/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.po index 71d13faa..9a969496 100644 --- a/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/hi/LC_MESSAGES/teaport.po @@ -966,3 +966,90 @@ msgstr "Teaport आपका लॉगिन नहीं बना सका। msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport आपका लॉगिन नहीं बना सका। आप अभी कनेक्ट कर सकते हैं और बाद में सेटिंग्स में अपना लॉगिन बना सकते हैं।" +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "लाइसेंस पढ़ें" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Teaport का स्पीच इंजन Teaport Engine License के साथ आता है। Teaport का सेटअप पूरा करने के लिए इसे पढ़ें, फिर स्वीकार करें।" + +msgid "Your email address" +msgstr "आपका ईमेल पता" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI इस पते के साथ रिकॉर्ड करता है कि लाइसेंस किसने स्वीकार किया।" + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Teaport Engine License मैंने पढ़ लिया है और यह मुझे स्वीकार है।" + +msgid "I accept" +msgstr "मुझे स्वीकार है" + +msgid "Recording your acceptance…" +msgstr "आपकी स्वीकृति दर्ज की जा रही है…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "धन्यवाद। लाइसेंस के लिए आपकी स्वीकृति दर्ज हो गई है।" + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "धन्यवाद। ऑनलाइन होते ही Teaport आपकी स्वीकृति Teaspoon AI के पास दर्ज कर देगा।" + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Teaport के ऑनलाइन होने पर आप सेटिंग्स में Teaport Engine License पढ़कर स्वीकार करेंगे।" + +msgid "Tick the box to accept the license." +msgstr "लाइसेंस स्वीकार करने के लिए बॉक्स पर टिक करें।" + +msgid "Enter your email address." +msgstr "अपना ईमेल पता डालें।" + +msgid "The license is already accepted on this Teaport." +msgstr "इस Teaport पर लाइसेंस पहले ही स्वीकार किया जा चुका है।" + +msgid "Accepting the license isn't available on this Teaport." +msgstr "इस Teaport पर लाइसेंस स्वीकार करना उपलब्ध नहीं है।" + +msgid "The license changed while you were reading it. Read it again." +msgstr "आपके पढ़ते समय लाइसेंस बदल गया। इसे फिर से पढ़ें।" + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport अभी लाइसेंस नहीं दिखा सकता। ऑनलाइन होने पर फिर से कोशिश करें।" + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI ने यह स्वीकृति नहीं ली। लाइसेंस फिर से पढ़ें और स्वीकार करें।" + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport आपकी स्वीकृति दर्ज नहीं कर सका। फिर से कोशिश करें।" + +msgid "The license is accepted as {email}." +msgstr "लाइसेंस {email} के नाम से स्वीकार किया गया है।" + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "आप नहीं हैं? लाइसेंस पढ़ें और अपने ईमेल पते से इसे फिर से स्वीकार करें।" + +msgid "Accept again" +msgstr "फिर से स्वीकार करें" + +msgid "Accept the license first, then create your login." +msgstr "पहले लाइसेंस स्वीकार करें, फिर अपना लॉगिन बनाएं।" + +msgid "What will you use Teaport for?" +msgstr "आप Teaport का इस्तेमाल किसके लिए करेंगे?" + +msgid "Personal use" +msgstr "निजी इस्तेमाल" + +msgid "A business" +msgstr "कोई व्यवसाय" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "चुनें कि Teaport निजी इस्तेमाल के लिए है या किसी व्यवसाय के लिए।" + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport अभी एक स्वीकृति दर्ज कर रहा है। थोड़ी देर में फिर से कोशिश करें।" + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "इस Teaport का लाइसेंस लिंक खो गया है: इसकी लाइसेंस कुंजी Teaport के सीक्रेट की एक कॉपी से लिंक कर दी गई। इसे वापस पाने के लिए Teaspoon AI सपोर्ट से संपर्क करें।" + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "इस Teaport का लाइसेंस लिंक विफल रहा। Teaspoon AI सपोर्ट से संपर्क करें।" diff --git a/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.mo index cb30eb1e..7f41ceb1 100644 Binary files a/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.po index 1b7f8964..21948751 100644 --- a/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/it/LC_MESSAGES/teaport.po @@ -871,3 +871,90 @@ msgstr "Teaport non è riuscito a creare il tuo accesso. Riprova." msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport non è riuscito a creare il tuo accesso. Puoi connetterti ora e crearlo più tardi nelle Impostazioni." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Leggi la licenza" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Il motore vocale di Teaport è fornito con la Teaport Engine License. Leggila, poi accettala per finire di configurare Teaport." + +msgid "Your email address" +msgstr "Il tuo indirizzo email" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI registra chi ha accettato la licenza, con questo indirizzo." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Ho letto la Teaport Engine License e la accetto." + +msgid "I accept" +msgstr "Accetto" + +msgid "Recording your acceptance…" +msgstr "Registrazione della tua accettazione…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Grazie. La tua accettazione della licenza è registrata." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Grazie. Teaport registra la tua accettazione presso Teaspoon AI appena è online." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Leggerai e accetterai la Teaport Engine License nelle Impostazioni quando Teaport sarà online." + +msgid "Tick the box to accept the license." +msgstr "Spunta la casella per accettare la licenza." + +msgid "Enter your email address." +msgstr "Inserisci il tuo indirizzo email." + +msgid "The license is already accepted on this Teaport." +msgstr "La licenza è già accettata su questo Teaport." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "Accettare la licenza non è disponibile su questo Teaport." + +msgid "The license changed while you were reading it. Read it again." +msgstr "La licenza è cambiata mentre la leggevi. Leggila di nuovo." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport non può mostrare la licenza adesso. Riprova quando è online." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI non ha preso questa accettazione. Leggi di nuovo la licenza e accettala." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport non è riuscito a registrare la tua accettazione. Riprova." + +msgid "The license is accepted as {email}." +msgstr "La licenza è accettata come {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "Non sei tu? Leggi la licenza e accettala di nuovo con il tuo indirizzo email." + +msgid "Accept again" +msgstr "Accetta di nuovo" + +msgid "Accept the license first, then create your login." +msgstr "Accetta prima la licenza, poi crea il tuo accesso." + +msgid "What will you use Teaport for?" +msgstr "Per cosa userai Teaport?" + +msgid "Personal use" +msgstr "Uso personale" + +msgid "A business" +msgstr "Un'azienda" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Scegli se Teaport è per uso personale o per un'azienda." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport sta già registrando un'accettazione. Riprova tra un momento." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "Il collegamento della licenza di questo Teaport è andato perso: la sua chiave di licenza è stata collegata con una copia del segreto del Teaport. Contatta il supporto di Teaspoon AI per recuperarlo." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "Il collegamento della licenza di questo Teaport non è riuscito. Contatta il supporto di Teaspoon AI." diff --git a/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.mo index 181967b5..26964fbd 100644 Binary files a/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.po index 2c4f0db3..dd53bfc2 100644 --- a/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/ja/LC_MESSAGES/teaport.po @@ -966,3 +966,90 @@ msgstr "Teaport はログインを作成できませんでした。もう一度 msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport はログインを作成できませんでした。今は接続だけ行い、あとで設定からログインを作成することもできます。" +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "ライセンスを読む" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Teaport の音声エンジンには Teaport Engine License が付いています。お読みのうえ同意して、Teaport のセットアップを完了してください。" + +msgid "Your email address" +msgstr "メールアドレス" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI は、ライセンスに同意した人をこのアドレスで記録します。" + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Teaport Engine License を読み、同意します。" + +msgid "I accept" +msgstr "同意する" + +msgid "Recording your acceptance…" +msgstr "同意を記録しています…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "ありがとうございます。ライセンスへの同意を記録しました。" + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "ありがとうございます。Teaport がオンラインになりしだい、同意を Teaspoon AI に記録します。" + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Teaport がオンラインになったら、設定で Teaport Engine License を読んで同意してください。" + +msgid "Tick the box to accept the license." +msgstr "ライセンスに同意するには、チェックボックスをオンにしてください。" + +msgid "Enter your email address." +msgstr "メールアドレスを入力してください。" + +msgid "The license is already accepted on this Teaport." +msgstr "この Teaport ではすでにライセンスに同意済みです。" + +msgid "Accepting the license isn't available on this Teaport." +msgstr "この Teaport ではライセンスへの同意はできません。" + +msgid "The license changed while you were reading it. Read it again." +msgstr "お読みのあいだにライセンスが変わりました。もう一度お読みください。" + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport は今ライセンスを表示できません。オンラインになってからもう一度お試しください。" + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI はこの同意を受け付けませんでした。ライセンスをもう一度読んで同意してください。" + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport は同意を記録できませんでした。もう一度お試しください。" + +msgid "The license is accepted as {email}." +msgstr "ライセンスは {email} として同意済みです。" + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "ご本人ではありませんか?ライセンスを読み、ご自分のメールアドレスでもう一度同意してください。" + +msgid "Accept again" +msgstr "もう一度同意する" + +msgid "Accept the license first, then create your login." +msgstr "先にライセンスに同意してから、ログインを作成してください。" + +msgid "What will you use Teaport for?" +msgstr "Teaport を何に使いますか?" + +msgid "Personal use" +msgstr "個人での利用" + +msgid "A business" +msgstr "事業での利用" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Teaport を個人で使うか、事業で使うかを選んでください。" + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport は同意を記録中です。少ししてからもう一度お試しください。" + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "この Teaport のライセンスのリンクが失われました。Teaport の秘密情報のコピーでライセンスキーがリンクされました。取り戻すには Teaspoon AI のサポートにお問い合わせください。" + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "この Teaport のライセンスのリンクに失敗しました。Teaspoon AI のサポートにお問い合わせください。" diff --git a/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.mo index 42e08a44..b36cd7e5 100644 Binary files a/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.po index 587e2283..8d97ff0b 100644 --- a/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/ko/LC_MESSAGES/teaport.po @@ -970,3 +970,90 @@ msgstr "Teaport가 로그인을 만들지 못했어요. 다시 시도해 주세 msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport가 로그인을 만들지 못했어요. 지금 연결하고 나중에 설정에서 로그인을 만들 수 있어요." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "라이선스 읽기" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Teaport의 음성 엔진에는 Teaport Engine License가 함께 제공돼요. 읽고 동의하면 Teaport 설정이 끝나요." + +msgid "Your email address" +msgstr "이메일 주소" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI는 이 주소로 라이선스에 동의한 사람을 기록해요." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Teaport Engine License를 읽었고 이에 동의합니다." + +msgid "I accept" +msgstr "동의합니다" + +msgid "Recording your acceptance…" +msgstr "동의를 기록하고 있어요…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "감사합니다. 라이선스 동의가 기록됐어요." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "감사합니다. Teaport가 온라인이 되면 동의를 Teaspoon AI에 기록해요." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Teaport가 온라인이 되면 설정에서 Teaport Engine License를 읽고 동의하게 돼요." + +msgid "Tick the box to accept the license." +msgstr "라이선스에 동의하려면 상자에 체크해 주세요." + +msgid "Enter your email address." +msgstr "이메일 주소를 입력해 주세요." + +msgid "The license is already accepted on this Teaport." +msgstr "이 Teaport에서는 이미 라이선스에 동의했어요." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "이 Teaport에서는 라이선스에 동의할 수 없어요." + +msgid "The license changed while you were reading it. Read it again." +msgstr "읽는 동안 라이선스가 바뀌었어요. 다시 읽어 주세요." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport가 지금은 라이선스를 보여 줄 수 없어요. 온라인이 된 뒤 다시 시도해 주세요." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI가 이 동의를 받지 않았어요. 라이선스를 다시 읽고 동의해 주세요." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport가 동의를 기록하지 못했어요. 다시 시도해 주세요." + +msgid "The license is accepted as {email}." +msgstr "{email}(으)로 라이선스에 동의했어요." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "본인이 아닌가요? 라이선스를 읽고 본인 이메일 주소로 다시 동의해 주세요." + +msgid "Accept again" +msgstr "다시 동의하기" + +msgid "Accept the license first, then create your login." +msgstr "먼저 라이선스에 동의한 다음 로그인을 만드세요." + +msgid "What will you use Teaport for?" +msgstr "Teaport를 어디에 사용하시나요?" + +msgid "Personal use" +msgstr "개인 용도" + +msgid "A business" +msgstr "사업 용도" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Teaport를 개인 용도로 쓸지 사업 용도로 쓸지 선택해 주세요." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport가 동의를 기록하는 중이에요. 잠시 후 다시 시도해 주세요." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "이 Teaport의 라이선스 연결이 끊겼어요. Teaport 비밀 정보의 복사본으로 라이선스 키가 연결됐어요. 되찾으려면 Teaspoon AI 지원팀에 문의해 주세요." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "이 Teaport의 라이선스 연결에 실패했어요. Teaspoon AI 지원팀에 문의해 주세요." diff --git a/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.mo index 8cbd8010..d9b2ff71 100644 Binary files a/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.po index c540770b..ac21fbf2 100644 --- a/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/nl/LC_MESSAGES/teaport.po @@ -861,3 +861,90 @@ msgstr "Teaport kon je login niet aanmaken. Probeer het opnieuw." msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport kon je login niet aanmaken. Je kunt nu verbinding maken en je login later aanmaken in Instellingen." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Lees de licentie" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "De spraakengine van Teaport wordt geleverd met de Teaport Engine License. Lees die en accepteer die om het instellen van Teaport af te ronden." + +msgid "Your email address" +msgstr "Je e-mailadres" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI legt met dit adres vast wie de licentie heeft geaccepteerd." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Ik heb de Teaport Engine License gelezen en ga ermee akkoord." + +msgid "I accept" +msgstr "Ik ga akkoord" + +msgid "Recording your acceptance…" +msgstr "Je akkoord wordt vastgelegd…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Bedankt. Je akkoord met de licentie is vastgelegd." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Bedankt. Teaport legt je akkoord bij Teaspoon AI vast zodra Teaport online is." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Je leest en accepteert de Teaport Engine License in Instellingen zodra Teaport online is." + +msgid "Tick the box to accept the license." +msgstr "Vink het vakje aan om de licentie te accepteren." + +msgid "Enter your email address." +msgstr "Vul je e-mailadres in." + +msgid "The license is already accepted on this Teaport." +msgstr "De licentie is op deze Teaport al geaccepteerd." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "De licentie accepteren is op deze Teaport niet beschikbaar." + +msgid "The license changed while you were reading it. Read it again." +msgstr "De licentie is veranderd terwijl je die las. Lees die opnieuw." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport kan de licentie nu niet tonen. Probeer het opnieuw zodra Teaport online is." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI heeft dit akkoord niet aangenomen. Lees de licentie opnieuw en accepteer die." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport kon je akkoord niet vastleggen. Probeer het opnieuw." + +msgid "The license is accepted as {email}." +msgstr "De licentie is geaccepteerd als {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "Ben jij dit niet? Lees de licentie en accepteer die opnieuw met je eigen e-mailadres." + +msgid "Accept again" +msgstr "Opnieuw accepteren" + +msgid "Accept the license first, then create your login." +msgstr "Accepteer eerst de licentie en maak daarna je login aan." + +msgid "What will you use Teaport for?" +msgstr "Waarvoor ga je Teaport gebruiken?" + +msgid "Personal use" +msgstr "Persoonlijk gebruik" + +msgid "A business" +msgstr "Een bedrijf" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Kies of Teaport voor persoonlijk gebruik of voor een bedrijf is." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport legt al een akkoord vast. Probeer het zo opnieuw." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "De licentiekoppeling van deze Teaport is kwijt: de licentiesleutel is gekoppeld met een kopie van het geheim van de Teaport. Neem contact op met de support van Teaspoon AI om hem terug te krijgen." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "De licentiekoppeling van deze Teaport is mislukt. Neem contact op met de support van Teaspoon AI." diff --git a/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.mo index 93bcd196..0a666e05 100644 Binary files a/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.po index 5030ab17..7178dd5b 100644 --- a/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/pt_BR/LC_MESSAGES/teaport.po @@ -861,3 +861,90 @@ msgstr "O Teaport não conseguiu criar seu login. Tente de novo." msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "O Teaport não conseguiu criar seu login. Você pode se conectar agora e criá-lo depois, em Configurações." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Leia a licença" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "O mecanismo de voz do Teaport vem com a Teaport Engine License. Leia e aceite a licença para terminar de configurar o Teaport." + +msgid "Your email address" +msgstr "Seu endereço de e-mail" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "A Teaspoon AI registra quem aceitou a licença, com este endereço." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Li a Teaport Engine License e a aceito." + +msgid "I accept" +msgstr "Aceito" + +msgid "Recording your acceptance…" +msgstr "Registrando sua aceitação…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Obrigado. Sua aceitação da licença foi registrada." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Obrigado. O Teaport registra sua aceitação com a Teaspoon AI assim que estiver online." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Você vai ler e aceitar a Teaport Engine License em Configurações assim que o Teaport estiver online." + +msgid "Tick the box to accept the license." +msgstr "Marque a caixa para aceitar a licença." + +msgid "Enter your email address." +msgstr "Digite seu endereço de e-mail." + +msgid "The license is already accepted on this Teaport." +msgstr "A licença já foi aceita neste Teaport." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "Aceitar a licença não está disponível neste Teaport." + +msgid "The license changed while you were reading it. Read it again." +msgstr "A licença mudou enquanto você a lia. Leia de novo." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "O Teaport não consegue mostrar a licença agora. Tente de novo quando ele estiver online." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "A Teaspoon AI não aceitou este registro. Leia a licença de novo e aceite-a." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "O Teaport não conseguiu registrar sua aceitação. Tente de novo." + +msgid "The license is accepted as {email}." +msgstr "A licença foi aceita como {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "Não é você? Leia a licença e aceite-a de novo com o seu próprio e-mail." + +msgid "Accept again" +msgstr "Aceitar de novo" + +msgid "Accept the license first, then create your login." +msgstr "Aceite a licença primeiro e depois crie seu login." + +msgid "What will you use Teaport for?" +msgstr "Para que você vai usar o Teaport?" + +msgid "Personal use" +msgstr "Uso pessoal" + +msgid "A business" +msgstr "Uma empresa" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Escolha se o Teaport é para uso pessoal ou para uma empresa." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "O Teaport está registrando uma aceitação. Tente de novo daqui a pouco." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "O vínculo de licença deste Teaport foi perdido: a chave de licença foi vinculada com uma cópia do segredo do Teaport. Fale com o suporte da Teaspoon AI para recuperá-lo." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "O vínculo de licença deste Teaport falhou. Fale com o suporte da Teaspoon AI." diff --git a/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.mo index 79bfa14a..73d5d037 100644 Binary files a/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.po index ee546109..eaf475cc 100644 --- a/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/ru/LC_MESSAGES/teaport.po @@ -869,3 +869,90 @@ msgstr "Teaport не удалось создать учётную запись. msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport не удалось создать учётную запись. Можно подключиться сейчас и создать её позже в Настройках." +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "Прочитайте лицензию" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Речевой движок Teaport поставляется с лицензией Teaport Engine License. Прочитайте её и примите, чтобы завершить настройку Teaport." + +msgid "Your email address" +msgstr "Ваш адрес электронной почты" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI записывает, кто принял лицензию, вместе с этим адресом." + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "Лицензия Teaport Engine License прочитана, и я её принимаю." + +msgid "I accept" +msgstr "Я принимаю" + +msgid "Recording your acceptance…" +msgstr "Записываем ваше согласие…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "Спасибо. Ваше согласие с лицензией записано." + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "Спасибо. Teaport передаст ваше согласие в Teaspoon AI, как только будет в сети." + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Вы прочитаете и примете Teaport Engine License в Настройках, когда Teaport будет в сети." + +msgid "Tick the box to accept the license." +msgstr "Отметьте флажок, чтобы принять лицензию." + +msgid "Enter your email address." +msgstr "Введите адрес электронной почты." + +msgid "The license is already accepted on this Teaport." +msgstr "Лицензия на этом Teaport уже принята." + +msgid "Accepting the license isn't available on this Teaport." +msgstr "Принять лицензию на этом Teaport нельзя." + +msgid "The license changed while you were reading it. Read it again." +msgstr "Лицензия изменилась, пока вы её читали. Прочитайте её ещё раз." + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport сейчас не может показать лицензию. Попробуйте ещё раз, когда он будет в сети." + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI не приняла это согласие. Прочитайте лицензию ещё раз и примите её." + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport не удалось записать ваше согласие. Попробуйте ещё раз." + +msgid "The license is accepted as {email}." +msgstr "Лицензия принята как {email}." + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "Это не вы? Прочитайте лицензию и примите её ещё раз со своим адресом электронной почты." + +msgid "Accept again" +msgstr "Принять ещё раз" + +msgid "Accept the license first, then create your login." +msgstr "Сначала примите лицензию, затем создайте учётную запись." + +msgid "What will you use Teaport for?" +msgstr "Для чего вы будете использовать Teaport?" + +msgid "Personal use" +msgstr "Личное использование" + +msgid "A business" +msgstr "Компания" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "Выберите, для личного использования Teaport или для компании." + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport уже записывает согласие. Попробуйте ещё раз через минуту." + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "Привязка лицензии этого Teaport потеряна: его лицензионный ключ привязали с копией секрета Teaport. Обратитесь в поддержку Teaspoon AI, чтобы вернуть её." + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "Не удалось привязать лицензию этого Teaport. Обратитесь в поддержку Teaspoon AI." diff --git a/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.mo b/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.mo index 71916713..d7733d6b 100644 Binary files a/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.mo and b/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.mo differ diff --git a/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.po b/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.po index bbbd40ec..95d7e4b0 100644 --- a/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.po +++ b/brain/teaport_brain/locale/zh/LC_MESSAGES/teaport.po @@ -861,3 +861,90 @@ msgstr "Teaport 没能创建你的登录账户。请再试一次。" msgid "Teaport couldn't create your login. You can connect now and create it later in Settings." msgstr "Teaport 没能创建你的登录账户。你可以先连接,以后再到设置中创建。" +# The owner's license (#465): the setup page's step and the Settings card (owner_license.py). +msgid "Read the license" +msgstr "阅读许可协议" + +msgid "Teaport's speech engine comes with the Teaport Engine License. Read it, then accept it to finish setting up Teaport." +msgstr "Teaport 的语音引擎附带 Teaport Engine License。请阅读并接受它,以完成 Teaport 的设置。" + +msgid "Your email address" +msgstr "你的电子邮件地址" + +msgid "Teaspoon AI records who accepted the license, with this address." +msgstr "Teaspoon AI 会用这个地址记录是谁接受了许可协议。" + +msgid "I have read the Teaport Engine License and I accept it." +msgstr "我已阅读并接受 Teaport Engine License。" + +msgid "I accept" +msgstr "我接受" + +msgid "Recording your acceptance…" +msgstr "正在记录你的接受…" + +msgid "Thank you. Your acceptance of the license is recorded." +msgstr "谢谢。你对许可协议的接受已记录。" + +msgid "Thank you. Teaport records your acceptance with Teaspoon AI once it's online." +msgstr "谢谢。Teaport 联网后会将你的接受记录到 Teaspoon AI。" + +msgid "You'll read and accept the Teaport Engine License in Settings once Teaport is online." +msgstr "Teaport 联网后,你可以在设置中阅读并接受 Teaport Engine License。" + +msgid "Tick the box to accept the license." +msgstr "勾选方框以接受许可协议。" + +msgid "Enter your email address." +msgstr "请输入你的电子邮件地址。" + +msgid "The license is already accepted on this Teaport." +msgstr "这台 Teaport 上已接受过许可协议。" + +msgid "Accepting the license isn't available on this Teaport." +msgstr "这台 Teaport 上无法接受许可协议。" + +msgid "The license changed while you were reading it. Read it again." +msgstr "你阅读期间许可协议有了变化。请重新阅读。" + +msgid "Teaport can't show the license right now. Try again once it's online." +msgstr "Teaport 现在无法显示许可协议。请在联网后重试。" + +msgid "Teaspoon AI didn't take this acceptance. Read the license again and accept it." +msgstr "Teaspoon AI 没有接收这次接受。请重新阅读许可协议并接受。" + +msgid "Teaport couldn't record your acceptance. Try again." +msgstr "Teaport 没能记录你的接受。请再试一次。" + +msgid "The license is accepted as {email}." +msgstr "许可协议已由 {email} 接受。" + +msgid "Not you? Read the license and accept it again with your own email address." +msgstr "不是你?请阅读许可协议,并用你自己的电子邮件地址重新接受。" + +msgid "Accept again" +msgstr "重新接受" + +msgid "Accept the license first, then create your login." +msgstr "请先接受许可协议,再创建登录账户。" + +msgid "What will you use Teaport for?" +msgstr "你会把 Teaport 用于什么?" + +msgid "Personal use" +msgstr "个人使用" + +msgid "A business" +msgstr "企业使用" + +msgid "Choose whether Teaport is for personal use or for a business." +msgstr "请选择 Teaport 是个人使用还是企业使用。" + +msgid "Teaport is busy recording an acceptance. Try again in a moment." +msgstr "Teaport 正在记录一项接受。请稍后再试。" + +msgid "This Teaport's license link was lost: its license key was linked with a copy of the Teaport's secret. Contact Teaspoon AI support to get it back." +msgstr "这台 Teaport 的许可链接已丢失:有人用 Teaport 密钥的副本链接了它的许可证密钥。请联系 Teaspoon AI 支持以找回。" + +msgid "This Teaport's license link failed. Contact Teaspoon AI support." +msgstr "这台 Teaport 的许可链接失败了。请联系 Teaspoon AI 支持。" diff --git a/brain/teaport_brain/login_apply.py b/brain/teaport_brain/login_apply.py index de0989f0..a0f48bab 100644 --- a/brain/teaport_brain/login_apply.py +++ b/brain/teaport_brain/login_apply.py @@ -89,6 +89,18 @@ # let alone write there (it asks `status`). PENDING_PATH = "/var/lib/teaport-owner/pending" LOCK_PATH = "/run/teaport-login-apply/lock" +# The engine's license files (teaport#474 F1): nothing here writes, renames or removes them, +# whatever a path above comes to name. The same tuple in every root helper the run user +# reaches (license_link.PROTECTED is the one list; tests hold the copies to it). +PROTECTED = ("/etc/teaport/license.json", "/etc/teaport/license-revocations.json", + "/etc/teaport/license-link.secret") + + +def protected(path: str) -> bool: + """`path` is one of PROTECTED, by name or through a link.""" + return os.path.abspath(path) in PROTECTED or os.path.realpath(path) in PROTECTED + + # The brain's unit, whose User= is the run user: the login must not be that account. BRAIN_UNIT = "teaport-brain.service" # The minimum in characters, as the owner counts; the maximum in UTF-8 bytes, as PAM does @@ -282,6 +294,8 @@ def present(self) -> bool: return self._roots(directory, stat.S_ISDIR) and self._roots(marker, stat.S_ISREG) def remove(self) -> None: + if protected(self.path): + raise Refused(f"{self.path} is the engine's license, which this helper never removes") os.unlink(self.path) @@ -356,6 +370,8 @@ def handle(ops: Ops, marker: Marker, verb: str, req) -> dict: def _lock(path: str = LOCK_PATH) -> int: """An exclusive lock on root's own file, held until the process exits: two creates at once would each find no user, and the second's undo would remove the first's.""" + if protected(path): + raise Refused(f"{path} is the engine's license, which this helper never writes") os.makedirs(os.path.dirname(path), mode=0o700, exist_ok=True) fd = os.open(path, os.O_RDWR | os.O_CREAT | os.O_NOFOLLOW, 0o600) try: diff --git a/brain/teaport_brain/owner_license.py b/brain/teaport_brain/owner_license.py new file mode 100644 index 00000000..e3fc4271 --- /dev/null +++ b/brain/teaport_brain/owner_license.py @@ -0,0 +1,175 @@ +# +# teaport — the owner accepts the Teaport Engine License at setup (#465), from the run +# user's side: what the setup page (wifi_setup.py, offline) and Settings (config_ui.py, +# online) share -- whether the step is offered, the license's text, accepting it, and the +# words the owner reads about it. +# +# The recording is license_accept.py's, as root, behind its sudoers line: it takes the +# owner's email, makes POST /api/accept itself (or queues it, offline) and records the id +# the license server returns. Then license_link.py, the same way, puts that acceptance on +# the box's appliance key. The run user is the agent's: it may ask, never decide, and it +# never names an acceptance. The email goes to the helper and nowhere else (no log line, no +# answer). Only setup is held up until the owner accepts: the engine runs all the while, +# under the appliance key the box shipped with (#474, the owner's decision 2026-11-28). +# No Pipecat import: the setup unit runs this alone on a box short of memory. +# +from teaport_brain import license_accept, license_link, root_helper +from teaport_brain.i18n import N_ + +# The root-owned copies the sudoers lines name (packaging/deb/sudoers-sync). +ACCEPT_HELPER = "/usr/lib/teaport/license_accept.py" +LINK_HELPER = "/usr/lib/teaport/license_link.py" +# Each helper's longest path: the wait for the send lock, then a manifest, the text and the +# POST, each to its own limit, and a margin for python's start: a caller that gave up first +# would kill the helper mid-POST. +HELPER_SECS = license_accept.LOCK_SECS + 3 * license_accept.NET_SECS + 15 +HELPER_STOP_SECS = 10 +PENDING, QUEUED, RECORDED, NOT_OFFERED = (license_accept.PENDING, license_accept.QUEUED, + license_accept.RECORDED, license_accept.NOT_OFFERED) +# Why an acceptance did not happen, beyond the helper's codes: the box was not ticked. +UNTICKED = "unticked" + +# What the owner reads, in their language (say()). +TEXT = { + "title": N_("Read the license"), + "intro": N_("Teaport's speech engine comes with the Teaport Engine License. Read it, " + "then accept it to finish setting up Teaport."), + "email": N_("Your email address"), + "email_note": N_("Teaspoon AI records who accepted the license, with this address."), + # What the owner uses the box for (license_accept.OWNER_USES): recorded with the + # acceptance, never with a license id. + "use": N_("What will you use Teaport for?"), + "use_personal": N_("Personal use"), + "use_business": N_("A business"), + "tick": N_("I have read the Teaport Engine License and I accept it."), + "accept": N_("I accept"), + "accepting": N_("Recording your acceptance…"), + "recorded": N_("Thank you. Your acceptance of the license is recorded."), + "queued": N_("Thank you. Teaport records your acceptance with Teaspoon AI once it's online."), + # The setup page, offline, on a box that has no copy of the license yet. + "later": N_("You'll read and accept the Teaport Engine License in Settings once Teaport " + "is online."), + # The acceptance on the box, its email masked (license_accept.mask), while it may still be + # replaced: an agent could have accepted first (license_accept.py's module comment). + "accepted_as": N_("The license is accepted as {email}."), + "not_you": N_("Not you? Read the license and accept it again with your own email address."), + "again": N_("Accept again"), + # The box's secret no longer links its key (license_link.LOST): someone linked it with a + # copy; support gives the owner a recovery code. + "link_lost": N_("This Teaport's license link was lost: its license key was linked with a copy " + "of the Teaport's secret. Contact Teaspoon AI support to get it back."), + # A secret that never linked, refused, its cause unknown (license_link.CAUSE_UNKNOWN): + # neutral words, the cause is support's to find. + "link_failed": N_("This Teaport's license link failed. Contact Teaspoon AI support."), + # Settings' login card while the license waits (the login comes after it, as on the page). + "login_first": N_("Accept the license first, then create your login."), +} +WHY = { + UNTICKED: N_("Tick the box to accept the license."), + license_accept.EMAIL_BAD: N_("Enter your email address."), + license_accept.ACCEPTED: N_("The license is already accepted on this Teaport."), + license_accept.NOT_OFFERED: N_("Accepting the license isn't available on this Teaport."), + license_accept.CHANGED: N_("The license changed while you were reading it. Read it again."), + license_accept.UNAVAILABLE: N_("Teaport can't show the license right now. Try again " + "once it's online."), + license_accept.DROPPED: N_("Teaspoon AI didn't take this acceptance. Read the license " + "again and accept it."), + license_accept.FAILED: N_("Teaport couldn't record your acceptance. Try again."), + license_accept.USE: N_("Choose whether Teaport is for personal use or for a business."), + license_accept.BUSY: N_("Teaport is busy recording an acceptance. Try again in a moment."), + license_accept.REFUSED: N_("Teaport couldn't record your acceptance. Try again."), +} + + +def say(t, msgid: str, **fill) -> str: + """`msgid` (one of TEXT's or WHY's) in t's language, its placeholders ({email}) filled in.""" + text = t._(msgid) + return text.format(**fill) if fill else text + + +def sudo_helper(helper: str, verb: str, req: dict) -> dict: + return root_helper.call(helper, verb, req, timeout=HELPER_SECS, + stop_secs=HELPER_STOP_SECS, name="the license helper") + + +class License: + """The owner's acceptance. `accept_helper` and `link_helper` (verb, req) -> reply are + injectable; given `box` (and `link_box`, tests), the requests run in-process through + the helpers' handle().""" + + def __init__(self, accept_helper=None, link_helper=None, box=None, link_box=None): + if accept_helper is None: + accept_helper = (self._in_process(license_accept, box) if box is not None + else lambda verb, req: sudo_helper(ACCEPT_HELPER, verb, req)) + if link_helper is None: + link_helper = (self._in_process(license_link, link_box) if link_box is not None + else lambda verb, req: sudo_helper(LINK_HELPER, verb, req)) + self._accept, self._link = accept_helper, link_helper + + @staticmethod + def _in_process(module, box): + def call(verb: str, req: dict) -> dict: + try: + return module.handle(box, verb, req) + except module.Refused as e: + return {"ok": False, "err": str(e), "why": e.why} + return call + + def state(self) -> str: + """PENDING, QUEUED, RECORDED or NOT_OFFERED. A helper that cannot answer (no sudoers + line, an install without it) offers nothing: the step is only shown when it can work.""" + state = self._accept("status", {}).get("state") + return state if state in (PENDING, QUEUED, RECORDED) else NOT_OFFERED + + def pending(self) -> bool: + return self.state() == PENDING + + def accepted(self) -> dict | None: + """{email: masked, replaceable} of the acceptance on the box, while setup is + unfinished (queued or recorded); None for none, or a helper that cannot answer.""" + r = self._accept("status", {}) + if r.get("state") not in (QUEUED, RECORDED) or not isinstance(r.get("email"), str): + return None + return {"email": r["email"], "replaceable": r.get("replaceable") is True} + + def text(self) -> dict | None: + """{version, sha256, text} of the license to accept now, or None (no copy on the box + and no way to fetch one, or nothing offered).""" + r = self._accept("text", {}) + if isinstance(r.get("text"), str) and isinstance(r.get("sha256"), str): + return {"version": r.get("version"), "sha256": r["sha256"], "text": r["text"]} + return None + + def accept(self, email: str, sha256: str, ticked: bool, owner_use: str | None = None, + replace: bool = False) -> tuple[bool, str]: + """(True, QUEUED or RECORDED) once the acceptance is on the box, else (False, a WHY + code). `owner_use`: personal or business, as the owner chose. `replace`: in place of + the one on the box ("Not you? Accept again", while the + helper says it may). Recorded: linked to the box's key at once (link(); a link that + fails is retried by the timer, and never undoes the acceptance).""" + if not ticked: + return False, UNTICKED + if not license_accept.valid_email(email): + return False, license_accept.EMAIL_BAD + if owner_use not in license_accept.OWNER_USES: + return False, license_accept.USE + r = self._accept("accept", {"email": email.strip(), "eula_sha256": sha256, "owner_use": owner_use, + "replace": replace is True}) + if r.get("ok") is True and r.get("state") in (QUEUED, RECORDED): + if r["state"] == RECORDED: + self.link() + return True, r["state"] + why = r.get("why") + return False, why if why in WHY else license_accept.FAILED + + def link_lost(self) -> str | None: + """The box's secret no longer links its key (license_link.LOST): the TEXT that says + why ("link_lost", or "link_failed" for a secret that never linked, cause unknown).""" + r = self._link("status", {}) + if r.get("state") != license_link.LOST: + return None + return "link_failed" if r.get("why") == license_link.CAUSE_UNKNOWN else "link_lost" + + def link(self) -> bool: + """The recorded acceptance on the box's key, through the link helper: whether it is.""" + return self._link("link", {}).get("linked") is True diff --git a/brain/teaport_brain/static/config.html b/brain/teaport_brain/static/config.html index 7c011734..ca942247 100644 --- a/brain/teaport_brain/static/config.html +++ b/brain/teaport_brain/static/config.html @@ -323,6 +323,11 @@ .account .acct-msg.ok { color: var(--ok-ink); } .account .acct-connect { display: grid; gap: 8px; max-width: 560px; margin: 16px 0 0; } .account .acct-connect .btn-primary { justify-self: start; } + /* The license the owner accepts (#465): its whole text, in a box of its own that scrolls. */ + .account .eula-text { max-height: 320px; overflow: auto; margin: 16px 0 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: var(--surface); font-family: var(--mono); } + .account .eula-tick { display: flex; gap: 8px; align-items: flex-start; } + .account .eula-use { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; } + .account .eula-use legend { padding: 0; margin: 0 0 4px; } .account .banner { margin: 12px 0 0; } .account > .group-blurb + .group-blurb { margin-top: 10px; } .adv-toggle { margin: 0 0 24px; } @@ -366,6 +371,7 @@

This box asks for its token