Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Bypass per-server ACL for control-plane actions; add diagnostic logs

Juan Denisd528d272963c
diff --git a/agent/internal/agent/agent.go b/agent/internal/agent/agent.go
index 9d7a1721..e9b59402 100644
--- a/agent/internal/agent/agent.go
+++ b/agent/internal/agent/agent.go
@@ -664,6 +664,11 @@ func (a *Agent) sendCapabilities() {
SystemdJSON: caps.SystemdJSON,
ProbedAt: caps.ProbedAt,
}
+ a.log.Info("Sending capabilities to panel",
+ "sudo", caps.Sudo,
+ "cap_count", len(caps.Capabilities),
+ "runtime_count", len(caps.Runtimes),
+ )
if err := a.ws.Send(msg); err != nil {
a.log.Warn("Failed to send capabilities", "error", err)
return
diff --git a/backend/app/api/agent_poll.py b/backend/app/api/agent_poll.py
index de0829f2..243b4608 100644
--- a/backend/app/api/agent_poll.py
+++ b/backend/app/api/agent_poll.py
@@ -106,6 +106,19 @@ def poll():
sysinfo = body.get('system_info')
caps = body.get('capabilities')
+ # Diagnostic: log whenever the agent ships state. Helps debug the
+ # "panel shows N/A" failure mode where the agent is connected but
+ # the periodic resend isn't actually reaching us.
+ import logging as _logging
+ _log = _logging.getLogger(__name__)
+ _log.info(
+ "agent /poll from %s: metrics=%s sysinfo_keys=%s caps_keys=%s",
+ agent.server_id,
+ bool(metrics),
+ list(sysinfo.keys()) if isinstance(sysinfo, dict) else None,
+ list(caps.keys()) if isinstance(caps, dict) else None,
+ )
+
agent_registry.update_heartbeat(agent.server_id, metrics)
if sysinfo:
agent_registry.update_system_info(agent.server_id, sysinfo)
diff --git a/backend/app/models/server.py b/backend/app/models/server.py
index cd107fe5..8983fd2f 100644
--- a/backend/app/models/server.py
+++ b/backend/app/models/server.py
@@ -63,6 +63,18 @@ class Server(db.Model):
}
SYSTEM_READ_ACTIONS = {'metrics', 'info', 'processes'}
+ # Control-plane actions that aren't gated by per-server permissions:
+ # the panel issues these to discover state or refresh metadata, not
+ # to mutate the host. Without this list, an agent with the
+ # 'docker_manager' profile (no 'agent:*' grant) would 403 on the
+ # Refresh button in the System Status card. Authentication still
+ # happens at the JWT layer; this only short-circuits the per-server
+ # ACL.
+ CONTROL_PLANE_ACTIONS = {
+ 'agent:recapabilities',
+ 'agent:update',
+ }
+
id = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
# Basic Info
@@ -268,6 +280,11 @@ class Server(db.Model):
def has_permission(self, scope):
"""Check if server/agent has a specific permission scope"""
+ # Control-plane actions (agent:recapabilities, agent:update) are
+ # not gated — they're issued by the panel to discover state and
+ # refresh metadata. Authentication is enforced at the JWT layer.
+ if scope in self.CONTROL_PLANE_ACTIONS:
+ return True
if not self.permissions:
return False
if '*' in self.permissions: