clavarium 0.2.402-next.1 → 0.2.405-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.
- package/deploy/clavarium-host +6 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/conversations.mjs +9 -1
- package/server/vm.mjs +2 -2
package/deploy/clavarium-host
CHANGED
|
@@ -1121,10 +1121,11 @@ case "$AREA $VERB" in
|
|
|
1121
1121
|
fi
|
|
1122
1122
|
exit 0 ;;
|
|
1123
1123
|
"vm smount")
|
|
1124
|
-
# <vm> <conversation> <work|folder|view> <resource> <uid> <gid>: into the conversation's
|
|
1125
|
-
# shared machine (/srv/clavarium/<conversation>/...), where its door (clavarium-enter) finds
|
|
1126
|
-
# a conversation that lives in that machine.
|
|
1127
|
-
[ $# -eq
|
|
1124
|
+
# <vm> <conversation> <work|folder|view> <resource> <uid> <gid> <its uid> <its gid>: into the conversation's
|
|
1125
|
+
# own place in a shared machine (/srv/clavarium/<conversation>/...), where its door (clavarium-enter) finds
|
|
1126
|
+
# it, owned there by ITS user (not the machine's admin) -- only for a conversation that lives in that machine.
|
|
1127
|
+
[ $# -eq 8 ] || usage; vm_of "$1"; is_name "$2" || refuse "not a conversation name: $2"; is_name "$4" || refuse "not a folder name: $4"; number "$5"; number "$6"; number "$7"; number "$8"
|
|
1128
|
+
[ "$7" -ge 1001 ] && [ "$8" -ge 1001 ] || refuse "its own user is not the machine's admin"
|
|
1128
1129
|
[ -f "$DATA/shared/$1" ] && grep -qx "$2" "$DATA/shared/$1" || refuse "$2 does not live in $1"
|
|
1129
1130
|
case "$3" in
|
|
1130
1131
|
work) [ "$4" = "$2" ] || refuse "a work folder belongs to its own conversation"
|
|
@@ -1137,7 +1138,7 @@ case "$AREA $VERB" in
|
|
|
1137
1138
|
target="$1:/srv/clavarium/$2/resources/$4" ;;
|
|
1138
1139
|
*) refuse "a shared mount is of a work folder, a folder or a view" ;;
|
|
1139
1140
|
esac
|
|
1140
|
-
run "$MULTIPASS" mount -u "$5:$
|
|
1141
|
+
run "$MULTIPASS" mount -u "$5:$7" -g "$6:$8" "$source" "$target" ;;
|
|
1141
1142
|
"vm sumount")
|
|
1142
1143
|
# <vm> <conversation> <work|resource name>: taken out of its place in a shared machine.
|
|
1143
1144
|
[ $# -eq 3 ] || usage; vm_of "$1"; is_name "$2" || refuse "not a conversation name: $2"; is_name "$3" || refuse "not a name: $3"
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.405-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.405-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/conversations.mjs
CHANGED
|
@@ -21,6 +21,8 @@ export const STOP_DELAY_MS = 60_000;
|
|
|
21
21
|
const STEP_MS = 15 * 60_000;
|
|
22
22
|
/* The door of a conversation in a shared machine (#221), put in the machine by the server. */
|
|
23
23
|
export const DOOR = new URL('../config/machine/clavarium-enter', import.meta.url);
|
|
24
|
+
/* The most programs one conversation may run in a shared machine. */
|
|
25
|
+
export const SHARED_PROCS = 1024;
|
|
24
26
|
/* Moving a work folder: what must stay free after it, and how long a copy may take. */
|
|
25
27
|
export const ROOM_MB = 1024;
|
|
26
28
|
/* A file shown straight from a machine's disk: where, and how large at most. */
|
|
@@ -444,8 +446,13 @@ export class Conversations {
|
|
|
444
446
|
const [uid, gid] = String(me.stdout ?? '').trim().split('\n').map(Number);
|
|
445
447
|
if (me.code !== 0 || !Number.isInteger(uid) || !Number.isInteger(gid)) return fail('Its own user could not be made', me);
|
|
446
448
|
this.#store.patch(name, { machineUser: { uid, gid } });
|
|
449
|
+
/* Its limits, read by its door at each entry: the memory chosen for it, and a bound on its programs -- one
|
|
450
|
+
conversation that runs away never takes the machine from the others. */
|
|
451
|
+
const limits = await this.#vms.execMachine(name, ['sudo', '-n', 'install', '-D', '-m', '0644', '-o', 'root', '-g', 'root', '/dev/stdin', `/etc/clavarium/limits/${name}`],
|
|
452
|
+
{ input: `mem=${Number(c.memoryMb) || tool.memoryMb}\nprocs=${SHARED_PROCS}\n`, timeoutMs: STEP_MS });
|
|
453
|
+
if (limits.code !== 0) return fail('Its limits could not be set in the shared machine', limits);
|
|
447
454
|
const kept = await this.#vms.workMake(name);
|
|
448
|
-
const shown = kept.code === 0 ? await this.#vms.workMount(name, uid, gid) : kept;
|
|
455
|
+
const shown = kept.code === 0 ? await this.#vms.workMount(name, this.#uid, this.#gid) : kept;
|
|
449
456
|
if (shown.code !== 0) return fail('The work folder could not be shown in the shared machine', shown);
|
|
450
457
|
/* Its tool: there already (another conversation installed it), or installed -- a step as root for the
|
|
451
458
|
machine, any other as its own user (its settings, in its home). */
|
|
@@ -1695,6 +1702,7 @@ export class Conversations {
|
|
|
1695
1702
|
await this.#vms.execMachine(name, ['sudo', '-n', 'pkill', '-KILL', '-u', `c-${name}`], { timeoutMs: 30_000 }).catch(() => {});
|
|
1696
1703
|
await this.#vms.workUnmount(name).catch(() => {});
|
|
1697
1704
|
if (erase) await this.#vms.execMachine(name, ['sudo', '-n', 'userdel', '--remove', `c-${name}`], { timeoutMs: 60_000 }).catch(() => {});
|
|
1705
|
+
if (erase) await this.#vms.execMachine(name, ['sudo', '-n', 'rm', '-f', `/etc/clavarium/limits/${name}`], { timeoutMs: 30_000 }).catch(() => {});
|
|
1698
1706
|
}
|
|
1699
1707
|
await this.#vms.unshare(name).catch(() => {});
|
|
1700
1708
|
const last = others.length === 0;
|
package/server/vm.mjs
CHANGED
|
@@ -188,7 +188,7 @@ export class Vms {
|
|
|
188
188
|
files written in the VM belong, on the host, to this account. */
|
|
189
189
|
mount(conversation, kind, name, uid, gid) {
|
|
190
190
|
/* In a shared machine (#221): into its own place there, where its door finds it. */
|
|
191
|
-
if (this.shared(conversation)) { const u = this.#userOf(conversation)
|
|
191
|
+
if (this.shared(conversation)) { const u = this.#userOf(conversation); if (!u) throw new Error('its own user in the shared machine is not known yet'); return this.run(['vm', 'smount', this.vmOf(conversation), conversation, kind, name, String(uid), String(gid), String(u.uid), String(u.gid)], { timeoutMs: 600_000 }); }
|
|
192
192
|
return this.run(['vm', 'mount', this.vmOf(conversation), kind, name, String(uid), String(gid)], { timeoutMs: 600_000 });
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -196,7 +196,7 @@ export class Vms {
|
|
|
196
196
|
machine at /work. Made (or found again) before it is mounted. */
|
|
197
197
|
workMake(conversation) { this.vmOf(conversation); return this.run(['work', 'make', conversation]); }
|
|
198
198
|
workMount(conversation, uid, gid) {
|
|
199
|
-
if (this.shared(conversation)) { const u = this.#userOf(conversation)
|
|
199
|
+
if (this.shared(conversation)) { const u = this.#userOf(conversation); if (!u) throw new Error('its own user in the shared machine is not known yet'); return this.run(['vm', 'smount', this.vmOf(conversation), conversation, 'work', conversation, String(uid), String(gid), String(u.uid), String(u.gid)], { timeoutMs: 600_000 }); }
|
|
200
200
|
return this.run(['vm', 'mount', this.vmOf(conversation), 'work', conversation, String(uid), String(gid)], { timeoutMs: 600_000 });
|
|
201
201
|
}
|
|
202
202
|
workUnmount(conversation) {
|