Update the permissions system to handle scripts and notecards the way

it was meant to. No functional changes, just better code
0.6.0-stable
Melanie Thielker 2008-09-23 03:36:16 +00:00
parent 611ffa3f60
commit 70d264ee6c
5 changed files with 90 additions and 13 deletions

View File

@ -4835,7 +4835,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
case PacketType.TransferRequest:
//Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
TransferRequestPacket transfer = (TransferRequestPacket)Pack;
System.Console.WriteLine("Transfer request, source {0}", transfer.TransferInfo.SourceType);
// Validate inventory transfers
// Has to be done here, because AssetCache can't do it
//

View File

@ -631,7 +631,10 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
return false;
// If you can view it, you can edit it
// There is no viewing a no mod script
//
return CanViewScript(script, objectID, user, scene);
}
private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene)
@ -639,6 +642,67 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue;
if (objectID == UUID.Zero) // User inventory
{
CachedUserInfo userInfo =
scene.CommsManager.UserProfileCacheService.GetUserDetails(user);
if (userInfo == null)
return false;
if (userInfo.RootFolder == null)
return false;
InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(notecard);
if (assetRequestItem == null) // Library item
{
assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);
if (assetRequestItem != null) // Implicitly readable
return true;
}
// Notecards must be both mod and copy to be saveable
// This is because of they're not copy, you can't read
// them, and if they're not mod, well, then they're
// not mod. Duh.
//
if ((assetRequestItem.CurrentPermissions &
((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy)) !=
((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy))
return false;
}
else // Prim inventory
{
SceneObjectPart part = scene.GetSceneObjectPart(objectID);
if (part == null)
return false;
if (part.OwnerID != user)
return false;
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return false;
TaskInventoryItem ti = part.GetInventoryItem(notecard);
if (ti == null)
return false;
if (ti.OwnerID != user)
return false;
// Require full perms
if ((ti.CurrentPermissions &
((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy)) !=
((uint)PermissionMask.Modify |
(uint)PermissionMask.Copy))
return false;
}
return true;
}

View File

@ -171,6 +171,23 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null)
{
if ((InventoryType) item.InvType == InventoryType.Notecard)
{
if (!ExternalChecks.ExternalChecksCanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
return UUID.Zero;
}
}
else if ((InventoryType) item.InvType == InventoryType.LSL)
{
if (!ExternalChecks.ExternalChecksCanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
return UUID.Zero;
}
}
AssetBase asset =
CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
AssetCache.AddAsset(asset);
@ -179,15 +196,6 @@ namespace OpenSim.Region.Environment.Scenes
userInfo.UpdateItem(item);
// remoteClient.SendInventoryItemCreateUpdate(item);
if ((InventoryType) item.InvType == InventoryType.Notecard)
{
//do we want to know about updated note cards?
}
else if ((InventoryType) item.InvType == InventoryType.LSL)
{
// do we want to know about updated scripts
}
return (asset.FullID);
}
}
@ -228,6 +236,12 @@ namespace OpenSim.Region.Environment.Scenes
public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId,
UUID primId, bool isScriptRunning, byte[] data)
{
if (!ExternalChecks.ExternalChecksCanEditScript(itemId, primId, remoteClient.AgentId))
{
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
return;
}
// Retrieve group
SceneObjectPart part = GetSceneObjectPart(primId);
SceneObjectGroup group = part.ParentGroup;

View File

@ -56,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public IConfigSource ConfigSource;
public IConfig ScriptConfigSource;
public abstract string ScriptEngineName { get; }
private bool m_enabled = true;
private bool m_enabled = false;
private bool m_hookUpToServer = false;
/// <summary>

View File

@ -67,7 +67,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private int m_SleepTime;
private int m_SaveTime;
private ThreadPriority m_Prio;
private bool m_Enabled = true;
private bool m_Enabled = false;
// disable warning: need to keep a reference to XEngine.EventManager
// alive to avoid it being garbage collected