Expand description
Directories and files that nobody else on this machine can read.
data/ holds the database (chat history, the proxy’s API key, the
environment variables given to MCP servers) beside the endpoint identity
and the device keys. A build made in a checkout resolves it inside the
repository, which other accounts on the machine can often reach, so data/
is 0700 and the database in it 0600, each from the moment it exists.
Creating is strict; tightening is best effort. A mode asked of mkdir
or open costs nothing a plain create did not, so these fail exactly when
one would. Tightening what is already there, which an older build left or
this crate’s build.rs made in a checkout, is a chmod afterwards, and a
filesystem with no Unix modes refuses that for every file. So a tightening
that fails is logged rather than returned: a gglib that would not start
there would protect nothing.
Functions§
- create_
dir 🔒 mkdirasked for0700. The mode applies to every directory this creates, parents included, and to none that already exist.- create_
file 🔒 openasked for0600, and only if nothing is there:create_newis what makes truncating an existing file impossible here.- create_
private_ dir - Create
dirand any parents it lacks0700, and take group and other’s access away from adirthat was already there. - create_
private_ file - Create
fileempty and0600, or take group and other’s access away from one that is already there. - make_
private - Take group and other’s access away from whatever is at
path; the owner keeps what it had. - tighten 🔒
- Clear group’s and other’s bits, keeping the owner’s and the setuid, setgid
and sticky bits, and only when group or other has one, so a file that is
already private costs a
statand nothing more.