olliesrv: route agent paths by FindAgent, not active agent

The 9P server path classifier still validated /session/{id}/agent/{aid}
against sess.Core.Agent().Name(), which leaked single-agent semantics into
multi-agent routing. This broke per-agent paths even when the per-agent
file trees were otherwise correct.

Fix route/type validation to resolve the requested agent with FindAgent(),
and use that specific agent for /proc PID checks.
This commit is contained in:
Ollie Agent 2026-08-01 22:03:41 +02:00
parent beadf8463a
commit a01829991f
1 changed files with 4 additions and 4 deletions

View File

@ -585,9 +585,9 @@ func (s *Server) pathType(path string) string {
if sess.Core == nil {
return ""
}
// Validate agent Name
agentName := sess.Core.Agent().Name()
if agentName == "" || parts[2] != agentName {
// Validate target agent by name or ID.
ag := sess.Core.FindAgent(parts[2])
if ag == nil {
return ""
}
// /session/{id}/agent/{aid} — directory
@ -600,7 +600,7 @@ func (s *Server) pathType(path string) string {
}
// /session/{id}/agent/{aid}/proc/{pid} — verify exists
if len(parts) == 5 && parts[3] == "proc" {
for _, p := range sess.Core.Agent().ListDetached() {
for _, p := range ag.ListDetached() {
if fmt.Sprintf("%d", p.PID) == parts[4] {
return "file"
}