mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-26 01:41:04 +08:00
The confined file tools (Read, Write, Edit, MultiEdit, LS, Glob, Grep) and the opens of ingest_bbot and ingest_scan_output ran inside the server, as root, and relied on the os.Root path confinement alone. With the executor privilege drop active, PrepareExecPrivilege now gives them the executor uid and gid: each call runs on a thread of its own whose file system uid, file system gid and supplementary groups are the executor's (setfsuid, setfsgid and the per-thread setgroups of x/sys/unix). The thread is never unlocked, so the runtime ends it with the call and no other goroutine runs with those ids. The kernel then checks every open, create and directory read against the rights of the agent's shell, on top of the path confinement. Output over the cap is still spilled, after the call, with the server's identity. Linux only. Elsewhere the identity is not set and a log line says the file tools keep the server's identity. golang.org/x/sys becomes a direct dependency (already in the module graph at the same version).
15 lines
411 B
Go
15 lines
411 B
Go
//go:build !linux
|
|
|
|
package agent
|
|
|
|
import "errors"
|
|
|
|
const fileIdentitySupported = false
|
|
|
|
// runWithFileIdentity: per-thread file system ids exist on Linux only. The server
|
|
// sets no identity where FileToolIdentitySupported is false; one set anyway fails
|
|
// closed.
|
|
func runWithFileIdentity(FileToolIdentity, func()) error {
|
|
return errors.New("the file tools cannot run as another identity on this platform")
|
|
}
|