aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-12-29 16:56:48 +0000
committerJustin Clarke Casey2008-12-29 16:56:48 +0000
commit266d0fbaaeac0dad06da98ceda8d19b8f3d732d6 (patch)
tree45f2ad93db485b5144c3fc86662891432c3a877a /OpenSim/Framework
parentRevamp the return logic to close a privilege escalation loophole. (diff)
downloadopensim-SC-266d0fbaaeac0dad06da98ceda8d19b8f3d732d6.zip
opensim-SC-266d0fbaaeac0dad06da98ceda8d19b8f3d732d6.tar.gz
opensim-SC-266d0fbaaeac0dad06da98ceda8d19b8f3d732d6.tar.bz2
opensim-SC-266d0fbaaeac0dad06da98ceda8d19b8f3d732d6.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=2927 with some changes
* This allows configuration of the assetset and library control file paths to be other than ./inventory/Libraries.xml and ./assets/AssetSets.xml * This is controlled via the LibrariesXMLFile and AssetSetsXMLFile configuration settings in [StandAlone] in OpenSim.ini (in standalone) and via the user and asset config xml files for grid mode * Thanks to SirKimba for the patch
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AssetConfig.cs10
-rw-r--r--OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs14
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs27
-rw-r--r--OpenSim/Framework/ConfigSettings.cs25
-rw-r--r--OpenSim/Framework/IAssetLoader.cs1
-rw-r--r--OpenSim/Framework/UserConfig.cs11
7 files changed, 63 insertions, 29 deletions
diff --git a/OpenSim/Framework/AssetConfig.cs b/OpenSim/Framework/AssetConfig.cs
index 9ae98d7..cc0217f 100644
--- a/OpenSim/Framework/AssetConfig.cs
+++ b/OpenSim/Framework/AssetConfig.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Framework
40 public string DatabaseConnect = String.Empty; 40 public string DatabaseConnect = String.Empty;
41 public string DatabaseProvider = String.Empty; 41 public string DatabaseProvider = String.Empty;
42 public uint HttpPort = DefaultHttpPort; 42 public uint HttpPort = DefaultHttpPort;
43 public string AssetSetsLocation = string.Empty;
43 44
44 public AssetConfig(string description, string filename) 45 public AssetConfig(string description, string filename)
45 { 46 {
@@ -58,6 +59,10 @@ namespace OpenSim.Framework
58 59
59 configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 60 configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
60 "Http Listener port", DefaultHttpPort.ToString(), false); 61 "Http Listener port", DefaultHttpPort.ToString(), false);
62
63 configMember.addConfigurationOption("assetset_location", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
64 "Location of 'AssetSets.xml'",
65 string.Format(".{0}assets{0}AssetSets.xml", System.IO.Path.DirectorySeparatorChar), false);
61 } 66 }
62 67
63 public bool handleIncomingConfiguration(string configuration_key, object configuration_result) 68 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@@ -70,6 +75,9 @@ namespace OpenSim.Framework
70 case "database_connect": 75 case "database_connect":
71 DatabaseConnect = (string) configuration_result; 76 DatabaseConnect = (string) configuration_result;
72 break; 77 break;
78 case "assetset_location":
79 AssetSetsLocation = (string) configuration_result;
80 break;
73 case "http_port": 81 case "http_port":
74 HttpPort = (uint) configuration_result; 82 HttpPort = (uint) configuration_result;
75 break; 83 break;
@@ -78,4 +86,4 @@ namespace OpenSim.Framework
78 return true; 86 return true;
79 } 87 }
80 } 88 }
81} \ No newline at end of file 89}
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
index 6fe9fb4..9d0f697 100644
--- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
+++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
@@ -86,12 +86,6 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
86 } 86 }
87 } 87 }
88 88
89 public void ForEachDefaultXmlAsset(Action<AssetBase> action)
90 {
91 string assetSetFilename = Path.Combine(Util.assetsDir(), "AssetSets.xml");
92
93 ForEachDefaultXmlAsset(assetSetFilename, action);
94 }
95 89
96 public void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action) 90 public void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action)
97 { 91 {
@@ -99,16 +93,18 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
99 if (File.Exists(assetSetFilename)) 93 if (File.Exists(assetSetFilename))
100 { 94 {
101 string assetSetPath = "ERROR"; 95 string assetSetPath = "ERROR";
102 96 string assetRootPath = "";
103 try 97 try
104 { 98 {
105 XmlConfigSource source = new XmlConfigSource(assetSetFilename); 99 XmlConfigSource source = new XmlConfigSource(assetSetFilename);
100 assetRootPath = Path.GetFullPath(source.SavePath);
101 assetRootPath = Path.GetDirectoryName(assetRootPath);
106 102
107 for (int i = 0; i < source.Configs.Count; i++) 103 for (int i = 0; i < source.Configs.Count; i++)
108 { 104 {
109 assetSetPath = source.Configs[i].GetString("file", String.Empty); 105 assetSetPath = source.Configs[i].GetString("file", String.Empty);
110 106
111 LoadXmlAssetSet(Path.Combine(Util.assetsDir(), assetSetPath), assets); 107 LoadXmlAssetSet(Path.Combine(assetRootPath, assetSetPath), assets);
112 } 108 }
113 } 109 }
114 catch (XmlException e) 110 catch (XmlException e)
@@ -118,7 +114,7 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
118 } 114 }
119 else 115 else
120 { 116 {
121 m_log.Error("[ASSETS]: Asset set control file assets/AssetSets.xml does not exist! No assets loaded."); 117 m_log.ErrorFormat("[ASSETS]: Asset set control file {0} does not exist! No assets loaded.", assetSetFilename);
122 } 118 }
123 119
124 assets.ForEach(action); 120 assets.ForEach(action);
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index a289fb7..137bde9 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -106,11 +106,11 @@ namespace OpenSim.Framework.Communications.Cache
106 } 106 }
107 } 107 }
108 108
109 public virtual void LoadDefaultAssets() 109 public virtual void LoadDefaultAssets(string pAssetSetsXml)
110 { 110 {
111 m_log.Info("[ASSET SERVER]: Setting up asset database"); 111 m_log.Info("[ASSET SERVER]: Setting up asset database");
112 112
113 assetLoader.ForEachDefaultXmlAsset(StoreAsset); 113 assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset);
114 } 114 }
115 115
116 public AssetServerBase() 116 public AssetServerBase()
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
index cf3490b..0b05adf 100644
--- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
+++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
@@ -52,11 +52,9 @@ namespace OpenSim.Framework.Communications.Cache
52 /// </summary> 52 /// </summary>
53 protected Dictionary<UUID, InventoryFolderImpl> libraryFolders 53 protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
54 = new Dictionary<UUID, InventoryFolderImpl>(); 54 = new Dictionary<UUID, InventoryFolderImpl>();
55 55
56 public LibraryRootFolder() 56 public LibraryRootFolder(string pLibrariesLocation)
57 { 57 {
58 m_log.Info("[LIBRARY INVENTORY]: Loading library inventory");
59
60 Owner = libOwner; 58 Owner = libOwner;
61 ID = new UUID("00000112-000f-0000-0000-000100bba000"); 59 ID = new UUID("00000112-000f-0000-0000-000100bba000");
62 Name = "OpenSim Library"; 60 Name = "OpenSim Library";
@@ -66,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache
66 64
67 libraryFolders.Add(ID, this); 65 libraryFolders.Add(ID, this);
68 66
69 LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); 67 LoadLibraries(pLibrariesLocation);
70 } 68 }
71 69
72 public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, 70 public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description,
@@ -96,9 +94,7 @@ namespace OpenSim.Framework.Communications.Cache
96 /// <param name="assets"></param> 94 /// <param name="assets"></param>
97 protected void LoadLibraries(string librariesControlPath) 95 protected void LoadLibraries(string librariesControlPath)
98 { 96 {
99 m_log.InfoFormat( 97 m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath);
100 "[LIBRARY INVENTORY]: Loading libraries control file {0}", librariesControlPath);
101
102 LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); 98 LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
103 } 99 }
104 100
@@ -106,17 +102,18 @@ namespace OpenSim.Framework.Communications.Cache
106 /// Read a library set from config 102 /// Read a library set from config
107 /// </summary> 103 /// </summary>
108 /// <param name="config"></param> 104 /// <param name="config"></param>
109 protected void ReadLibraryFromConfig(IConfig config) 105 protected void ReadLibraryFromConfig(IConfig config, string path)
110 { 106 {
107 string basePath = Path.GetDirectoryName(path);
111 string foldersPath 108 string foldersPath
112 = Path.Combine( 109 = Path.Combine(
113 Util.inventoryDir(), config.GetString("foldersFile", String.Empty)); 110 basePath, config.GetString("foldersFile", String.Empty));
114 111
115 LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); 112 LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
116 113
117 string itemsPath 114 string itemsPath
118 = Path.Combine( 115 = Path.Combine(
119 Util.inventoryDir(), config.GetString("itemsFile", String.Empty)); 116 basePath, config.GetString("itemsFile", String.Empty));
120 117
121 LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); 118 LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
122 } 119 }
@@ -125,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
125 /// Read a library inventory folder from a loaded configuration 122 /// Read a library inventory folder from a loaded configuration
126 /// </summary> 123 /// </summary>
127 /// <param name="source"></param> 124 /// <param name="source"></param>
128 private void ReadFolderFromConfig(IConfig config) 125 private void ReadFolderFromConfig(IConfig config, string path)
129 { 126 {
130 InventoryFolderImpl folderInfo = new InventoryFolderImpl(); 127 InventoryFolderImpl folderInfo = new InventoryFolderImpl();
131 128
@@ -158,7 +155,7 @@ namespace OpenSim.Framework.Communications.Cache
158 /// Read a library inventory item metadata from a loaded configuration 155 /// Read a library inventory item metadata from a loaded configuration
159 /// </summary> 156 /// </summary>
160 /// <param name="source"></param> 157 /// <param name="source"></param>
161 private void ReadItemFromConfig(IConfig config) 158 private void ReadItemFromConfig(IConfig config, string path)
162 { 159 {
163 InventoryItemBase item = new InventoryItemBase(); 160 InventoryItemBase item = new InventoryItemBase();
164 item.Owner = libOwner; 161 item.Owner = libOwner;
@@ -195,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache
195 } 192 }
196 } 193 }
197 194
198 private delegate void ConfigAction(IConfig config); 195 private delegate void ConfigAction(IConfig config, string path);
199 196
200 /// <summary> 197 /// <summary>
201 /// Load the given configuration at a path and perform an action on each Config contained within it 198 /// Load the given configuration at a path and perform an action on each Config contained within it
@@ -213,7 +210,7 @@ namespace OpenSim.Framework.Communications.Cache
213 210
214 for (int i = 0; i < source.Configs.Count; i++) 211 for (int i = 0; i < source.Configs.Count; i++)
215 { 212 {
216 action(source.Configs[i]); 213 action(source.Configs[i], path);
217 } 214 }
218 } 215 }
219 catch (XmlException e) 216 catch (XmlException e)
diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs
index 02b8465..3d66311 100644
--- a/OpenSim/Framework/ConfigSettings.cs
+++ b/OpenSim/Framework/ConfigSettings.cs
@@ -179,5 +179,30 @@ namespace OpenSim.Framework
179 get { return m_dumpAssetsToFile; } 179 get { return m_dumpAssetsToFile; }
180 set { m_dumpAssetsToFile = value; } 180 set { m_dumpAssetsToFile = value; }
181 } 181 }
182
183 protected string m_librariesXMLFile;
184 public string LibrariesXMLFile
185 {
186 get
187 {
188 return m_librariesXMLFile;
189 }
190 set
191 {
192 m_librariesXMLFile = value;
193 }
194 }
195 protected string m_assetSetsXMLFile;
196 public string AssetSetsXMLFile
197 {
198 get
199 {
200 return m_assetSetsXMLFile;
201 }
202 set
203 {
204 m_assetSetsXMLFile = value;
205 }
206 }
182 } 207 }
183} 208}
diff --git a/OpenSim/Framework/IAssetLoader.cs b/OpenSim/Framework/IAssetLoader.cs
index 6aa71d3..3ecc051 100644
--- a/OpenSim/Framework/IAssetLoader.cs
+++ b/OpenSim/Framework/IAssetLoader.cs
@@ -31,7 +31,6 @@ namespace OpenSim.Framework
31{ 31{
32 public interface IAssetLoader 32 public interface IAssetLoader
33 { 33 {
34 void ForEachDefaultXmlAsset(Action<AssetBase> action);
35 void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action); 34 void ForEachDefaultXmlAsset(string assetSetFilename, Action<AssetBase> action);
36 } 35 }
37} \ No newline at end of file 36} \ No newline at end of file
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs
index 87ba271..cc048b7 100644
--- a/OpenSim/Framework/UserConfig.cs
+++ b/OpenSim/Framework/UserConfig.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Framework
47 public uint HttpPort = DefaultHttpPort; 47 public uint HttpPort = DefaultHttpPort;
48 public bool HttpSSL = DefaultHttpSSL; 48 public bool HttpSSL = DefaultHttpSSL;
49 public uint DefaultUserLevel = 0; 49 public uint DefaultUserLevel = 0;
50 public string LibraryXmlfile = "";
50 51
51 private Uri m_inventoryUrl; 52 private Uri m_inventoryUrl;
52 53
@@ -109,6 +110,11 @@ namespace OpenSim.Framework
109 "Default Inventory Server URI", 110 "Default Inventory Server URI",
110 "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/", 111 "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/",
111 false); 112 false);
113 configMember.addConfigurationOption("library_location",
114 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
115 "Path to library control file",
116 string.Format(".{0}inventory{0}Libraries.xml", System.IO.Path.DirectorySeparatorChar), false);
117
112 configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, 118 configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
113 "DLL for database provider", "OpenSim.Data.MySQL.dll", false); 119 "DLL for database provider", "OpenSim.Data.MySQL.dll", false);
114 configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING, 120 configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
@@ -173,7 +179,10 @@ namespace OpenSim.Framework
173 179
174 case "default_loginLevel": 180 case "default_loginLevel":
175 DefaultUserLevel = (uint)configuration_result; 181 DefaultUserLevel = (uint)configuration_result;
176 break; 182 break;
183 case "library_location":
184 LibraryXmlfile = (string)configuration_result;
185 break;
177 } 186 }
178 187
179 return true; 188 return true;