Every worker bot now works on a computer as its own Linux account (cb-<bot id>, no sudo), owning its folder; a workspace's folder belongs to a group its bots share. Only the coordinator works as gem, with sudo. gem, and so Chrome, can't open worker folders: downloads, uploads and files saved by name are copied by the worker's own account, and workers open no file: URLs. The computer's own services (agent, DevTools, Playwright MCP, VNC, ttyd) are kept from worker accounts by an nftables rule, so containers get NET_ADMIN; without the rule the agent refuses worker commands. The X display needs gem's cookie. File reads for a worker are checked on the open descriptor, and writes are made as the worker. Workers ask the coordinator to install system packages with request_install: a coordinator task in the super admin's conversation weighs it and answers, and the answer wakes the worker. Stop ends a worker's leftover processes on its computers. Computer image 1.2.0; the layout bump recreates every computer once.
20 lines
682 B
TypeScript
20 lines
682 B
TypeScript
import type { RunUser } from "./run-user-for";
|
|
|
|
/**
|
|
* The environment a worker's commands get: its own home and identity,
|
|
* and nothing of gem's (no screen, no session bus, no cookie), so it can
|
|
* reach neither the browser nor gem's services.
|
|
*/
|
|
export default function workerEnv({ run_user }: { run_user: RunUser }): NodeJS.ProcessEnv {
|
|
return {
|
|
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
|
HOME: run_user.home,
|
|
USER: run_user.name,
|
|
LOGNAME: run_user.name,
|
|
SHELL: "/bin/bash",
|
|
LANG: process.env.LANG || "C.UTF-8",
|
|
TZ: process.env.TZ || "UTC",
|
|
PIP_BREAK_SYSTEM_PACKAGES: "1",
|
|
};
|
|
}
|