udp/config: fall back to default_owner when os_info has no owner; log debug

- When os_info arrives with no owner field, apply default_owner from server config
- Stop applying default_owner unconditionally in get_host_access (now deferred to os_info handling)
- os_info plugin logs debug message when injecting owner from client config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-08 08:49:42 -04:00
parent 88a3c09b51
commit b3aa7b585f
3 changed files with 5 additions and 5 deletions
+1
View File
@@ -63,6 +63,7 @@ class OSInfoPlugin(InfoPlugin):
"hbc_type": "full", "hbc_type": "full",
} }
if self.config.get("owner"): if self.config.get("owner"):
self.logger.debug(f"Adding owner from config: {self.config['owner']}")
data["owner"] = self.config["owner"] data["owner"] = self.config["owner"]
# Add Linux-specific distribution info # Add Linux-specific distribution info
+1 -1
View File
@@ -309,7 +309,7 @@ def get_host_access(config, hostname) -> dict:
""" """
host_cfg = get_host_config(config, hostname) host_cfg = get_host_config(config, hostname)
owner = host_cfg.get("owner") or get_default_owner(config) owner = host_cfg.get("owner") # or get_default_owner(config)
managers = host_cfg.get("managers", []) managers = host_cfg.get("managers", [])
if isinstance(managers, str): if isinstance(managers, str):
+3 -4
View File
@@ -372,10 +372,9 @@ def handle_datagram(msg: dict, addr, transport, ctx: dict):
host.add_plugin_data(plugin_name, plugin_data, timestamp=now) host.add_plugin_data(plugin_name, plugin_data, timestamp=now)
# If os_info reports an owner and none is configured server-side, apply it # If os_info reports an owner and none is configured server-side, apply it
if plugin_name == "os_info" and not host.owner: if plugin_name == "os_info":
reported_owner = plugin_data.get("owner") if not host.owner:
if reported_owner: host.owner = plugin_data.get("owner", config_mod.get_default_owner(cfg))
host.owner = reported_owner
if DEBUG > 1: if DEBUG > 1:
print(f"Stored plugin data for {uname}: {plugin_name}") print(f"Stored plugin data for {uname}: {plugin_name}")