aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-01-28 02:21:41 +0000
committerJustin Clark-Casey (justincc)2012-01-28 02:21:41 +0000
commit154ba0124aaf0836ee50bce81a3441be6d11f06a (patch)
treee9b192cf4b5dec5aefcc0b1e823b509353739ffc
parentRemove accidental /user postfix from HomeURI in [HGInventoryAccessModule] in ... (diff)
downloadopensim-SC-154ba0124aaf0836ee50bce81a3441be6d11f06a.zip
opensim-SC-154ba0124aaf0836ee50bce81a3441be6d11f06a.tar.gz
opensim-SC-154ba0124aaf0836ee50bce81a3441be6d11f06a.tar.bz2
opensim-SC-154ba0124aaf0836ee50bce81a3441be6d11f06a.tar.xz
Add experimental --publish option to "save oar" so that OARs reloaded to the same grid don't have the publisher as owner.
-rw-r--r--OpenSim/Region/Application/OpenSim.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs83
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs20
7 files changed, 116 insertions, 21 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 8683476..145875b 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -291,12 +291,16 @@ namespace OpenSim
291 291
292 m_console.Commands.AddCommand("region", false, "save oar", 292 m_console.Commands.AddCommand("region", false, "save oar",
293 //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]", 293 //"save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]",
294 "save oar [-h|--home=<url>] [--noassets] [--perm=<permissions>] [<OAR path>]", 294 "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [<OAR path>]",
295 "Save a region's data to an OAR archive.", 295 "Save a region's data to an OAR archive.",
296// "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine 296// "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
297 "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine 297 "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
298 + "--noassets stops assets being saved to the OAR." + Environment.NewLine 298 + "--noassets stops assets being saved to the OAR." + Environment.NewLine
299 + "--perm stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine 299 + "--publish saves an OAR stripped of owner and last owner information." + Environment.NewLine
300 + " on reload, the estate owner will be the owner of all objects" + Environment.NewLine
301 + " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published" + Environment.NewLine
302 + " this option is EXPERIMENTAL" + Environment.NewLine
303 + "--perm=<permissions> stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine
300 + " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine 304 + " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine
301 + "The OAR path must be a filesystem path." 305 + "The OAR path must be a filesystem path."
302 + " If this is not given then the oar is saved to region.oar in the current directory.", 306 + " If this is not given then the oar is saved to region.oar in the current directory.",
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index edc5ba4..a6dbaba 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -116,6 +116,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
116 m_merge = merge; 116 m_merge = merge;
117 m_skipAssets = skipAssets; 117 m_skipAssets = skipAssets;
118 m_requestId = requestId; 118 m_requestId = requestId;
119
120 // Zero can never be a valid user id
121 m_validUserUuids[UUID.Zero] = false;
119 } 122 }
120 123
121 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) 124 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
@@ -125,6 +128,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
125 m_merge = merge; 128 m_merge = merge;
126 m_skipAssets = skipAssets; 129 m_skipAssets = skipAssets;
127 m_requestId = requestId; 130 m_requestId = requestId;
131
132 // Zero can never be a valid user id
133 m_validUserUuids[UUID.Zero] = false;
128 } 134 }
129 135
130 /// <summary> 136 /// <summary>
@@ -368,16 +374,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
368 if (!m_validUserUuids.ContainsKey(uuid)) 374 if (!m_validUserUuids.ContainsKey(uuid))
369 { 375 {
370 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); 376 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
371 if (account != null) 377 m_validUserUuids.Add(uuid, account != null);
372 m_validUserUuids.Add(uuid, true);
373 else
374 m_validUserUuids.Add(uuid, false);
375 } 378 }
376 379
377 if (m_validUserUuids[uuid]) 380 return m_validUserUuids[uuid];
378 return true;
379 else
380 return false;
381 } 381 }
382 382
383 /// <summary> 383 /// <summary>
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index b895afe..ffcf063 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -282,10 +282,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
282 // always (incorrectly) includes the Copy bit set in this case. But that's a mistake: the viewer 282 // always (incorrectly) includes the Copy bit set in this case. But that's a mistake: the viewer
283 // does NOT show that the object has Everyone-Copy permissions, and doesn't allow it to be copied. 283 // does NOT show that the object has Everyone-Copy permissions, and doesn't allow it to be copied.
284 if (permissionClass != PermissionClass.Owner) 284 if (permissionClass != PermissionClass.Owner)
285 {
286 canTransfer |= (obj.EveryoneMask & (uint)PermissionMask.Copy) != 0; 285 canTransfer |= (obj.EveryoneMask & (uint)PermissionMask.Copy) != 0;
287 }
288
289 286
290 bool partPermitted = true; 287 bool partPermitted = true;
291 if (checkPermissions.Contains("C") && !canCopy) 288 if (checkPermissions.Contains("C") && !canCopy)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 0b22598..f5a5a8d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -142,6 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
142 ops.Add("h|home=", delegate(string v) { options["home"] = v; }); 142 ops.Add("h|home=", delegate(string v) { options["home"] = v; });
143 143
144 ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); 144 ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; });
145 ops.Add("publish", v => options["wipe-owners"] = v != null);
145 ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; }); 146 ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; });
146 147
147 List<string> mainParams = ops.Parse(cmdparams); 148 List<string> mainParams = ops.Parse(cmdparams);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index eec3c1b..63f1363 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -248,9 +248,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
248 Dictionary<string, Object> options = new Dictionary<string, Object>(); 248 Dictionary<string, Object> options = new Dictionary<string, Object>();
249 options.Add("noassets", true); 249 options.Add("noassets", true);
250 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); 250 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options);
251 //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer;
252 //while (assetServer.HasWaitingRequests())
253 // assetServer.ProcessNextRequest();
254 251
255 // Don't wait for completion - with --noassets save oar happens synchronously 252 // Don't wait for completion - with --noassets save oar happens synchronously
256// Monitor.Wait(this, 60000); 253// Monitor.Wait(this, 60000);
@@ -410,6 +407,86 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
410 } 407 }
411 408
412 /// <summary> 409 /// <summary>
410 /// Test loading an OpenSim Region Archive saved with the --publish option.
411 /// </summary>
412 [Test]
413 public void TestLoadPublishedOar()
414 {
415 TestHelpers.InMethod();
416// log4net.Config.XmlConfigurator.Configure();
417
418 SceneObjectPart part1 = CreateSceneObjectPart1();
419 SceneObjectGroup sog1 = new SceneObjectGroup(part1);
420 m_scene.AddNewSceneObject(sog1, false);
421
422 SceneObjectPart part2 = CreateSceneObjectPart2();
423
424 AssetNotecard nc = new AssetNotecard();
425 nc.BodyText = "Hello World!";
426 nc.Encode();
427 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
428 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
429 AssetBase ncAsset
430 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
431 m_scene.AssetService.Store(ncAsset);
432 SceneObjectGroup sog2 = new SceneObjectGroup(part2);
433 TaskInventoryItem ncItem
434 = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
435 part2.Inventory.AddInventoryItem(ncItem, true);
436
437 m_scene.AddNewSceneObject(sog2, false);
438
439 MemoryStream archiveWriteStream = new MemoryStream();
440 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
441
442 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
443
444 lock (this)
445 {
446 m_archiverModule.ArchiveRegion(
447 archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } });
448
449 Monitor.Wait(this, 60000);
450 }
451
452 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
453
454 byte[] archive = archiveWriteStream.ToArray();
455 MemoryStream archiveReadStream = new MemoryStream(archive);
456
457 {
458 UUID estateOwner = TestHelpers.ParseTail(0x4747);
459 UUID objectOwner = TestHelpers.ParseTail(0x15);
460
461 // Reload to new scene
462 ArchiverModule archiverModule = new ArchiverModule();
463 SerialiserModule serialiserModule = new SerialiserModule();
464 TerrainModule terrainModule = new TerrainModule();
465
466 TestScene scene2 = SceneHelpers.SetupScene();
467 SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule);
468
469 // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is
470 // behaving correctly
471 UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner);
472
473 scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;
474
475 lock (this)
476 {
477 scene2.EventManager.OnOarFileLoaded += LoadCompleted;
478 archiverModule.DearchiveRegion(archiveReadStream);
479 }
480
481 Assert.That(m_lastErrorMessage, Is.Null);
482
483 SceneObjectGroup loadedSog = scene2.GetSceneObjectGroup(part1.Name);
484 Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner));
485 Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner));
486 }
487 }
488
489 /// <summary>
413 /// Test loading the region settings of an OpenSim Region Archive. 490 /// Test loading the region settings of an OpenSim Region Archive.
414 /// </summary> 491 /// </summary>
415 [Test] 492 [Test]
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index cad09b8..739c5fa 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -441,6 +441,12 @@ namespace OpenSim.Region.Framework.Scenes
441 } 441 }
442 } 442 }
443 443
444 public UUID LastOwnerID
445 {
446 get { return m_rootPart.LastOwnerID; }
447 set { m_rootPart.LastOwnerID = value; }
448 }
449
444 public UUID OwnerID 450 public UUID OwnerID
445 { 451 {
446 get { return m_rootPart.OwnerID; } 452 get { return m_rootPart.OwnerID; }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 7c60ddd..3a08271 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1192,8 +1192,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1192 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); 1192 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
1193 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); 1193 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
1194 WriteUUID(writer, "GroupID", sop.GroupID, options); 1194 WriteUUID(writer, "GroupID", sop.GroupID, options);
1195 WriteUUID(writer, "OwnerID", sop.OwnerID, options); 1195
1196 WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options); 1196 UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID;
1197 WriteUUID(writer, "OwnerID", ownerID, options);
1198
1199 UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.LastOwnerID;
1200 WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
1201
1197 writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); 1202 writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
1198 writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); 1203 writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
1199 writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); 1204 writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
@@ -1277,7 +1282,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1277 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); 1282 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
1278 writer.WriteElementString("CreationDate", item.CreationDate.ToString()); 1283 writer.WriteElementString("CreationDate", item.CreationDate.ToString());
1279 1284
1280
1281 WriteUUID(writer, "CreatorID", item.CreatorID, options); 1285 WriteUUID(writer, "CreatorID", item.CreatorID, options);
1282 1286
1283 if (item.CreatorData != null && item.CreatorData != string.Empty) 1287 if (item.CreatorData != null && item.CreatorData != string.Empty)
@@ -1298,10 +1302,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1298 writer.WriteElementString("InvType", item.InvType.ToString()); 1302 writer.WriteElementString("InvType", item.InvType.ToString());
1299 WriteUUID(writer, "ItemID", item.ItemID, options); 1303 WriteUUID(writer, "ItemID", item.ItemID, options);
1300 WriteUUID(writer, "OldItemID", item.OldItemID, options); 1304 WriteUUID(writer, "OldItemID", item.OldItemID, options);
1301 WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options); 1305
1306 UUID lastOwnerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.LastOwnerID;
1307 WriteUUID(writer, "LastOwnerID", lastOwnerID, options);
1308
1302 writer.WriteElementString("Name", item.Name); 1309 writer.WriteElementString("Name", item.Name);
1303 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); 1310 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
1304 WriteUUID(writer, "OwnerID", item.OwnerID, options); 1311
1312 UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.OwnerID;
1313 WriteUUID(writer, "OwnerID", ownerID, options);
1314
1305 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); 1315 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
1306 WriteUUID(writer, "ParentID", item.ParentID, options); 1316 WriteUUID(writer, "ParentID", item.ParentID, options);
1307 WriteUUID(writer, "ParentPartID", item.ParentPartID, options); 1317 WriteUUID(writer, "ParentPartID", item.ParentPartID, options);