fix(#1304) scope state/harness chowns to own agent dir in hive-agent-user-migrate

This commit is contained in:
damocles 2026-06-04 20:47:40 +02:00 committed by mara
commit 6c16d25039

View file

@ -705,14 +705,19 @@ in
fi fi
mkdir -p "$(dirname "$marker")" mkdir -p "$(dirname "$marker")"
: > "$marker" : > "$marker"
for stateDir in /agents/*/state; do # Scope state + harness chowns to THIS container's own dirs only.
[ -d "$stateDir" ] || continue # The glob `/agents/*/state` also matches child-agent state dirs that
chown -hR "$userName:$userName" "$stateDir" 2>/dev/null || true # are bind-mounted into parent containers, which would clobber the
done # ownership those dirs' own activation scripts set — producing
for harnessDir in /agents/*/harness; do # intermittent EACCES for the child agent's harness between a parent
[ -d "$harnessDir" ] || continue # rebuild and the child's next activation. Config dirs are kept broad
chown -hR "$userName:$userName" "$harnessDir" 2>/dev/null || true # because the parent legitimately owns child proposed-config repos.
done if [ -d "/agents/$userName/state" ]; then
chown -hR "$userName:$userName" "/agents/$userName/state" 2>/dev/null || true
fi
if [ -d "/agents/$userName/harness" ]; then
chown -hR "$userName:$userName" "/agents/$userName/harness" 2>/dev/null || true
fi
# The proposed-config repo is RW-mounted into the editing (parent/ # The proposed-config repo is RW-mounted into the editing (parent/
# manager) agent and owned by it; hive-c0re only pulls from it. Heal # manager) agent and owned by it; hive-c0re only pulls from it. Heal
# it to this user too — same as state/harness. In an agent's own # it to this user too — same as state/harness. In an agent's own