aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-09-07 19:57:44 +0100
committerJustin Clark-Casey (justincc)2009-09-07 19:57:44 +0100
commitfa1d79533e22266f8ee7f1aa4d93a3f7fba0e230 (patch)
tree07980bd5c2eac7e0a31107f7dbe8a73d4cc5e8a9 /OpenSim/Region/CoreModules
parentmake oar module logging a little less noisy (diff)
downloadopensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.zip
opensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.tar.gz
opensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.tar.bz2
opensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.tar.xz
Only allow iar load/save if user is logged in to the region simulator
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs128
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs10
2 files changed, 110 insertions, 28 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 3869de2..2340fad 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -51,6 +51,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
51 public string Name { get { return "Inventory Archiver Module"; } } 51 public string Name { get { return "Inventory Archiver Module"; } }
52 52
53 public bool IsSharedModule { get { return true; } } 53 public bool IsSharedModule { get { return true; } }
54
55 /// <value>
56 /// Enable or disable checking whether the iar user is actually logged in
57 /// </value>
58 public bool DisablePresenceChecks { get; set; }
54 59
55 public event InventoryArchiveSaved OnInventoryArchiveSaved; 60 public event InventoryArchiveSaved OnInventoryArchiveSaved;
56 61
@@ -70,6 +75,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
70 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 75 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
71 private Scene m_aScene; 76 private Scene m_aScene;
72 77
78 public InventoryArchiverModule() {}
79
80 public InventoryArchiverModule(bool disablePresenceChecks)
81 {
82 DisablePresenceChecks = disablePresenceChecks;
83 }
84
73 public void Initialise(Scene scene, IConfigSource source) 85 public void Initialise(Scene scene, IConfigSource source)
74 { 86 {
75 if (m_scenes.Count == 0) 87 if (m_scenes.Count == 0)
@@ -109,29 +121,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
109 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); 121 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
110 } 122 }
111 123
112 public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) 124 public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream)
113 { 125 {
114 if (m_scenes.Count > 0) 126 if (m_scenes.Count > 0)
115 { 127 {
116 CachedUserInfo userInfo = GetUserInfo(firstName, lastName); 128 CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
117 129
118 if (userInfo != null) 130 if (userInfo != null)
119 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); 131 {
120 } 132 if (CheckPresence(userInfo.UserProfile.ID))
133 {
134 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
135 return true;
136 }
137 else
138 {
139 m_log.ErrorFormat(
140 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
141 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
142 }
143 }
144 }
145
146 return false;
121 } 147 }
122 148
123 public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) 149 public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath)
124 { 150 {
125 if (m_scenes.Count > 0) 151 if (m_scenes.Count > 0)
126 { 152 {
127 CachedUserInfo userInfo = GetUserInfo(firstName, lastName); 153 CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
128 154
129 if (userInfo != null) 155 if (userInfo != null)
130 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); 156 {
131 } 157 if (CheckPresence(userInfo.UserProfile.ID))
158 {
159 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
160 return true;
161 }
162 else
163 {
164 m_log.ErrorFormat(
165 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
166 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
167 }
168 }
169 }
170
171 return false;
132 } 172 }
133 173
134 public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) 174 public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream)
135 { 175 {
136 if (m_scenes.Count > 0) 176 if (m_scenes.Count > 0)
137 { 177 {
@@ -139,14 +179,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
139 179
140 if (userInfo != null) 180 if (userInfo != null)
141 { 181 {
142 InventoryArchiveReadRequest request = 182 if (CheckPresence(userInfo.UserProfile.ID))
143 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); 183 {
144 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 184 InventoryArchiveReadRequest request =
185 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream);
186 UpdateClientWithLoadedNodes(userInfo, request.Execute());
187
188 return true;
189 }
190 else
191 {
192 m_log.ErrorFormat(
193 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
194 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
195 }
145 } 196 }
146 } 197 }
198
199 return false;
147 } 200 }
148 201
149 public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) 202 public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath)
150 { 203 {
151 if (m_scenes.Count > 0) 204 if (m_scenes.Count > 0)
152 { 205 {
@@ -154,11 +207,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
154 207
155 if (userInfo != null) 208 if (userInfo != null)
156 { 209 {
157 InventoryArchiveReadRequest request = 210 if (CheckPresence(userInfo.UserProfile.ID))
158 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); 211 {
159 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 212 InventoryArchiveReadRequest request =
160 } 213 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath);
161 } 214 UpdateClientWithLoadedNodes(userInfo, request.Execute());
215
216 return true;
217 }
218 else
219 {
220 m_log.ErrorFormat(
221 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
222 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
223 }
224 }
225 }
226
227 return false;
162 } 228 }
163 229
164 /// <summary> 230 /// <summary>
@@ -183,11 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
183 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", 249 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
184 loadPath, invPath, firstName, lastName); 250 loadPath, invPath, firstName, lastName);
185 251
186 DearchiveInventory(firstName, lastName, invPath, loadPath); 252 if (DearchiveInventory(firstName, lastName, invPath, loadPath))
187 253 m_log.InfoFormat(
188 m_log.InfoFormat( 254 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}",
189 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", 255 loadPath, firstName, lastName);
190 loadPath, firstName, lastName);
191 } 256 }
192 257
193 /// <summary> 258 /// <summary>
@@ -291,5 +356,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
291 } 356 }
292 } 357 }
293 } 358 }
359
360 /// <summary>
361 /// Check if the given user is present in any of the scenes.
362 /// </summary>
363 /// <param name="userId">The user to check</param>
364 /// <returns>true if the user is in any of the scenes, false otherwise</returns>
365 protected bool CheckPresence(UUID userId)
366 {
367 if (DisablePresenceChecks)
368 return true;
369
370 foreach (Scene scene in m_scenes.Values)
371 {
372 if (scene.GetScenePresence(userId) != null)
373 return true;
374 }
375
376 return false;
377 }
294 } 378 }
295} 379}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index c21adef..d579a81 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
83 TestHelper.InMethod(); 83 TestHelper.InMethod();
84 log4net.Config.XmlConfigurator.Configure(); 84 log4net.Config.XmlConfigurator.Configure();
85 85
86 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 86 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
87 87
88 Scene scene = SceneSetupHelpers.SetupScene("Inventory"); 88 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
89 SceneSetupHelpers.SetupSceneModules(scene, archiverModule); 89 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
@@ -100,9 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
100 cm, userFirstName, userLastName, userId, InventoryReceived); 100 cm, userFirstName, userLastName, userId, InventoryReceived);
101 Monitor.Wait(this, 60000); 101 Monitor.Wait(this, 60000);
102 } 102 }
103 103
104 Console.WriteLine("here");
105
106 // Create asset 104 // Create asset
107 SceneObjectGroup object1; 105 SceneObjectGroup object1;
108 SceneObjectPart part1; 106 SceneObjectPart part1;
@@ -248,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
248 246
249 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 247 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
250 SerialiserModule serialiserModule = new SerialiserModule(); 248 SerialiserModule serialiserModule = new SerialiserModule();
251 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 249 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
252 250
253 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 251 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
254 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 252 Scene scene = SceneSetupHelpers.SetupScene("inventory");
@@ -318,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
318 316
319 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 317 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
320 SerialiserModule serialiserModule = new SerialiserModule(); 318 SerialiserModule serialiserModule = new SerialiserModule();
321 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 319 InventoryArchiverModule archiverModule = new InventoryArchiverModule(true);
322 320
323 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 321 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
324 Scene scene = SceneSetupHelpers.SetupScene(); 322 Scene scene = SceneSetupHelpers.SetupScene();