aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs39
4 files changed, 66 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 14bab6e..b37beab 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -53,25 +53,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 56 protected Scene m_scene;
57 private static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 57 protected Stream m_loadStream;
58 58 protected Guid m_requestId;
59 private Scene m_scene; 59 protected string m_errorMessage;
60 private Stream m_loadStream;
61 private Guid m_requestId;
62 private string m_errorMessage;
63 60
64 /// <value> 61 /// <value>
65 /// Should the archive being loaded be merged with what is already on the region? 62 /// Should the archive being loaded be merged with what is already on the region?
66 /// </value> 63 /// </value>
67 private bool m_merge; 64 protected bool m_merge;
65
66 /// <value>
67 /// Should we ignore any assets when reloading the archive?
68 /// </value>
69 protected bool m_skipAssets;
68 70
69 /// <summary> 71 /// <summary>
70 /// Used to cache lookups for valid uuids. 72 /// Used to cache lookups for valid uuids.
71 /// </summary> 73 /// </summary>
72 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); 74 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
73 75
74 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) 76 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
75 { 77 {
76 m_scene = scene; 78 m_scene = scene;
77 79
@@ -89,14 +91,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
89 91
90 m_errorMessage = String.Empty; 92 m_errorMessage = String.Empty;
91 m_merge = merge; 93 m_merge = merge;
94 m_skipAssets = skipAssets;
92 m_requestId = requestId; 95 m_requestId = requestId;
93 } 96 }
94 97
95 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId) 98 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
96 { 99 {
97 m_scene = scene; 100 m_scene = scene;
98 m_loadStream = loadStream; 101 m_loadStream = loadStream;
99 m_merge = merge; 102 m_merge = merge;
103 m_skipAssets = skipAssets;
100 m_requestId = requestId; 104 m_requestId = requestId;
101 } 105 }
102 106
@@ -133,9 +137,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
133 137
134 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 138 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
135 { 139 {
136 serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); 140 serialisedSceneObjects.Add(Encoding.UTF8.GetString(data));
137 } 141 }
138 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 142 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets)
139 { 143 {
140 if (LoadAsset(filePath, data)) 144 if (LoadAsset(filePath, data))
141 successfulAssetRestores++; 145 successfulAssetRestores++;
@@ -155,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
155 } 159 }
156 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) 160 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
157 { 161 {
158 serialisedParcels.Add(m_utf8Encoding.GetString(data)); 162 serialisedParcels.Add(Encoding.UTF8.GetString(data));
159 } 163 }
160 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 164 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
161 { 165 {
@@ -178,12 +182,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
178 archive.Close(); 182 archive.Close();
179 } 183 }
180 184
181 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 185 if (!m_skipAssets)
182
183 if (failedAssetRestores > 0)
184 { 186 {
185 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 187 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
186 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); 188
189 if (failedAssetRestores > 0)
190 {
191 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
192 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
193 }
187 } 194 }
188 195
189 if (!m_merge) 196 if (!m_merge)
@@ -279,6 +286,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
279 { 286 {
280 sceneObjectsLoadedCount++; 287 sceneObjectsLoadedCount++;
281 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); 288 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
289 sceneObject.ResumeScripts();
282 } 290 }
283 } 291 }
284 292
@@ -543,7 +551,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
543 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); 551 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
544 552
545 XmlTextReader xtr 553 XmlTextReader xtr
546 = new XmlTextReader(m_asciiEncoding.GetString(data), XmlNodeType.Document, context); 554 = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
547 555
548 RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; 556 RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;
549 557
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index fc8d4e1..82ede01 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -94,8 +94,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) 94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
95 { 95 {
96 bool mergeOar = false; 96 bool mergeOar = false;
97 bool skipAssets = false;
97 98
98 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); 99 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
100 options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
101
99 List<string> mainParams = options.Parse(cmdparams); 102 List<string> mainParams = options.Parse(cmdparams);
100 103
101// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); 104// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
@@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
105 108
106 if (mainParams.Count > 2) 109 if (mainParams.Count > 2)
107 { 110 {
108 DearchiveRegion(mainParams[2], mergeOar, Guid.Empty); 111 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
109 } 112 }
110 else 113 else
111 { 114 {
112 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty); 115 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty);
113 } 116 }
114 } 117 }
115 118
@@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
154 157
155 public void DearchiveRegion(string loadPath) 158 public void DearchiveRegion(string loadPath)
156 { 159 {
157 DearchiveRegion(loadPath, false, Guid.Empty); 160 DearchiveRegion(loadPath, false, false, Guid.Empty);
158 } 161 }
159 162
160 public void DearchiveRegion(string loadPath, bool merge, Guid requestId) 163 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
161 { 164 {
162 m_log.InfoFormat( 165 m_log.InfoFormat(
163 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 166 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
164 167
165 new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion(); 168 new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
166 } 169 }
167 170
168 public void DearchiveRegion(Stream loadStream) 171 public void DearchiveRegion(Stream loadStream)
169 { 172 {
170 DearchiveRegion(loadStream, false, Guid.Empty); 173 DearchiveRegion(loadStream, false, false, Guid.Empty);
171 } 174 }
172 175
173 public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId) 176 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
174 { 177 {
175 new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion(); 178 new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
176 } 179 }
177 } 180 }
178} 181}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index de16d89..624dc22 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -442,7 +442,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
442 byte[] archive = archiveWriteStream.ToArray(); 442 byte[] archive = archiveWriteStream.ToArray();
443 MemoryStream archiveReadStream = new MemoryStream(archive); 443 MemoryStream archiveReadStream = new MemoryStream(archive);
444 444
445 m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); 445 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty);
446 446
447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 0f830e1..d940564 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -162,7 +162,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
162 private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); 162 private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>();
163 private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); 163 private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
164 private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); 164 private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
165 private IFriendsModule m_friendsModule = null; 165 private IFriendsModule m_friendsModule;
166 private IGroupsModule m_groupsModule;
166 167
167 #endregion 168 #endregion
168 169
@@ -386,9 +387,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
386 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 387 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
387 388
388 if (m_friendsModule == null) 389 if (m_friendsModule == null)
389 m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); 390 m_log.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work");
390 else 391
391 m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); 392 m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
393
394 if (m_groupsModule == null)
395 m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work");
392 } 396 }
393 397
394 public void Close() 398 public void Close()
@@ -423,14 +427,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
423 // with the powers requested (powers = 0 for no powers check) 427 // with the powers requested (powers = 0 for no powers check)
424 protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) 428 protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
425 { 429 {
426 ScenePresence sp = m_scene.GetScenePresence(userID); 430 if (null == m_groupsModule)
427 if (sp != null) 431 return false;
428 { 432
429 IClientAPI client = sp.ControllingClient; 433 GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
430 434
431 return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && 435 if (gmd != null)
432 ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); 436 {
437 if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
438 return true;
433 } 439 }
440
434 return false; 441 return false;
435 } 442 }
436 443
@@ -721,8 +728,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
721 permission = false; 728 permission = false;
722 } 729 }
723 730
731// m_log.DebugFormat(
732// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}",
733// group.GroupID,
734// m_scene.GetSceneObjectPart(objId).GroupMask,
735// IsGroupMember(group.GroupID, currentUser, 0),
736// currentUser);
737
724 // Group members should be able to edit group objects 738 // Group members should be able to edit group objects
725 if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0)) 739 if ((group.GroupID != UUID.Zero)
740 && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
741 && IsGroupMember(group.GroupID, currentUser, 0))
726 { 742 {
727 // Return immediately, so that the administrator can shares group objects 743 // Return immediately, so that the administrator can shares group objects
728 return true; 744 return true;
@@ -957,7 +973,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
957 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 973 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
958 if (m_bypassPermissions) return m_bypassPermissionsValue; 974 if (m_bypassPermissions) return m_bypassPermissionsValue;
959 975
960
961 return GenericObjectPermission(editorID, objectID, false); 976 return GenericObjectPermission(editorID, objectID, false);
962 } 977 }
963 978