fix(gen1): optional SYS.API startup cannot prevent ROBUST boot
This commit is contained in:
1 parent
d8b4b439d7
commit
62cc8dc69c
4 files changed
+34
-18
No files matched your search
@@ -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<IUserAccountService>(config, "UserAccountService");
|
||||
var authentication = LoadService<IAuthenticationService>(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<IUserAccountService>(config, "UserAccountService");
|
||||
var authentication = LoadService<IAuthenticationService>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<PropertyGroup><TargetFramework>net10.0</TargetFramework><OutputType>Exe</OutputType><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../addons/SysApi/sys.api.csproj"/>
|
||||
<Reference Include="Nini"><HintPath>../../../bin/Nini.dll</HintPath><Private>true</Private></Reference>
|
||||
<Reference Include="OpenMetaverseTypes"><HintPath>../../../bin/OpenMetaverseTypes.dll</HintPath><Private>true</Private></Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user