From 4317efff6845774f27eb21e979c2e3e6f4d9ab5a Mon Sep 17 00:00:00 2001 From: Alex Hope-O'Connor Date: Thu, 5 Feb 2026 03:40:09 +1000 Subject: [PATCH] Use absolute path for conf-file=; list all config files in UI - EnsureManagedConfigHostedService: write conf-file=/absolute/path so dnsmasq finds the managed file regardless of CWD (e.g. systemd with CWD=/) - Dnsmasq.razor: show Config files (load order) as single list with all paths (main, conf-dir, managed); fallback to Main/Managed when set unavailable --- .../Components/Pages/Dnsmasq.razor | 29 +++++++++++-------- .../EnsureManagedConfigHostedService.cs | 4 ++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/DnsmasqWebUI/Components/Pages/Dnsmasq.razor b/src/DnsmasqWebUI/Components/Pages/Dnsmasq.razor index 7c51ad1..e93e238 100644 --- a/src/DnsmasqWebUI/Components/Pages/Dnsmasq.razor +++ b/src/DnsmasqWebUI/Components/Pages/Dnsmasq.razor @@ -22,16 +22,15 @@ else if (_status != null) {

Service configuration

- - @if (_configSet != null && _configSet.Files?.Count > 0) - { -

Config set (load order):

- @if (_status.ReloadCommandConfigured) { diff --git a/src/DnsmasqWebUI/Services/EnsureManagedConfigHostedService.cs b/src/DnsmasqWebUI/Services/EnsureManagedConfigHostedService.cs index 3161fe2..e949376 100644 --- a/src/DnsmasqWebUI/Services/EnsureManagedConfigHostedService.cs +++ b/src/DnsmasqWebUI/Services/EnsureManagedConfigHostedService.cs @@ -46,7 +46,8 @@ public class EnsureManagedConfigHostedService : IApplicationHostedService var mainDir = Path.GetDirectoryName(mainFull) ?? ""; var managedPath = Path.GetFullPath(set.ManagedFilePath); var managedDir = Path.GetDirectoryName(managedPath) ?? ""; - var confFileLine = "conf-file=" + Path.GetRelativePath(mainDir, managedPath); + // Use absolute path so dnsmasq finds the file regardless of CWD (e.g. systemd may run with CWD=/). + var confFileLine = "conf-file=" + managedPath; var lines = File.Exists(mainFull) ? (await File.ReadAllLinesAsync(mainFull, DnsmasqFileEncoding.Utf8NoBom, cancellationToken)).ToList() @@ -62,6 +63,7 @@ public class EnsureManagedConfigHostedService : IApplicationHostedService var value = trimmed.Length > 10 ? trimmed[10..].Trim() : ""; if (string.IsNullOrEmpty(value)) continue; + // Resolve relative to main config dir; absolute value is used as-is. var resolved = Path.GetFullPath(Path.Combine(mainDir, value)); if (string.Equals(resolved, managedPath, StringComparison.Ordinal)) lines.RemoveAt(i);