From 62cc8dc69cd44a93d543d7c07745a97aa45839c1 Mon Sep 17 00:00:00 2001 From: "OpenGenesis (MPL 2.0)" <153564363+opengenesislink@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:29:59 +0100 Subject: [PATCH] fix(gen1): optional SYS.API startup cannot prevent ROBUST boot --- addons/SysApi/SysApiConnector.cs | 44 +++++++++++++++---------- tools/ci/SysApiSmoke/Program.cs | 6 ++++ tools/ci/SysApiSmoke/SysApiSmoke.csproj | 1 + tools/ci/verify_sys_api_foundation.py | 1 + 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/addons/SysApi/SysApiConnector.cs b/addons/SysApi/SysApiConnector.cs index 75f642d1..b1604348 100644 --- a/addons/SysApi/SysApiConnector.cs +++ b/addons/SysApi/SysApiConnector.cs @@ -28,25 +28,33 @@ public sealed class SysApiConnector : ServiceConnector Log.Info("[SYS.API] Disabled by configuration."); return; } - int port = cfg.GetInt("InternalPort", 8851); - if (port is < 1025 or > 65535) - throw new InvalidOperationException("Invalid SysApi internal port"); - string publicOrigin = cfg.GetString("PublicOrigin", "").Trim(); - string secretDirectory = cfg.GetString("SecretDirectory", "/etc/oglwebinterface").Trim(); - if (string.IsNullOrWhiteSpace(secretDirectory) || !Path.IsPathRooted(secretDirectory)) - throw new InvalidOperationException("SysApi secret directory must be absolute"); - lock (Gate) + try { - if (_host != null) return; - var accounts = LoadService(config, "UserAccountService"); - var authentication = LoadService(config, "AuthenticationService"); - if (accounts is null || authentication is null) - throw new InvalidOperationException("SYS.API requires local ROBUST account and authentication services"); - var token = PortalSecretStore.OpenOrCreate(secretDirectory); - var host = new SysApiHost(port, publicOrigin, accounts, authentication, token); - host.Start(); - _host = host; - Log.InfoFormat("[SYS.API] Foundation active on loopback 127.0.0.1:{0}; public TLS proxy port 8850 requires ACME certificate.", port); + int port = cfg.GetInt("InternalPort", 8851); + if (port is < 1025 or > 65535) + throw new InvalidOperationException("Invalid SysApi internal port"); + string publicOrigin = cfg.GetString("PublicOrigin", "").Trim(); + string secretDirectory = cfg.GetString("SecretDirectory", "/etc/oglwebinterface").Trim(); + if (string.IsNullOrWhiteSpace(secretDirectory) || !Path.IsPathRooted(secretDirectory)) + throw new InvalidOperationException("SysApi secret directory must be absolute"); + lock (Gate) + { + if (_host != null) return; + var accounts = LoadService(config, "UserAccountService"); + var authentication = LoadService(config, "AuthenticationService"); + if (accounts is null || authentication is null) + throw new InvalidOperationException("SYS.API requires local ROBUST account and authentication services"); + var token = PortalSecretStore.OpenOrCreate(secretDirectory); + var host = new SysApiHost(port, publicOrigin, accounts, authentication, token); + host.Start(); + _host = host; + Log.InfoFormat("[SYS.API] Foundation active on loopback 127.0.0.1:{0}; public TLS proxy port 8850 requires ACME certificate.", port); + } + } + catch (Exception e) + { + // Never prevent ROBUST/legacy World API startup for an optional SYS.API failure. + Log.Error("[SYS.API] Optional module initialization failed; ROBUST and legacy World API remain available.", e); } } diff --git a/tools/ci/SysApiSmoke/Program.cs b/tools/ci/SysApiSmoke/Program.cs index 0e405753..2f95061d 100644 --- a/tools/ci/SysApiSmoke/Program.cs +++ b/tools/ci/SysApiSmoke/Program.cs @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MPL-2.0 using System.Net; +using Nini.Config; using System.Net.Http; using System.Net.Sockets; using System.Reflection; @@ -11,6 +12,11 @@ using OpenGenesisLINK.SysApi; using OpenSim.Framework; using System.Security.Cryptography; +// Invalid opt-in settings must not crash ROBUST or disable the legacy World API. +var unavailable = new IniConfigSource(); +unavailable.Configs.Add("SysApi").Set("Enabled", "true"); +new SysApiConnector(unavailable, null!, "SysApi"); + var dir = Path.Combine(Path.GetTempPath(), "ogl-sysapi-smoke-" + Guid.NewGuid().ToString("N")); string first = PortalSecretStore.OpenOrCreate(dir); string second = PortalSecretStore.OpenOrCreate(dir); diff --git a/tools/ci/SysApiSmoke/SysApiSmoke.csproj b/tools/ci/SysApiSmoke/SysApiSmoke.csproj index 87d2f0d6..e8dbd1d5 100644 --- a/tools/ci/SysApiSmoke/SysApiSmoke.csproj +++ b/tools/ci/SysApiSmoke/SysApiSmoke.csproj @@ -2,6 +2,7 @@ net10.0Exeenableenable + ../../../bin/Nini.dlltrue ../../../bin/OpenMetaverseTypes.dlltrue \ No newline at end of file diff --git a/tools/ci/verify_sys_api_foundation.py b/tools/ci/verify_sys_api_foundation.py index 68869888..900aaa31 100644 --- a/tools/ci/verify_sys_api_foundation.py +++ b/tools/ci/verify_sys_api_foundation.py @@ -21,6 +21,7 @@ for needle in ('UserLevel < 200', 'Access Denied – Keine Berechtigung', for needle in ('GetBoolean("Enabled", false)', 'IUserAccountService', 'IAuthenticationService', 'PortalSecretStore.OpenOrCreate'): assert needle in auth,needle +assert "Optional module initialization failed" in auth and "catch (Exception e)" in auth for needle in ('FileMode.CreateNew', 'RandomNumberGenerator.GetBytes(64)', 'UnixFileMode.UserRead | UnixFileMode.UserWrite'): assert needle in secret,needle