diff --git a/.github/workflows/nexjast-ci.yml b/.github/workflows/nexjast-ci.yml index 01db1440..58fabb97 100644 --- a/.github/workflows/nexjast-ci.yml +++ b/.github/workflows/nexjast-ci.yml @@ -103,6 +103,13 @@ jobs: shell: bash run: python3 tools/ci/verify_no_remote_asset_delete_09312.py + - name: Verify LevelUpload precedence for UDP and CAPS + shell: bash + run: | + set -euo pipefail + python3 tools/ci/verify_asset_upload_level_consistency.py + dotnet run --configuration Release --project tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj + - name: Verify runtime secrets are not committed shell: bash run: python3 tools/ci/verify_no_plaintext_runtime_secrets.py diff --git a/OpenSim/Framework/AssetUploadLevelPolicy.cs b/OpenSim/Framework/AssetUploadLevelPolicy.cs new file mode 100644 index 00000000..397fbcf8 --- /dev/null +++ b/OpenSim/Framework/AssetUploadLevelPolicy.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the original license notices + * are retained. See CONTRIBUTORS.TXT. + */ + +using Nini.Config; + +namespace OpenSim.Framework +{ + /// + /// Reads the simulator's minimum user level for permanent asset uploads. + /// [Permissions] is the documented owner of LevelUpload. Keep [Startup] + /// as a backwards-compatible fallback for installations using older INIs. + /// An explicit zero in [Permissions] MUST override an older nonzero value. + /// + public static class AssetUploadLevelPolicy + { + public static int Resolve(IConfigSource config) + { + if (config == null) + return 0; + + IConfig permissions = config.Configs["Permissions"]; + if (permissions != null && permissions.Contains("LevelUpload")) + return permissions.GetInt("LevelUpload", 0); + + IConfig startup = config.Configs["Startup"]; + return startup != null ? startup.GetInt("LevelUpload", 0) : 0; + } + } +} diff --git a/OpenSim/Framework/OpenSim.Framework.csproj b/OpenSim/Framework/OpenSim.Framework.csproj index dd4ad247..5d09c7a1 100644 --- a/OpenSim/Framework/OpenSim.Framework.csproj +++ b/OpenSim/Framework/OpenSim.Framework.csproj @@ -61,6 +61,7 @@ AnyCPU + Code diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs index 333b070f..90520fb7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs @@ -100,16 +100,8 @@ namespace OpenSim.Region.ClientStack.Linden IConfigSource config = m_Scene.Config; if (config is not null) { - IConfig sconfig = config.Configs["Startup"]; - if (sconfig is not null) - ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0); - - if (ConfigOptions.levelUpload == 0) - { - IConfig pconfig = config.Configs["Permissions"]; - if (pconfig is not null) - ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0); - } + // Same minimum upload user level as UDP asset transactions. + ConfigOptions.levelUpload = AssetUploadLevelPolicy.Resolve(config); IConfig appearanceConfig = config.Configs["Appearance"]; if (appearanceConfig is not null) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index ba44bd10..7a0a5391 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -58,11 +58,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction public void Initialise(IConfigSource source) { - IConfig sconfig = source.Configs["Startup"]; - if (sconfig != null) - { - m_levelUpload = sconfig.GetInt("LevelUpload", 0); - } + // Shared with CAPS: [Permissions] takes priority over legacy [Startup]. + m_levelUpload = AssetUploadLevelPolicy.Resolve(source); } public void AddRegion(Scene scene) diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 02b6aad4..aacd180d 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -644,7 +644,10 @@ ; Disabled by default ; simple_build_permissions = False - ; Minimum user level required to upload assets + ; Minimum UserLevel for normal texture, sound, animation and mesh uploads. + ; Applies to both UDP asset transactions and viewer CAPS uploads. + ; Set this under [Permissions] in OpenSim.ini (default: 0). + ; [Startup] LevelUpload is recognized only as a legacy fallback. ;LevelUpload = 0 [RegionReady] @@ -1054,8 +1057,8 @@ ; default is true AllowMeshUpload = true - ; Minimum user level required to upload meshes - ;LevelUpload = 0 + ; Mesh uploads use [Permissions] LevelUpload (see above). + ; A separate [Mesh] LevelUpload is NOT implemented. ; support meshes on physics ;UseMeshiesPhysicsMesh = true diff --git a/doc/OpenGenesisLINK/LEVELUPLOAD_CONFIGURATION_FIX.md b/doc/OpenGenesisLINK/LEVELUPLOAD_CONFIGURATION_FIX.md new file mode 100644 index 00000000..bdedb491 --- /dev/null +++ b/doc/OpenGenesisLINK/LEVELUPLOAD_CONFIGURATION_FIX.md @@ -0,0 +1,58 @@ +# OGL Asset Upload: UserLevel-Schwelle (`LevelUpload`) + +## Korrektur + +Im bisherigen Code las `AssetTransactionModule` die Upload-Schwelle nur aus +`[Startup]`; der moderne Viewer-CAPS-Pfad (`BunchOfCapsModule`) +verwendete `[Startup]` und nur bei Wert `0` einen Fallback auf +`[Permissions]`. Der dokumentierte Wert in `[Permissions]` schützte +klassische UDP-Uploads deshalb nicht zuverlässig. + +Beide Transportwege verwenden jetzt +`OpenSim.Framework.AssetUploadLevelPolicy.Resolve` mit einheitlicher +Reihenfolge: + +1. Ist `LevelUpload` in `[Permissions]` ausdrücklich gesetzt, + gilt genau dieser Wert (auch `0`). +2. Sonst wird ein vorhandener `[Startup] LevelUpload`-Wert verwendet + (Abwärtskompatibilität mit älteren Installationen). +3. Ohne Einstellung gilt weiterhin `0`. + +## Beispiel für die Simulator-OpenSim.ini + +```ini +[Permissions] + LevelUpload = 200 +``` + +`0` erlaubt gewöhnlichen Usern die von dieser Regel erfassten Uploads; +`200` verlangt `UserLevel >= 200`. Änderungen greifen nach einem +Neustart des jeweiligen **Simulators**; ein reiner ROBUST-Neustart +reicht nicht. + +**Wichtig:** Das ist eine **Upload-Schwelle und kein globales Asset-Schreibverbot**. +Die bisherigen Prüfungen betreffen im UDP-Pfad normale, nicht temporäre +Texturen, TGA-Texturen, Sounds und Animationen. Im Viewer-CAPS-Pfad +werden Texturen, Sounds, Animationen und Mesh beim Upload-Request +kontrolliert. Andere Upload- und Update-Wege (beispielsweise bestimmte +Skript-, Notizkarten-, Bekleidungs-/Bodypart-Updates, temporäre Assets, +administrative Imports und serviceinterne Asset-Schreibzugriffe) werden +durch `LevelUpload` **nicht durchgängig** gesperrt. Eine vollständige +Upload-Policy erfordert gesonderte, serverseitige Autorisierung für +alle relevanten Pfade. + +Eine eigenständige `[Mesh] LevelUpload`-Schwelle wird nicht +ausgewertet; die frühere missverständliche Kommentarzeile in +`OpenSimDefaults.ini` wurde berichtigt. Mesh nutzt denselben +`[Permissions] LevelUpload` wie die anderen genannten CAPS-Uploads. + +## Tests + +```bash +python3 tools/ci/verify_asset_upload_level_consistency.py +dotnet run -c Release --project tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj +``` + +Die Tests prüfen die gemeinsame Verwendung im UDP- und CAPS-Modul, +fehlen-de Werte, `[Startup]`-Fallback, `[Permissions]`-Vorrang, +und ein ausdrücklich gesetztes `[Permissions] LevelUpload = 0`. diff --git a/tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj b/tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj new file mode 100644 index 00000000..e47450b1 --- /dev/null +++ b/tools/ci/AssetUploadLevelRegression/AssetUploadLevelRegression.csproj @@ -0,0 +1,16 @@ + + + Exe + net8.0 + disable + disable + false + + + + ../../../bin/Nini.dll + True + + + + diff --git a/tools/ci/AssetUploadLevelRegression/Program.cs b/tools/ci/AssetUploadLevelRegression/Program.cs new file mode 100644 index 00000000..091fdfa0 --- /dev/null +++ b/tools/ci/AssetUploadLevelRegression/Program.cs @@ -0,0 +1,61 @@ +// Upload Level configuration contract shared by UDP and viewer CAPS. +using System; +using Nini.Config; +using OpenSim.Framework; + +internal static class Program +{ + private static int checks; + + private static void Check(int expected, IConfigSource source, string description) + { + checks++; + int actual = AssetUploadLevelPolicy.Resolve(source); + if (expected != actual) + throw new Exception(description + ": expected " + expected + ", got " + actual); + } + + public static int Main() + { + try + { + Check(0, null, "No configuration"); + Check(0, new IniConfigSource(), "No sections"); + + IniConfigSource startupOnly = new IniConfigSource(); + startupOnly.AddConfig("Startup").Set("LevelUpload", 150); + Check(150, startupOnly, "Legacy Startup setting"); + + IniConfigSource permissionsOnly = new IniConfigSource(); + permissionsOnly.AddConfig("Permissions").Set("LevelUpload", 200); + Check(200, permissionsOnly, "Documented Permissions setting"); + + IniConfigSource permissionsWin = new IniConfigSource(); + permissionsWin.AddConfig("Startup").Set("LevelUpload", 100); + permissionsWin.AddConfig("Permissions").Set("LevelUpload", 200); + Check(200, permissionsWin, "Permissions overrides Startup"); + + IniConfigSource explicitZero = new IniConfigSource(); + explicitZero.AddConfig("Startup").Set("LevelUpload", 200); + explicitZero.AddConfig("Permissions").Set("LevelUpload", 0); + Check(0, explicitZero, "Explicit Permissions zero must override Startup"); + + IniConfigSource missingKey = new IniConfigSource(); + missingKey.AddConfig("Startup").Set("LevelUpload", 50); + missingKey.AddConfig("Permissions").Set("serverside_object_permissions", true); + Check(50, missingKey, "Empty Permissions falls back to Startup"); + + IniConfigSource mesh = new IniConfigSource(); + mesh.AddConfig("Mesh").Set("LevelUpload", 250); + Check(0, mesh, "Mesh is not a separate LevelUpload configuration section"); + + Console.WriteLine("Asset upload policy: PASS (" + checks + " checks)"); + return 0; + } + catch (Exception ex) + { + Console.Error.WriteLine("Asset upload policy FAIL: " + ex); + return 1; + } + } +} diff --git a/tools/ci/verify_asset_upload_level_consistency.py b/tools/ci/verify_asset_upload_level_consistency.py new file mode 100644 index 00000000..6cbdd865 --- /dev/null +++ b/tools/ci/verify_asset_upload_level_consistency.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +"""Guard both uploader transports against divergent LevelUpload configuration.""" +from pathlib import Path + +root = Path(__file__).resolve().parents[2] +read = lambda path: (root / path).read_text(encoding="utf-8") + +helper = read("OpenSim/Framework/AssetUploadLevelPolicy.cs") +udp = read("OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs") +caps_module = read("OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs") +caps = read("OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs") +framework_project = read("OpenSim/Framework/OpenSim.Framework.csproj") +defaults = read("bin/OpenSimDefaults.ini") + +assert '