clavarium 0.2.418-next.1 → 0.2.419-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  # /resources/* are only those given to it (/srv/clavarium/NAME/resources),
8
8
  # /tools is the machine's (the same for all, read-only),
9
9
  # ~ is /home/c-NAME (closed to the others),
10
- # /tmp is its own,
10
+ # /tmp, /var/tmp and /dev/shm are its own,
11
11
  # /run/secrets and /etc/clavarium/conversation.md are its own (/run/clavarium/own/NAME, /etc/clavarium/own/NAME.md),
12
12
  # within a slice of its own (memory, processes: /etc/clavarium/limits/NAME, set by Clavarium). Seen from inside,
13
13
  # a conversation is alone in its machine: no tool, no agent needs to know.
@@ -23,12 +23,15 @@ if ! id "$user" >/dev/null 2>&1; then
23
23
  useradd --create-home --home-dir "/home/$user" --shell /bin/bash --user-group "$user"
24
24
  fi
25
25
  chmod 700 "/home/$user"
26
- mkdir -p "$base/work" "$base/resources" "$base/tmp"
27
- chown "$user:$user" "$base/tmp"; chmod 700 "$base/tmp"
26
+ mkdir -p "$base/work" "$base/resources" "$base/tmp" "$base/vartmp"
27
+ # Its place closed to the others (its own views of it are made below, as root): never another's /work by its path.
28
+ chown root:root /srv/clavarium "$base"; chmod 711 /srv/clavarium; chmod 700 "$base"
29
+ chown "$user:$user" "$base/tmp" "$base/vartmp"; chmod 700 "$base/tmp" "$base/vartmp"
28
30
  # Its secrets and its guide: its own, written by Clavarium, shown at the usual places (never the others').
29
31
  own="/run/clavarium/own/$name"; mkdir -p "$own/secrets"; chmod 711 /run/clavarium /run/clavarium/own
30
32
  chown "$user:$user" "$own/secrets"; chmod 700 "$own/secrets"
31
- mkdir -p /etc/clavarium/own /run/secrets; [ -e "/etc/clavarium/own/$name.md" ] || install -m 0444 /dev/null "/etc/clavarium/own/$name.md"
33
+ mkdir -p /etc/clavarium/own /run/secrets; chmod 711 /etc/clavarium/own
34
+ [ -e "/etc/clavarium/own/$name.md" ] || install -m 0440 -o root -g "$user" /dev/null "/etc/clavarium/own/$name.md"
32
35
  [ -e /etc/clavarium/conversation.md ] || install -m 0444 /dev/null /etc/clavarium/conversation.md
33
36
  # Its limits (memory in MB, processes), when Clavarium set them.
34
37
  mem=""; procs=""
@@ -42,6 +45,8 @@ exec unshare --mount --propagation private -- sh -c '
42
45
  mount -t tmpfs -o mode=755,size=1m none /resources
43
46
  for r in "$base"/resources/*; do [ -e "$r" ] || continue; mkdir -p "/resources/$(basename "$r")"; mount --rbind "$r" "/resources/$(basename "$r")"; done
44
47
  mount --bind "$base/tmp" /tmp
48
+ mount --bind "$base/vartmp" /var/tmp
49
+ mount -t tmpfs -o mode=1777,size=64m none /dev/shm
45
50
  mount --bind "/run/clavarium/own/$name/secrets" /run/secrets
46
51
  mount --bind "/etc/clavarium/own/$name.md" /etc/clavarium/conversation.md
47
52
  # The processes of the others hidden (a procfs of its own, Linux 5.8+): only its own are seen.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.418-next.1",
3
+ "version": "0.2.419-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.418-next.1",
9
+ "version": "0.2.419-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.418-next.1",
3
+ "version": "0.2.419-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
package/server/guide.mjs CHANGED
@@ -36,7 +36,7 @@ import { Refusal } from './conversations.mjs';
36
36
  import { isConversationName } from './names.mjs';
37
37
  import { originFolder } from './resources.mjs';
38
38
  import { TOOLS_PATH, NOTES } from './toolbox.mjs';
39
- import { ownGuideFile } from './vm.mjs';
39
+ import { ownGuideFile, sharedUser } from './vm.mjs';
40
40
 
41
41
  export const COMMON_PATH = `${TOOLS_PATH}/${NOTES}`;
42
42
  export const OWN_PATH = '/etc/clavarium/conversation.md';
@@ -80,7 +80,7 @@ export function commonText() {
80
80
  return [
81
81
  '# Where you are (Clavarium)',
82
82
  '',
83
- '- A throw-away machine, yours alone: you are root (sudo works). Install what you need.',
83
+ '- A throw-away machine, yours alone: you are root (sudo works). Install what you need. (In a shared machine, not so: ' + OWN_PATH + ' says it.)',
84
84
  '- /work: where you work. /resources/<name>: folders and repositories you were given, read-only or read-write. /tools: tools offered, read-only (/tools/index.json says what each is).',
85
85
  `- What this conversation has, and what its owner asks of you: ${OWN_PATH} (read-only; written again by the server when your setup changes).`,
86
86
  '- Git: commit your work. The person reviews it and sends it from their screen, or the server sends it by itself where they allowed it. You have no push key: never push.',
@@ -102,9 +102,11 @@ const list = (items) => items.join(', ');
102
102
  /* THE PART OF ONE CONVERSATION, from its facts:
103
103
  { name, tool, workKept, resources: [{ name, access, type, origin }], chat, online, secrets: [names], lines, reread }
104
104
  `reread`: the command that reads the end of its chat after a restart (the owner's choice, talk.mjs). */
105
- export function ownText({ name, tool, workKept, resources = [], chat, online, secrets = [], lines = [], reread }) {
105
+ export function ownText({ name, tool, shared, workKept, resources = [], chat, online, secrets = [], lines = [], reread }) {
106
106
  const out = [`# This conversation: ${plain(name, 40)}`, ''];
107
107
  if (tool) out.push(`- Tool running here: ${plain(tool, 40)}.`);
108
+ /* #221: in a shared machine, its own user without sudo -- not what /tools/CLAVARIUM.md says of a machine of its own. */
109
+ if (shared) out.push(`- A machine shared with other conversations: you are its user c-${plain(name, 40)}, NOT root (no sudo). Install in your home (npm --prefix ~/.local, pip install --user); what needs root, ask the person.`);
108
110
  out.push(workKept ? '- /work is kept by the server: the person sees it in Files, and it outlives the machine.' : '- /work is on this machine\'s own disk: it goes with the machine.');
109
111
  const where = (r) => `/resources/${plain(r.name, 40)}${r.type === 'mailbox' ? ' (mail)' : r.type === 'git' ? ' (git)' : ''}`;
110
112
  const write = resources.filter((r) => r.access === 'write');
@@ -225,7 +227,7 @@ export class Guide {
225
227
  const type = this.#resources.get(r.name)?.type ?? 'folder';
226
228
  return { name: r.name, access: r.access, type, origin: type === 'git' && this.#resources.hasOrigin?.(r.name) ? originFolder(r.name) : undefined };
227
229
  });
228
- return ownText({ name, tool: this.#tool(c)?.label ?? c.tool, workKept: c.work === 'kept', resources, chat: Boolean(this.#chat(name)), online: c.offline !== true, secrets: (this.#secrets?.given ?? this.#secrets?.of)?.call(this.#secrets, name) ?? [], lines: this.lines(name), reread: this.#reread() });
230
+ return ownText({ name, tool: this.#tool(c)?.label ?? c.tool, shared: this.#vms.shared?.(name) === true, workKept: c.work === 'kept', resources, chat: Boolean(this.#chat(name)), online: c.offline !== true, secrets: (this.#secrets?.given ?? this.#secrets?.of)?.call(this.#secrets, name) ?? [], lines: this.lines(name), reread: this.#reread() });
229
231
  }
230
232
 
231
233
  /* What the page shows: the exact texts, where each is, and the line in the tool's own file. */
@@ -246,9 +248,9 @@ export class Guide {
246
248
  /* ---- into the machine ---- */
247
249
  async #writeOwn(name) {
248
250
  const text = this.own(name);
249
- /* In a shared machine, its own file: its door shows it at OWN_PATH (#221). */
250
- const path = this.#vms.shared?.(name) === true ? ownGuideFile(name) : OWN_PATH;
251
- const r = await this.#vms.exec(name, ['sudo', '-n', 'install', '-D', '-m', '0444', '-o', 'root', '-g', 'root', '/dev/stdin', path], { input: text, timeoutMs: 30_000 });
251
+ /* In a shared machine, its own file, readable by its own user only: its door shows it at OWN_PATH (#221). */
252
+ const shared = this.#vms.shared?.(name) === true;
253
+ const r = await this.#vms.exec(name, ['sudo', '-n', 'install', '-D', '-m', shared ? '0440' : '0444', '-o', 'root', '-g', shared ? sharedUser(name) : 'root', '/dev/stdin', shared ? ownGuideFile(name) : OWN_PATH], { input: text, timeoutMs: 30_000 });
252
254
  if (r.code !== 0) throw new Error(`its guide could not be written: ${firstLine(r.stderr) || `exit ${r.code}`}`);
253
255
  this.#written.set(name, text);
254
256
  }