mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-25 17:30:56 +08:00
The task and chat workspace trees were shared whole with the executor group, and the main agent and the planner worked in tasks/<id>, the parent of every worker directory: the executor could rename, remove or replace a run directory, its own included, and plant entries beside them. - Layout: no agent working directory is an ancestor of another. The main agent and the planner work in tasks/<id>/main, a worker in tasks/<id>/i<N>, a chat in sessions/<id>. With the privilege drop on, tasks/, sessions/ and tasks/<id> are root:root 0755 and only the leaves are root:<exec gid> 2775. - PrepareExecPrivilege no longer shares tasks/ and sessions/. It sets the parents, shares the leaves found on disk with what they hold, and registers the run-directory maker (agent.SetRunDirMaker). ensureRunDir and the chat session directory go through it: each level is created with Mkdir and set through a descriptor opened with O_NOFOLLOW, parents before the leaf, so a link planted where a run directory goes is refused. Without the drop both stay a plain MkdirAll. - Uploads for the main agent land in tasks/<id>/main/uploads, and the attachment paths given to it use the same directory; session uploads create sessions/<id> by the same rule. - Task archives still pack and delete the whole task directory, so the package holds files/tasks/<id>/main and i<N>. The package keeps neither owners nor directory modes: the restore puts the layout back (installTaskArchiveFiles takes the privilege). - Existing data is not migrated. Files a task wrote directly in tasks/<id>/ stay there with their owner and mode; the main agent starts in an empty tasks/<id>/main and its file tools no longer reach them. Tests: TestRunDirLayout and TestIsRunDirName (agent); root-only TestRunDirLayoutAsRoot, TestRunDirSiblingsProtectedAsRoot, TestRunDirLayoutOnExistingTreeAsRoot and TestTaskArchiveRestoreRunDirOwnershipAsRoot (server). The archive tests use the main/ and i<N> leaves. SECURITY.md states the invariant, names the race that remains and drops ensureRunDir from the residual list.
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
//go:build !unix
|
|
|
|
package server
|
|
|
|
import (
|
|
"errors"
|
|
"os/exec"
|
|
)
|
|
|
|
// Without unix credentials the privilege drop cannot be applied. ResolveExecPrivilege
|
|
// never enables it here, so these stubs only keep the package compiling; the
|
|
// functions that would act on an enabled drop return an error to fail closed.
|
|
|
|
var errExecUnsupported = errors.New("agent process isolation is not supported on this platform")
|
|
|
|
func execPrivilegeSupported() bool { return false }
|
|
|
|
func serverIsRoot() bool { return false }
|
|
|
|
func applyExecCredential(c *exec.Cmd, p ExecPrivilege) {}
|
|
|
|
func prepareExecScript(p ExecPrivilege, path string) error { return nil }
|
|
|
|
func shareRestoredTaskDir(p ExecPrivilege, taskDir string) error { return nil }
|
|
|
|
// PrepareExecPrivilege fails when a drop is enabled; a disabled one does nothing.
|
|
func PrepareExecPrivilege(p *ExecPrivilege, dataDir, keyDir, configPath string) error {
|
|
if p.Enabled {
|
|
return errExecUnsupported
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// InstallBashShim fails when a drop is enabled; a disabled one does nothing.
|
|
func InstallBashShim(p ExecPrivilege) error {
|
|
if p.Enabled {
|
|
return errExecUnsupported
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RunExecShimIfRequested does nothing: no shim is ever installed on this platform.
|
|
func RunExecShimIfRequested(argv []string) {}
|