Documentation
¶
Index ¶
- Constants
- func DropPrivileges(cmd *exec.Cmd)
- func EnsureOwnership(root string) error
- func Environ() []string
- func Filter(parent []string) []string
- func FilterForGolemCLI(parent []string) []string
- func FilterPairs(m map[string]string) []string
- func GolemCLIEnviron() []string
- func IsGolemOwned(name string) bool
- func User() *agentAccount
Constants ¶
const UserEnv = "GOLEM_AGENT_USER"
The shem itself stays root: it holds the push credential, and dropping it would mean the credential lives somewhere the agent can reach anyway. UserEnv names the unprivileged account the agent runs as.
Variables ¶
This section is empty.
Functions ¶
func DropPrivileges ¶
applyAgentCredentials makes cmd run as the unprivileged agent account, and rewrites the identity variables so the tools it starts agree about who it is. HOME especially: it is on agentenv's allow-list and would otherwise arrive as /root, which the dropped process cannot write, and Claude Code stores its state under HOME. DropPrivileges makes cmd run as the unprivileged agent account when one is configured, and is a no-op otherwise.
func EnsureOwnership ¶
ensureAgentOwnership gives the agent account ownership of everything under root that it does not already own.
The shem runs as root and creates the clone, the ticket directory and the worktree, so without this the dropped agent cannot write the code it is employed to write. Entries already owned are skipped, so the common case — a repository prepared on an earlier run — walks the tree without touching it.
Failures are reported but not fatal: a repository the agent cannot write fails loudly in the phase that follows, which is a better error than refusing to start. EnsureOwnership gives the agent account ownership of everything under root that it does not already own. No-op when no account is configured.
func Environ ¶
func Environ() []string
Environ is Filter over this process's own environment. It is what every agent exec site passes to cmd.Env.
func Filter ¶
Filter reduces parent (an os.Environ()-shaped slice) to what an agent subprocess is allowed to see.
func FilterForGolemCLI ¶
FilterForGolemCLI applies the agent allow-list and retains only its policy directive for the trusted Golem CLI to apply to its own children.
func FilterPairs ¶
FilterPairs returns operator-declared variables as KEY=VALUE pairs, minus golem's own. The allow-list does not apply: the operator named them.
func GolemCLIEnviron ¶
func GolemCLIEnviron() []string
GolemCLIEnviron is for a trusted nested Golem CLI, not an agent process. The CLI may run a gate, which filters its own child environment again. Keep the operator's allow-list policy across that boundary so explicitly allowed build/test variables survive the second filter; Filter still strips the policy itself before any agent or gate command runs.
func IsGolemOwned ¶
IsGolemOwned reports whether name is golem's own configuration, which never reaches an agent.
func User ¶
func User() *agentAccount
resolveAgentUser returns the account to run agents as, or nil to run them as this process does.
nil is returned when the process is not root (nothing to drop — this is CLI mode, `go run`, and every test) or when the account does not exist. The container case is the one that matters, and it is verified there: running the agent as root is what makes GOLEM_GITHUB_TOKEN readable out of /proc/1/environ, so a silent fallback to root would quietly restore exactly the exposure this exists to close. It is therefore logged loudly. User returns the resolved unprivileged agent account, or nil.
Types ¶
This section is empty.