45 lines
2.7 KiB
SQL
45 lines
2.7 KiB
SQL
-- A module that joins has a user and a group of its own, each library has a group of its own, and a library's
|
||
-- existing data is taken once, on the operator's word (novox/hq ADR 0328 §3, §4, §7, §15).
|
||
--
|
||
-- **One sequence for every number the mesh gives.** A joining module is given one number, its user's and its own
|
||
-- group's (mesh-<module>); a library is given one, its group's (mesh-<library>). Both are drawn from this sequence, so
|
||
-- a module's own group and a library's group never share a number. The range is 50000–59999 (catalogue.IdentityLow and
|
||
-- IdentityHigh): above the numbers distributions give people, below the 60000s Debian keeps for its daemons, and
|
||
-- nowhere near root's 0 or a root group's (0, 4, 10). The checks refuse a row outside it, so no write, by hand or by a
|
||
-- later bug, can make one root's (§15). A sequence never hands a number back, and a row is kept after its module or
|
||
-- library is gone, so a number once given is never given to another: a file left owned by a removed module's user is
|
||
-- never inherited by a new one.
|
||
create sequence mesh_number as integer minvalue 50000 maxvalue 59999 start 50000 no cycle;
|
||
|
||
create table module_identity (
|
||
module text primary key,
|
||
uid integer not null unique check (uid between 50000 and 59999),
|
||
allocated timestamptz not null default now()
|
||
);
|
||
|
||
create table library_group (
|
||
library text primary key,
|
||
gid integer not null unique check (gid between 50000 and 59999),
|
||
allocated timestamptz not null default now()
|
||
);
|
||
|
||
-- **A library taken** (§7). The first time a library's root on its home holds data not yet in its group, the operator
|
||
-- is asked once for that library; on the warrant the node-engine sets the group, group write and setgid under the root,
|
||
-- and the library is taken: kept from then on without asking. The row is the record of that act — on which machine
|
||
-- and filesystem, who approved it, under which warrant. A library whose home or filesystem changed since (it moved to
|
||
-- another machine or another disk) is not taken by that warrant, and the operator is asked again; a new take replaces
|
||
-- the row.
|
||
create table kept_library (
|
||
library text primary key,
|
||
home text not null,
|
||
-- The filesystem the root was on when taken, as the engine names it without a path ("fs-<12 hex>"); empty when
|
||
-- the engine named none.
|
||
placed text not null default '',
|
||
taken_at timestamptz not null default now(),
|
||
taken_by text not null,
|
||
ask text not null,
|
||
warrant text not null,
|
||
-- What the node-engine answered when it started the take.
|
||
said text not null default ''
|
||
);
|