fix merge

httptests
UbitUmarov 2017-05-03 03:52:55 +01:00
commit 832ca518d7
31 changed files with 1083 additions and 245 deletions

View File

@ -3087,15 +3087,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
/// </summary>
private void ApplyNextOwnerPermissions(InventoryItemBase item)
{
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
if (item.InvType == (int)InventoryType.Object)
{
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
uint perms = item.CurrentPermissions;
PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
item.CurrentPermissions = perms;
}
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
item.EveryOnePermissions &= item.NextPermissions;

View File

@ -60,9 +60,57 @@ namespace OpenSim.Framework
str += "C";
if ((perms & (int)PermissionMask.Transfer) != 0)
str += "T";
if ((perms & (int)PermissionMask.Export) != 0)
str += "X";
if (str == "")
str = ".";
return str;
}
public static void ApplyFoldedPermissions(uint foldedSourcePerms, ref uint targetPerms)
{
uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask;
if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do
return;
folded <<= (int)PermissionMask.FoldingShift;
folded |= ~(uint)PermissionMask.UnfoldedMask;
uint tmp = targetPerms;
tmp &= folded;
targetPerms = tmp;
}
// do not touch MOD
public static void ApplyNoModFoldedPermissions(uint foldedSourcePerms, ref uint target)
{
uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask;
if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do
return;
folded <<= (int)PermissionMask.FoldingShift;
folded |= (~(uint)PermissionMask.UnfoldedMask | (uint)PermissionMask.Modify);
uint tmp = target;
tmp &= folded;
target = tmp;
}
public static uint FixAndFoldPermissions(uint perms)
{
uint tmp = perms;
// C & T rule
if((tmp & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0)
tmp |= (uint)PermissionMask.Transfer;
// unlock
tmp |= (uint)PermissionMask.Move;
tmp &= ~(uint)PermissionMask.FoldedMask;
tmp |= ((tmp >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask);
return tmp;
}
}
}

View File

@ -191,8 +191,7 @@ namespace OpenSim.Framework.Servers
}
catch(Exception e)
{
m_log.FatalFormat("Fatal error: {0}",
(e.Message == null || e.Message == String.Empty) ? "Unknown reason":e.Message );
m_log.Fatal("Fatal error: " + e.ToString());
Environment.Exit(1);
}

View File

@ -79,7 +79,9 @@ namespace OpenSim.Framework
FoldedMask = 0x0f,
//
FoldingShift = 13 , // number of bit shifts from normal perm to folded or back (same as Transfer shift below)
// when doing as a block
Transfer = 1 << 13, // 0x02000
Modify = 1 << 14, // 0x04000
Copy = 1 << 15, // 0x08000
@ -90,7 +92,8 @@ namespace OpenSim.Framework
// explicitly given
All = 0x8e000,
AllAndExport = 0x9e000,
AllEffective = 0x9e000
AllEffective = 0x9e000,
UnfoldedMask = 0x1e000
}
/// <summary>

View File

@ -237,7 +237,7 @@ namespace OpenSim
string permissionModules = Util.GetConfigVarFromSections<string>(Config, "permissionmodules",
new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule");
m_permsModules = new List<string>(permissionModules.Split(','));
m_permsModules = new List<string>(permissionModules.Split(',').Select(m => m.Trim()));
managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty);

View File

@ -212,6 +212,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
byte[] data = null;
uint everyonemask = 0;
uint groupmask = 0;
if (invType == (sbyte)InventoryType.Landmark && presence != null)
{
@ -220,6 +222,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
data = Encoding.ASCII.GetBytes(strdata);
name = prefix + name;
description += suffix;
groupmask = (uint)PermissionMask.AllAndExport;
everyonemask = (uint)(PermissionMask.AllAndExport & ~PermissionMask.Modify);
}
AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
@ -227,9 +231,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
m_Scene.CreateNewInventoryItem(
remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
name, description, 0, callbackID, asset.FullID, asset.Type, invType,
(uint)PermissionMask.All | (uint)PermissionMask.Export, // Base
(uint)PermissionMask.All | (uint)PermissionMask.Export, // Current
0, nextOwnerMask, 0, creationDate, false); // Data from viewer
(uint)PermissionMask.AllAndExport, // Base
(uint)PermissionMask.AllAndExport, // Current
everyonemask,
nextOwnerMask, groupmask, creationDate, false); // Data from viewer
}
else
{
@ -573,41 +578,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions,
IClientAPI remoteClient)
{
uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7;
uint allObjectsNextOwnerPerms = 0x7fffffff;
uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export | PermissionMask.FoldedMask);
// For the porposes of inventory, an object is modify if the prims
// are modify. This allows renaming an object that contains no
// mod items.
foreach (SceneObjectGroup grp in objsForEffectivePermissions)
{
uint groupPerms = grp.GetEffectivePermissions(true);
if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0)
groupPerms |= (uint)PermissionMask.Modify;
effectivePerms &= groupPerms;
effectivePerms &= grp.CurrentAndFoldedNextPermissions();
}
effectivePerms |= (uint)PermissionMask.Move;
if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
{
uint perms = effectivePerms;
uint nextPerms = (perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
// apply parts inventory items next owner
PermissionsUtil.ApplyNoModFoldedPermissions(effectivePerms, ref effectivePerms);
// change to next owner
uint basePerms = effectivePerms & so.RootPart.NextOwnerMask;
// fix and update folded
basePerms = PermissionsUtil.FixAndFoldPermissions(basePerms);
// item.BasePermissions = perms & so.RootPart.NextOwnerMask;
uint nextp = so.RootPart.NextOwnerMask | (uint)PermissionMask.FoldedMask;
item.BasePermissions = perms & nextp;
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = perms & so.RootPart.NextOwnerMask;
item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
item.BasePermissions = basePerms;
item.CurrentPermissions = basePerms;
item.NextPermissions = basePerms & so.RootPart.NextOwnerMask;
item.EveryOnePermissions = basePerms & so.RootPart.EveryoneMask;
item.GroupPermissions = basePerms & so.RootPart.GroupMask;
// apply next owner perms on rez
item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
@ -626,7 +617,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
(uint)PermissionMask.Modify |
(uint)PermissionMask.Move |
(uint)PermissionMask.Export |
7); // Preserve folded permissions
(uint)PermissionMask.FoldedMask); // Preserve folded permissions ??
}
return item;
@ -1144,9 +1135,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if ((item.BasePermissions & (uint)PermissionMask.FoldedMask) != 0)
{
// We have permissions stored there so use them
part.NextOwnerMask = ((item.BasePermissions & 7) << 13);
if ((item.BasePermissions & (uint)PermissionMask.FoldedExport) != 0)
part.NextOwnerMask |= (uint)PermissionMask.Export;
part.NextOwnerMask = ((item.BasePermissions & (uint)PermissionMask.FoldedMask) << (int)PermissionMask.FoldingShift);
part.NextOwnerMask |= (uint)PermissionMask.Move;
}
else

View File

@ -223,20 +223,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
if (parms.Length - i < 2)
break;
//Have we reached the end of the list of headers?
//End is marked by a string with a single digit.
//We already know we have at least one parameter
//so it is safe to do this check at top of loop.
if (Char.IsDigit(parms[i][0]))
break;
if (htc.HttpCustomHeaders == null)
htc.HttpCustomHeaders = new List<string>();
htc.HttpCustomHeaders.Add(parms[i]);
htc.HttpCustomHeaders.Add(parms[i+1]);
int nexti = i + 2;
if (nexti >= parms.Length || Char.IsDigit(parms[nexti][0]))
break;
i += 2;
i = nexti;
}
break;

View File

@ -26,15 +26,15 @@
*/
using System;
using System.Threading;
using System.Collections.Generic;
using System.Collections;
using System.Reflection;
using System.Net;
using System.Net.Sockets;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@ -89,6 +89,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
protected Dictionary<string, UrlData> m_UrlMap =
new Dictionary<string, UrlData>();
protected bool m_enabled = false;
protected string m_ErrorStr;
protected uint m_HttpsPort = 0;
protected IHttpServer m_HttpServer = null;
protected IHttpServer m_HttpsServer = null;
@ -118,6 +120,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void Initialise(IConfigSource config)
{
IConfig networkConfig = config.Configs["Network"];
m_enabled = false;
if (networkConfig != null)
{
@ -128,9 +131,47 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
if (ssl_enabled)
m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort);
}
else
{
m_ErrorStr = "[Network] configuration missing, HTTP listener for LSL disabled";
m_log.Warn("[URL MODULE]: " + m_ErrorStr);
return;
}
if (ExternalHostNameForLSL == null)
ExternalHostNameForLSL = System.Environment.MachineName;
if (String.IsNullOrWhiteSpace(ExternalHostNameForLSL))
{
m_ErrorStr = "ExternalHostNameForLSL not defined in configuration, HTTP listener for LSL disabled";
m_log.Warn("[URL MODULE]: " + m_ErrorStr);
return;
}
IPAddress ia = null;
try
{
foreach (IPAddress Adr in Dns.GetHostAddresses(ExternalHostNameForLSL))
{
if (Adr.AddressFamily == AddressFamily.InterNetwork ||
Adr.AddressFamily == AddressFamily.InterNetworkV6) // ipv6 will most likely smoke
{
ia = Adr;
break;
}
}
}
catch
{
ia = null;
}
if (ia == null)
{
m_ErrorStr = "Could not resolve ExternalHostNameForLSL, HTTP listener for LSL disabled";
m_log.Warn("[URL MODULE]: " + m_ErrorStr);
return;
}
m_enabled = true;
m_ErrorStr = String.Empty;
IConfig llFunctionsConfig = config.Configs["LL-Functions"];
@ -146,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void AddRegion(Scene scene)
{
if (m_HttpServer == null)
if (m_enabled && m_HttpServer == null)
{
// There can only be one
//
@ -197,11 +238,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{
UUID urlcode = UUID.Random();
if(!m_enabled)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr });
return urlcode;
}
lock (m_UrlMap)
{
if (m_UrlMap.Count >= TotalUrls)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED",
"Too many URLs already open" });
return urlcode;
}
string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
@ -243,6 +291,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{
UUID urlcode = UUID.Random();
if(!m_enabled)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", m_ErrorStr });
return urlcode;
}
if (m_HttpsServer == null)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
@ -253,7 +307,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{
if (m_UrlMap.Count >= TotalUrls)
{
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED",
"Too many URLs already open" });
return urlcode;
}
string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/";

View File

@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
// wrap this in a try block so that defaults will work if
// the config file doesn't specify otherwise.
int maxlisteners = 1000;
int maxhandles = 64;
int maxhandles = 65;
try
{
m_whisperdistance = config.Configs["Chat"].GetInt(
@ -130,8 +130,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
catch (Exception)
{
}
if (maxlisteners < 1) maxlisteners = int.MaxValue;
if (maxhandles < 1) maxhandles = int.MaxValue;
if (maxlisteners < 1)
maxlisteners = int.MaxValue;
if (maxhandles < 1)
maxhandles = int.MaxValue;
if (maxlisteners < maxhandles)
maxlisteners = maxhandles;
m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
m_pendingQ = new Queue();
m_pending = Queue.Synchronized(m_pendingQ);
@ -605,11 +612,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
li.GetHandle().Equals(handle))
{
lis.Value.Remove(li);
if (lis.Value.Count == 0)
{
m_listeners.Remove(lis.Key);
m_curlisteners--;
}
if (lis.Value.Count == 0)
m_listeners.Remove(lis.Key); // bailing of loop so this does not smoke
// there should be only one, so we bail out early
return;
}
@ -718,6 +723,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
}
}
if(handles.Count >= m_maxhandles)
return -1;
// Note: 0 is NOT a valid handle for llListen() to return
for (int i = 1; i <= m_maxhandles; i++)
{

View File

@ -118,6 +118,11 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
return false;
SceneObjectGroup group = part.ParentGroup;
if(group == null || group.IsDeleted || group.inTransit)
return false;
// make sure we are not buying a child part
part = group.RootPart;
switch (saleType)
{
@ -157,18 +162,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
break;
case 2: // Sell a copy
Vector3 inventoryStoredPosition = new Vector3(
Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6),
Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6),
group.AbsolutePosition.Z);
Vector3 originalPosition = group.AbsolutePosition;
group.AbsolutePosition = inventoryStoredPosition;
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
group.AbsolutePosition = originalPosition;
uint perms = group.EffectiveOwnerPerms;
if ((perms & (uint)PermissionMask.Transfer) == 0)
@ -185,6 +178,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
return false;
}
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
AssetBase asset = m_scene.CreateAsset(
group.GetPartName(localID),
group.GetPartDescription(localID),
@ -206,21 +201,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
uint nextPerms=(perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
perms = group.CurrentAndFoldedNextPermissions();
// apply parts inventory next perms
PermissionsUtil.ApplyNoModFoldedPermissions(perms, ref perms);
// change to next owner perms
perms &= part.NextOwnerMask;
// update folded
perms = PermissionsUtil.FixAndFoldPermissions(perms);
item.BasePermissions = perms;
item.CurrentPermissions = perms;
item.NextPermissions = part.NextOwnerMask & perms;
item.EveryOnePermissions = part.EveryoneMask & perms;
item.GroupPermissions = part.GroupMask & perms;
item.BasePermissions = perms & part.NextOwnerMask;
item.CurrentPermissions = perms & part.NextOwnerMask;
item.NextPermissions = part.NextOwnerMask;
item.EveryOnePermissions = part.EveryoneMask &
part.NextOwnerMask;
item.GroupPermissions = part.GroupMask &
part.NextOwnerMask;
item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
item.CreationDate = Util.UnixTimeSinceEpoch();

View File

@ -2022,7 +2022,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
uint perms = GetObjectPermissions(sp, sog, true);
if((perms & (uint)PermissionMask.Copy) == 0)
{
sp.ControllingClient.SendAgentAlertMessage("Copying this item has been denied by the permissions system", false);
return false;
}
if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
return false;

View File

@ -682,30 +682,26 @@ namespace OpenSim.Region.Framework.Scenes
// These will be applied to the root prim at next rez.
// The legacy slam bit (bit 3) and folded permission (bits 0-2)
// are preserved due to the above mangling
ownerPerms &= nextPerms;
// ownerPerms &= nextPerms;
// Mask the base permissions. This is a conservative
// approach altering only the three main perms
basePerms &= nextPerms;
// basePerms &= nextPerms;
// Mask out the folded portion of the base mask.
// While the owner mask carries the actual folded
// permissions, the base mask carries the original
// base mask, before masking with the folded perms.
// We need this later for rezzing.
basePerms &= ~(uint)PermissionMask.FoldedMask;
basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
// basePerms &= ~(uint)PermissionMask.FoldedMask;
// basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
// If this is an object, root prim perms may be more
// permissive than folded perms. Use folded perms as
// a mask
if (item.InvType == (int)InventoryType.Object)
uint foldedPerms = (item.CurrentPermissions & (uint)PermissionMask.FoldedMask) << (int)PermissionMask.FoldingShift;
if (foldedPerms != 0 && item.InvType == (int)InventoryType.Object)
{
// Create a safe mask for the current perms
uint foldedPerms = (item.CurrentPermissions & 7) << 13;
if ((item.CurrentPermissions & (uint)PermissionMask.FoldedExport) != 0)
foldedPerms |= (uint)PermissionMask.Export;
foldedPerms |= permsMask;
bool isRootMod = (item.CurrentPermissions &
@ -729,6 +725,11 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// move here so nextperms are mandatory
ownerPerms &= nextPerms;
basePerms &= nextPerms;
basePerms &= ~(uint)PermissionMask.FoldedMask;
basePerms |= ((basePerms >> 13) & 7) | (((basePerms & (uint)PermissionMask.Export) != 0) ? (uint)PermissionMask.FoldedExport : 0);
// Assign to the actual item. Make sure the slam bit is
// set, if it wasn't set before.
itemCopy.BasePermissions = basePerms;
@ -1266,20 +1267,26 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: Fix this after the inventory fixer exists and has beenr run
if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
{
agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
uint perms = taskItem.BasePermissions & taskItem.NextPermissions;
if (taskItem.InvType == (int)InventoryType.Object)
agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move));
{
PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms );
perms = PermissionsUtil.FixAndFoldPermissions(perms);
}
else
agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
perms &= taskItem.CurrentPermissions;
agentItem.BasePermissions = agentItem.CurrentPermissions;
// always unlock
perms |= (uint)PermissionMask.Move;
agentItem.BasePermissions = perms;
agentItem.CurrentPermissions = perms;
agentItem.NextPermissions = perms & taskItem.NextPermissions;
agentItem.EveryOnePermissions = perms & taskItem.EveryonePermissions;
agentItem.GroupPermissions = perms & taskItem.GroupPermissions;
agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
agentItem.NextPermissions = taskItem.NextPermissions;
agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
// Group permissions make no sense here
agentItem.GroupPermissions = 0;
}
else
{
@ -1287,7 +1294,7 @@ namespace OpenSim.Region.Framework.Scenes
agentItem.CurrentPermissions = taskItem.CurrentPermissions;
agentItem.NextPermissions = taskItem.NextPermissions;
agentItem.EveryOnePermissions = taskItem.EveryonePermissions;
agentItem.GroupPermissions = 0;
agentItem.GroupPermissions = taskItem.GroupPermissions;
}
message = null;

View File

@ -252,70 +252,81 @@ namespace OpenSim.Region.Framework.Scenes
}
// new test code, to place in better place later
private object PermissionsLock = new object();
private object m_PermissionsLock = new object();
private bool m_EffectivePermsInvalid = true;
public void InvalidateEffectivePerms()
{
lock(m_PermissionsLock)
m_EffectivePermsInvalid = true;
}
private uint m_EffectiveEveryOnePerms;
public uint EffectiveEveryOnePerms
{
get
{
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
// bc this is on heavy duty code paths
// but for now we need to test the concept
// AggregateDeepPerms();
lock(m_PermissionsLock)
{
if(m_EffectivePermsInvalid)
AggregatePerms();
return m_EffectiveEveryOnePerms;
}
}
}
private uint m_EffectiveGroupPerms;
public uint EffectiveGroupPerms
{
get
{
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
// bc this is on heavy duty code paths
// but for now we need to test the concept
// AggregateDeepPerms();
lock(m_PermissionsLock)
{
if(m_EffectivePermsInvalid)
AggregatePerms();
return m_EffectiveGroupPerms;
}
}
}
private uint m_EffectiveGroupOrEveryOnePerms;
public uint EffectiveGroupOrEveryOnePerms
{
get
{
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
// bc this is on heavy duty code paths
// but for now we need to test the concept
// AggregateDeepPerms();
lock(m_PermissionsLock)
{
if(m_EffectivePermsInvalid)
AggregatePerms();
return m_EffectiveGroupOrEveryOnePerms;
}
}
}
private uint m_EffectiveOwnerPerms;
public uint EffectiveOwnerPerms
{
get
{
// this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
// bc this is on heavy duty code paths
// but for now we need to test the concept
// AggregateDeepPerms();
lock(m_PermissionsLock)
{
if(m_EffectivePermsInvalid)
AggregatePerms();
return m_EffectiveOwnerPerms;
}
}
}
// aggregates perms scanning parts and their contents
// AggregatePerms does same using cached parts content perms
public void AggregateDeepPerms()
{
lock(PermissionsLock)
lock(m_PermissionsLock)
{
// aux
const uint allmask = (uint)PermissionMask.AllEffective;
const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
const uint copytransfermask = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
@ -327,6 +338,8 @@ namespace OpenSim.Region.Framework.Scenes
uint rootEveryonePerms = RootPart.EveryoneMask;
uint everyone = rootEveryonePerms;
// date is time of writing april 30th 2017
bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
@ -334,12 +347,13 @@ namespace OpenSim.Region.Framework.Scenes
part.AggregateInnerPerms();
owner &= part.AggregatedInnerOwnerPerms;
group &= part.AggregatedInnerGroupPerms;
if(newObject)
everyone &= part.AggregatedInnerEveryonePerms;
}
// recover modify and move
rootOwnerPerms &= movemodmask;
owner |= rootOwnerPerms;
if((owner & copytransfermast) == 0)
if((owner & copytransfermask) == 0)
owner |= (uint)PermissionMask.Transfer;
owner &= basePerms;
@ -370,6 +384,7 @@ namespace OpenSim.Region.Framework.Scenes
m_EffectiveEveryOnePerms = everyone & owner;
m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
m_EffectivePermsInvalid = false;
}
}
@ -377,7 +392,7 @@ namespace OpenSim.Region.Framework.Scenes
// ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop
public void AggregatePerms()
{
lock(PermissionsLock)
lock(m_PermissionsLock)
{
// aux
const uint allmask = (uint)PermissionMask.AllEffective;
@ -394,12 +409,16 @@ namespace OpenSim.Region.Framework.Scenes
uint rootEveryonePerms = RootPart.EveryoneMask;
uint everyone = rootEveryonePerms;
bool needUpdate = false;
// date is time of writing april 30th 2017
bool newObject = (RootPart.CreationDate == 0 || RootPart.CreationDate > 1493574994);
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
owner &= part.AggregatedInnerOwnerPerms;
group &= part.AggregatedInnerGroupPerms;
if(newObject)
everyone &= part.AggregatedInnerEveryonePerms;
}
// recover modify and move
@ -409,7 +428,12 @@ namespace OpenSim.Region.Framework.Scenes
owner |= (uint)PermissionMask.Transfer;
owner &= basePerms;
if(owner != m_EffectiveOwnerPerms)
{
needUpdate = true;
m_EffectiveOwnerPerms = owner;
}
uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
// recover modify and move
@ -421,7 +445,12 @@ namespace OpenSim.Region.Framework.Scenes
group |= ownertransfermask;
uint groupOrEveryone = group;
m_EffectiveGroupPerms = group & owner;
uint tmpPerms = group & owner;
if(tmpPerms != m_EffectiveGroupPerms)
{
needUpdate = true;
m_EffectiveGroupPerms = tmpPerms;
}
// recover move
rootEveryonePerms &= (uint)PermissionMask.Move;
@ -434,35 +463,42 @@ namespace OpenSim.Region.Framework.Scenes
groupOrEveryone |= everyone;
m_EffectiveEveryOnePerms = everyone & owner;
m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
}
}
public uint GetEffectivePermissions()
tmpPerms = everyone & owner;
if(tmpPerms != m_EffectiveEveryOnePerms)
{
return GetEffectivePermissions(false);
needUpdate = true;
m_EffectiveEveryOnePerms = tmpPerms;
}
public uint GetEffectivePermissions(bool useBase)
tmpPerms = groupOrEveryone & owner;
if(tmpPerms != m_EffectiveGroupOrEveryOnePerms)
{
needUpdate = true;
m_EffectiveGroupOrEveryOnePerms = tmpPerms;
}
m_EffectivePermsInvalid = false;
if(needUpdate)
RootPart.ScheduleFullUpdate();
}
}
public uint CurrentAndFoldedNextPermissions()
{
uint perms=(uint)(PermissionMask.Modify |
PermissionMask.Copy |
PermissionMask.Move |
PermissionMask.Transfer) | 7;
PermissionMask.Transfer |
PermissionMask.FoldedMask);
uint ownerMask = 0x7fffffff;
uint ownerMask = RootPart.OwnerMask;
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
if (useBase)
ownerMask &= part.BaseMask;
else
ownerMask &= part.OwnerMask;
perms &= part.Inventory.MaskEffectivePermissions();
}
@ -472,17 +508,8 @@ namespace OpenSim.Region.Framework.Scenes
perms &= ~(uint)PermissionMask.Copy;
if ((ownerMask & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
// If root prim permissions are applied here, this would screw
// with in-inventory manipulation of the next owner perms
// in a major way. So, let's move this to the give itself.
// Yes. I know. Evil.
// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Modify) == 0)
// perms &= ~((uint)PermissionMask.Modify >> 13);
// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Copy) == 0)
// perms &= ~((uint)PermissionMask.Copy >> 13);
// if ((ownerMask & RootPart.NextOwnerMask & (uint)PermissionMask.Transfer) == 0)
// perms &= ~((uint)PermissionMask.Transfer >> 13);
if ((ownerMask & (uint)PermissionMask.Export) == 0)
perms &= ~(uint)PermissionMask.Export;
return perms;
}

View File

@ -2579,6 +2579,8 @@ namespace OpenSim.Region.Framework.Scenes
AggregatedInnerOwnerPerms = owner & mask;
AggregatedInnerGroupPerms = group & mask;
AggregatedInnerEveryonePerms = everyone & mask;
if(ParentGroup != null)
ParentGroup.InvalidateEffectivePerms();
}
}
@ -5286,9 +5288,9 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
// Export needs to be preserved in the base and everyone
// mask, but removed in the owner mask as a next owner
// can never change the export status
BaseMask &= NextOwnerMask | (uint)PermissionMask.Export;
BaseMask &= (NextOwnerMask | (uint)PermissionMask.Export);
OwnerMask &= NextOwnerMask;
EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export;
EveryoneMask &= (NextOwnerMask | (uint)PermissionMask.Export);
GroupMask = 0; // Giving an object zaps group permissions
Inventory.ApplyNextOwnerPermissions();

View File

@ -1332,6 +1332,8 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (TaskInventoryItem item in m_items.Values)
{
if(item.InvType == (sbyte)InventoryType.Landmark)
continue;
owner &= item.CurrentPermissions;
group &= item.GroupPermissions;
everyone &= item.EveryonePermissions;
@ -1340,33 +1342,35 @@ namespace OpenSim.Region.Framework.Scenes
public uint MaskEffectivePermissions()
{
// used to propagate permissions restrictions outwards
// Modify does not propagate outwards.
uint mask=0x7fffffff;
foreach (TaskInventoryItem item in m_items.Values)
{
if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
mask &= ~((uint)PermissionMask.Copy >> 13);
if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0)
mask &= ~((uint)PermissionMask.Transfer >> 13);
if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0)
mask &= ~((uint)PermissionMask.Modify >> 13);
if(item.InvType == (sbyte)InventoryType.Landmark)
continue;
if (item.InvType == (int)InventoryType.Object)
{
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
mask &= ~((uint)PermissionMask.Copy >> 13);
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
mask &= ~((uint)PermissionMask.Transfer >> 13);
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
mask &= ~((uint)PermissionMask.Modify >> 13);
}
// apply current to normal permission bits
uint newperms = item.CurrentPermissions;
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
if ((newperms & (uint)PermissionMask.Copy) == 0)
mask &= ~(uint)PermissionMask.Copy;
if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
if ((newperms & (uint)PermissionMask.Transfer) == 0)
mask &= ~(uint)PermissionMask.Transfer;
if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0)
mask &= ~(uint)PermissionMask.Modify;
if ((newperms & (uint)PermissionMask.Export) == 0)
mask &= ~((uint)PermissionMask.Export);
// apply next owner restricted by current to folded bits
newperms &= item.NextPermissions;
if ((newperms & (uint)PermissionMask.Copy) == 0)
mask &= ~((uint)PermissionMask.FoldedCopy);
if ((newperms & (uint)PermissionMask.Transfer) == 0)
mask &= ~((uint)PermissionMask.FoldedTransfer);
if ((newperms & (uint)PermissionMask.Export) == 0)
mask &= ~((uint)PermissionMask.FoldedExport);
}
return mask;
}
@ -1375,19 +1379,6 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{
// m_log.DebugFormat (
// "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}",
// item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions);
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
}
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
item.EveryonePermissions &= item.NextPermissions;

View File

@ -755,8 +755,8 @@ namespace PrimMesher
if (hollowAngles.angles[0].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[maxJ].angle + 0.000001f)
{
newFace.v1 = 0;
newFace.v2 = numTotalVerts - maxJ - 1;
newFace.v3 = numTotalVerts - 1;
newFace.v2 = numTotalVerts - 1;
newFace.v3 = numTotalVerts - maxJ - 1;
faces.Add(newFace);
}

View File

@ -13405,6 +13405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List<string> param = new List<string>();
bool ok;
Int32 flag;
int nCustomHeaders = 0;
for (int i = 0; i < parameters.Data.Length; i += 2)
{
@ -13431,6 +13432,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Second Life documentation for llHTTPRequest.
for (int count = 1; count <= 8; ++count)
{
if(nCustomHeaders >= 8)
{
Error("llHTTPRequest", "Max number of custom headers is 8, excess ignored");
break;
}
//Enough parameters remaining for (another) header?
if (parameters.Data.Length - i < 2)
{
@ -13445,15 +13452,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
param.Add(parameters.Data[i].ToString());
param.Add(parameters.Data[i+1].ToString());
nCustomHeaders++;
//Have we reached the end of the list of headers?
//End is marked by a string with a single digit.
if (i+2 >= parameters.Data.Length ||
Char.IsDigit(parameters.Data[i].ToString()[0]))
if (i + 2 >= parameters.Data.Length ||
Char.IsDigit(parameters.Data[i + 2].ToString()[0]))
{
break;
}
i += 2;
}
}

View File

@ -87,17 +87,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
uint port = 9999;
MainServer.RemoveHttpServer(port);
BaseHttpServer server = new BaseHttpServer(port, false, "", "", "");
m_engine = new MockScriptEngine();
m_urlModule = new UrlModule();
IConfigSource config = new IniConfigSource();
config.AddConfig("Network");
config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1");
m_scene = new SceneHelpers().SetupScene();
BaseHttpServer server = new BaseHttpServer(port, false, 0, "");
MainServer.AddHttpServer(server);
MainServer.Instance = server;
server.Start();
m_engine = new MockScriptEngine();
m_urlModule = new UrlModule();
m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine, m_urlModule);
SceneHelpers.SetupSceneModules(m_scene, config, m_engine, m_urlModule);
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart);

View File

@ -909,9 +909,9 @@ namespace OpenSim.Services.GridService
private void OutputRegionsToConsoleSummary(List<RegionData> regions)
{
ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
dispTable.AddColumn("Name", 44);
dispTable.AddColumn("ID", 36);
dispTable.AddColumn("Position", 11);
dispTable.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize);
dispTable.AddColumn("ID", ConsoleDisplayUtil.UuidSize);
dispTable.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize);
dispTable.AddColumn("Size", 11);
dispTable.AddColumn("Flags", 60);

View File

@ -640,9 +640,11 @@ namespace OpenSim.Services.UserAccountService
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart);
// Get Current Outfit folder
InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(principalID, FolderType.CurrentOutfit);
InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
eyes.AssetID = AvatarWearable.DEFAULT_EYES_ASSET;
eyes.Name = "Default Eyes";
eyes.CreatorId = principalID.ToString();
eyes.AssetType = (int)AssetType.Bodypart;
@ -655,6 +657,7 @@ namespace OpenSim.Services.UserAccountService
eyes.NextPermissions = (uint)PermissionMask.All;
eyes.Flags = (uint)WearableType.Eyes;
m_InventoryService.AddItem(eyes);
CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Eyes, eyes.Name, eyes.ID, principalID, currentOutfitFolder.ID);
InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
@ -670,6 +673,7 @@ namespace OpenSim.Services.UserAccountService
shape.NextPermissions = (uint)PermissionMask.All;
shape.Flags = (uint)WearableType.Shape;
m_InventoryService.AddItem(shape);
CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shape, shape.Name, shape.ID, principalID, currentOutfitFolder.ID);
InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
@ -685,6 +689,7 @@ namespace OpenSim.Services.UserAccountService
skin.NextPermissions = (uint)PermissionMask.All;
skin.Flags = (uint)WearableType.Skin;
m_InventoryService.AddItem(skin);
CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Skin, skin.Name, skin.ID, principalID, currentOutfitFolder.ID);
InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
@ -700,6 +705,7 @@ namespace OpenSim.Services.UserAccountService
hair.NextPermissions = (uint)PermissionMask.All;
hair.Flags = (uint)WearableType.Hair;
m_InventoryService.AddItem(hair);
CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Hair, hair.Name, hair.ID, principalID, currentOutfitFolder.ID);
InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing);
@ -717,6 +723,7 @@ namespace OpenSim.Services.UserAccountService
shirt.NextPermissions = (uint)PermissionMask.All;
shirt.Flags = (uint)WearableType.Shirt;
m_InventoryService.AddItem(shirt);
CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shirt, shirt.Name, shirt.ID, principalID, currentOutfitFolder.ID);
InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
@ -732,6 +739,7 @@ namespace OpenSim.Services.UserAccountService
pants.NextPermissions = (uint)PermissionMask.All;
pants.Flags = (uint)WearableType.Pants;
m_InventoryService.AddItem(pants);
CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Pants, pants.Name, pants.ID, principalID, currentOutfitFolder.ID);
if (m_AvatarService != null)
{
@ -815,6 +823,8 @@ namespace OpenSim.Services.UserAccountService
{
// Get Clothing folder of receiver
InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing);
// Get Current Outfit folder
InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit);
if (destinationFolder == null)
throw new Exception("Cannot locate folder(s)");
@ -841,6 +851,7 @@ namespace OpenSim.Services.UserAccountService
for (int i = 0; i < wearables.Length; i++)
{
wearable = wearables[i];
m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable[0].ItemID, source);
if (wearable[0].ItemID != UUID.Zero)
{
// Get inventory item and copy it
@ -878,6 +889,9 @@ namespace OpenSim.Services.UserAccountService
AvatarWearable newWearable = new AvatarWearable();
newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
avatarAppearance.SetWearable(i, newWearable);
// Add to Current Outfit
CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
}
else
{
@ -930,6 +944,9 @@ namespace OpenSim.Services.UserAccountService
// Attach item
avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID);
// Add to Current Outfit
CreateCurrentOutfitLink(destinationItem.InvType, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
}
else
{
@ -939,6 +956,30 @@ namespace OpenSim.Services.UserAccountService
}
}
protected void CreateCurrentOutfitLink(int invType, uint itemType, string name, UUID itemID, UUID userID, UUID currentOutfitFolderUUID)
{
UUID LinkInvItem = UUID.Random();
InventoryItemBase itembase = new InventoryItemBase(LinkInvItem, userID)
{
AssetID = itemID,
AssetType = (int)AssetType.Link,
CreatorId = userID.ToString(),
InvType = invType,
Description = "",
//Folder = m_InventoryService.GetFolderForType(userID, FolderType.CurrentOutfit).ID,
Folder = currentOutfitFolderUUID,
Flags = itemType,
Name = name,
BasePermissions = (uint)PermissionMask.Copy,
CurrentPermissions = (uint)PermissionMask.Copy,
EveryOnePermissions = (uint)PermissionMask.Copy,
GroupPermissions = (uint)PermissionMask.Copy,
NextPermissions = (uint)PermissionMask.Copy
};
m_InventoryService.AddItem(itembase);
}
/// <summary>
/// Apply next owner permissions.
/// </summary>

View File

@ -0,0 +1,365 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules.World.Permissions;
using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer;
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Tests.Permissions
{
[SetUpFixture]
public class Common : OpenSimTestCase
{
public static Common TheInstance;
public static TestScene TheScene
{
get { return TheInstance.m_Scene; }
}
public static ScenePresence[] TheAvatars
{
get { return TheInstance.m_Avatars; }
}
private static string Perms = "Owner: {0}; Group: {1}; Everyone: {2}; Next: {3}";
private TestScene m_Scene;
private ScenePresence[] m_Avatars = new ScenePresence[3];
[SetUp]
public override void SetUp()
{
if (TheInstance == null)
TheInstance = this;
base.SetUp();
TestHelpers.EnableLogging();
IConfigSource config = new IniConfigSource();
config.AddConfig("Messaging");
config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
config.AddConfig("InventoryService");
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin");
m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config);
// Add modules
SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule());
SetUpBasicEnvironment();
}
/// <summary>
/// The basic environment consists of:
/// - 3 avatars: A1, A2, A3
/// - 6 simple boxes inworld belonging to A0 and with Next Owner perms:
/// C, CT, MC, MCT, MT, T
/// - Copies of all of these boxes in A0's inventory in the Objects folder
/// - One additional box inworld and in A0's inventory which is a copy of MCT, but
/// with C removed in inventory. This one is called MCT-C
/// </summary>
private void SetUpBasicEnvironment()
{
Console.WriteLine("===> SetUpBasicEnvironment <===");
// Add 3 avatars
for (int i = 0; i < 3; i++)
{
UUID id = TestHelpers.ParseTail(i + 1);
m_Avatars[i] = AddScenePresence("Bot", "Bot_" + (i+1), id);
Assert.That(m_Avatars[i], Is.Not.Null);
Assert.That(m_Avatars[i].IsChildAgent, Is.False);
Assert.That(m_Avatars[i].UUID, Is.EqualTo(id));
Assert.That(m_Scene.GetScenePresences().Count, Is.EqualTo(i + 1));
}
AddA1Object("Box C", 10, PermissionMask.Copy);
AddA1Object("Box CT", 11, PermissionMask.Copy | PermissionMask.Transfer);
AddA1Object("Box MC", 12, PermissionMask.Modify | PermissionMask.Copy);
AddA1Object("Box MCT", 13, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer);
AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer);
AddA1Object("Box T", 15, PermissionMask.Transfer);
// MCT-C
AddA1Object("Box MCT-C", 16, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer);
Thread.Sleep(5000);
InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects");
List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID);
Assert.That(items.Count, Is.EqualTo(7));
RevokePermission(0, "Box MCT-C", PermissionMask.Copy);
}
private ScenePresence AddScenePresence(string first, string last, UUID id)
{
UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_Scene, first, last, id, "pw");
ScenePresence sp = SceneHelpers.AddScenePresence(m_Scene, id);
Assert.That(m_Scene.AuthenticateHandler.GetAgentCircuitData(id), Is.Not.Null);
return sp;
}
private void AddA1Object(string name, int suffix, PermissionMask nextOwnerPerms)
{
// Create a Box. Default permissions are just T
SceneObjectGroup box = AddSceneObject(name, suffix, 1, m_Avatars[0].UUID);
Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Copy) == 0);
Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Modify) == 0);
Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Transfer) != 0);
// field = 16 is NextOwner
// set = 1 means add the permission; set = 0 means remove permission
if ((nextOwnerPerms & PermissionMask.Copy) != 0)
m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID,
((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Copy, 1);
if ((nextOwnerPerms & PermissionMask.Modify) != 0)
m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID,
((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Modify, 1);
if ((nextOwnerPerms & PermissionMask.Transfer) == 0)
m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID,
((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Transfer, 0);
PrintPerms(box);
AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name);
TakeCopyToInventory(0, box);
}
public void RevokePermission(int ownerIndex, string name, PermissionMask perm)
{
InventoryItemBase item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name);
Assert.That(item, Is.Not.Null);
// Clone it, so to avoid aliasing -- just like the viewer does.
InventoryItemBase clone = Common.TheInstance.CloneInventoryItem(item);
// Revoke the permission in this copy
clone.NextPermissions &= ~(uint)perm;
Common.TheInstance.AssertPermissions((PermissionMask)clone.NextPermissions & ~perm,
(PermissionMask)clone.NextPermissions, Common.TheInstance.IdStr(clone));
Assert.That(clone.ID == item.ID);
// Update properties of the item in inventory. This should affect the original item above.
Common.TheScene.UpdateInventoryItemAsset(m_Avatars[ownerIndex].ControllingClient, UUID.Zero, clone.ID, clone);
item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name);
Assert.That(item, Is.Not.Null);
Common.TheInstance.PrintPerms(item);
Common.TheInstance.AssertPermissions((PermissionMask)item.NextPermissions & ~perm,
(PermissionMask)item.NextPermissions, Common.TheInstance.IdStr(item));
}
public void PrintPerms(SceneObjectGroup sog)
{
Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " +
String.Format(Perms, (PermissionMask)sog.EffectiveOwnerPerms,
(PermissionMask)sog.EffectiveGroupPerms, (PermissionMask)sog.EffectiveEveryOnePerms, (PermissionMask)sog.RootPart.NextOwnerMask));
}
public void PrintPerms(InventoryItemBase item)
{
Console.WriteLine("Inv " + item.Name + " (" + item.Owner.ToString().Substring(34) + "): " +
String.Format(Perms, (PermissionMask)item.BasePermissions,
(PermissionMask)item.GroupPermissions, (PermissionMask)item.EveryOnePermissions, (PermissionMask)item.NextPermissions));
}
public void AssertPermissions(PermissionMask desired, PermissionMask actual, string message)
{
if ((desired & PermissionMask.Copy) != 0)
Assert.True((actual & PermissionMask.Copy) != 0, message);
else
Assert.True((actual & PermissionMask.Copy) == 0, message);
if ((desired & PermissionMask.Modify) != 0)
Assert.True((actual & PermissionMask.Modify) != 0, message);
else
Assert.True((actual & PermissionMask.Modify) == 0, message);
if ((desired & PermissionMask.Transfer) != 0)
Assert.True((actual & PermissionMask.Transfer) != 0, message);
else
Assert.True((actual & PermissionMask.Transfer) == 0, message);
}
public SceneObjectGroup AddSceneObject(string name, int suffix, int partsToTestCount, UUID ownerID)
{
SceneObjectGroup so = SceneHelpers.CreateSceneObject(partsToTestCount, ownerID, name, suffix);
so.Name = name;
so.Description = name;
Assert.That(m_Scene.AddNewSceneObject(so, false), Is.True);
SceneObjectGroup retrievedSo = m_Scene.GetSceneObjectGroup(so.UUID);
// If the parts have the same UUID then we will consider them as one and the same
Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount));
return so;
}
public void TakeCopyToInventory(int userIndex, SceneObjectGroup sog)
{
InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[userIndex].UUID, "Objects");
Assert.That(objsFolder, Is.Not.Null);
List<uint> localIds = new List<uint>(); localIds.Add(sog.LocalId);
// This is an async operation
m_Scene.DeRezObjects((IClientAPI)m_Avatars[userIndex].ClientView, localIds, m_Avatars[userIndex].UUID, DeRezAction.TakeCopy, objsFolder.ID);
}
public InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName)
{
InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, userID, folderName);
Assert.That(objsFolder, Is.Not.Null);
List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(userID, objsFolder.ID);
InventoryItemBase item = items.Find(i => i.Name == itemName);
Assert.That(item, Is.Not.Null);
return item;
}
public InventoryItemBase CloneInventoryItem(InventoryItemBase item)
{
InventoryItemBase clone = new InventoryItemBase(item.ID);
clone.Name = item.Name;
clone.Description = item.Description;
clone.AssetID = item.AssetID;
clone.AssetType = item.AssetType;
clone.BasePermissions = item.BasePermissions;
clone.CreatorId = item.CreatorId;
clone.CurrentPermissions = item.CurrentPermissions;
clone.EveryOnePermissions = item.EveryOnePermissions;
clone.Flags = item.Flags;
clone.Folder = item.Folder;
clone.GroupID = item.GroupID;
clone.GroupOwned = item.GroupOwned;
clone.GroupPermissions = item.GroupPermissions;
clone.InvType = item.InvType;
clone.NextPermissions = item.NextPermissions;
clone.Owner = item.Owner;
return clone;
}
public void DeleteObjectsFolders()
{
// Delete everything in A2 and A3's Objects folders, so we can restart
for (int i = 1; i < 3; i++)
{
InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[i].UUID, "Objects");
Assert.That(objsFolder, Is.Not.Null);
List<InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID);
List<UUID> ids = new List<UUID>();
foreach (InventoryItemBase it in items)
ids.Add(it.ID);
Common.TheScene.InventoryService.DeleteItems(Common.TheAvatars[i].UUID, ids);
items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID);
Assert.That(items.Count, Is.EqualTo(0), "A" + (i + 1));
}
}
public string IdStr(InventoryItemBase item)
{
return item.Owner.ToString().Substring(34) + " : " + item.Name;
}
public string IdStr(SceneObjectGroup sog)
{
return sog.OwnerID.ToString().Substring(34) + " : " + sog.Name;
}
public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp)
{
TestClient giverClient = (TestClient)giverSp.ControllingClient;
TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
UUID initialSessionId = TestHelpers.ParseTail(0x10);
byte[] giveImBinaryBucket = new byte[17];
byte[] itemIdBytes = itemId.GetBytes();
Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
GridInstantMessage giveIm
= new GridInstantMessage(
m_Scene,
giverSp.UUID,
giverSp.Name,
receiverSp.UUID,
(byte)InstantMessageDialog.InventoryOffered,
false,
"inventory offered msg",
initialSessionId,
false,
Vector3.Zero,
giveImBinaryBucket,
true);
giverClient.HandleImprovedInstantMessage(giveIm);
// These details might not all be correct.
GridInstantMessage acceptIm
= new GridInstantMessage(
m_Scene,
receiverSp.UUID,
receiverSp.Name,
giverSp.UUID,
(byte)InstantMessageDialog.InventoryAccepted,
false,
"inventory accepted msg",
initialSessionId,
false,
Vector3.Zero,
null,
true);
receiverClient.HandleImprovedInstantMessage(acceptIm);
}
}
}

View File

@ -0,0 +1,146 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Tests.Permissions
{
/// <summary>
/// Basic scene object tests (create, read and delete but not update).
/// </summary>
[TestFixture]
public class DirectTransferTests
{
[SetUp]
public void SetUp()
{
Common.TheInstance.DeleteObjectsFolders();
}
/// <summary>
/// Test giving simple objecta with various combinations of next owner perms.
/// </summary>
[Test]
public void TestGiveBox()
{
TestHelpers.InMethod();
// C, CT, MC, MCT, MT, T
string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" };
PermissionMask[] perms = new PermissionMask[6] {
PermissionMask.Copy,
PermissionMask.Copy | PermissionMask.Transfer,
PermissionMask.Modify | PermissionMask.Copy,
PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer,
PermissionMask.Modify | PermissionMask.Transfer,
PermissionMask.Transfer
};
for (int i = 0; i < 6; i++)
TestOneBox(names[i], perms[i]);
}
private void TestOneBox(string name, PermissionMask mask)
{
InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name);
Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]);
item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name);
// Check the receiver
Common.TheInstance.PrintPerms(item);
Common.TheInstance.AssertPermissions(mask, (PermissionMask)item.BasePermissions, item.Owner.ToString().Substring(34) + " : " + item.Name);
int nObjects = Common.TheScene.GetSceneObjectGroups().Count;
// Rez it and check perms in scene too
Common.TheScene.RezObject(Common.TheAvatars[1].ControllingClient, item.ID, UUID.Zero, Vector3.One, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero);
Assert.That(Common.TheScene.GetSceneObjectGroups().Count, Is.EqualTo(nObjects + 1));
SceneObjectGroup box = Common.TheScene.GetSceneObjectGroups().Find(sog => sog.OwnerID == Common.TheAvatars[1].UUID && sog.Name == name);
Common.TheInstance.PrintPerms(box);
Assert.That(box, Is.Not.Null);
// Check Owner permissions
Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.EffectiveOwnerPerms, box.OwnerID.ToString().Substring(34) + " : " + box.Name);
// Check Next Owner permissions
Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name);
}
/// <summary>
/// Test giving simple objecta with variour combinations of next owner perms.
/// </summary>
[Test]
public void TestDoubleGiveWithChange()
{
TestHelpers.InMethod();
string name = "Box MCT-C";
InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name);
// Now give the item to A2. We give the original item, not a clone.
// The giving methods are supposed to duplicate it.
Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]);
item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name);
// Check the receiver
Common.TheInstance.PrintPerms(item);
Common.TheInstance.AssertPermissions(PermissionMask.Modify | PermissionMask.Transfer,
(PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
// ---------------------------
// Second transfer
//----------------------------
// A2 revokes M
Common.TheInstance.RevokePermission(1, name, PermissionMask.Modify);
item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name);
// Now give the item to A3. We give the original item, not a clone.
// The giving methods are supposed to duplicate it.
Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[1], Common.TheAvatars[2]);
item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[2].UUID, "Objects", name);
// Check the receiver
Common.TheInstance.PrintPerms(item);
Common.TheInstance.AssertPermissions(PermissionMask.Transfer,
(PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
}
}
}

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using System.Threading;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Tests.Permissions
{
/// <summary>
/// Basic scene object tests (create, read and delete but not update).
/// </summary>
[TestFixture]
public class IndirectTransferTests
{
[SetUp]
public void SetUp()
{
Common.TheInstance.DeleteObjectsFolders();
}
/// <summary>
/// Test giving simple objecta with various combinations of next owner perms.
/// </summary>
[Test]
public void SimpleTakeCopy()
{
TestHelpers.InMethod();
// The Objects folder of A2
InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[1].UUID, "Objects");
// C, CT, MC, MCT, MT, T
string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" };
PermissionMask[] perms = new PermissionMask[6] {
PermissionMask.Copy,
PermissionMask.Copy | PermissionMask.Transfer,
PermissionMask.Modify | PermissionMask.Copy,
PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer,
PermissionMask.Modify | PermissionMask.Transfer,
PermissionMask.Transfer
};
// Try A2 takes copies of objects that cannot be copied.
for (int i = 0; i < 6; i++)
TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]);
Thread.Sleep(5000);
List<InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID);
Assert.That(items.Count, Is.EqualTo(0));
// A1 makes the objects copyable
for (int i = 0; i < 6; i++)
MakeCopyable(Common.TheScene.GetSceneObjectGroups(), names[i]);
// Try A2 takes copies of objects that can be copied.
for (int i = 0; i < 6; i++)
TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]);
Thread.Sleep(5000);
items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID);
Assert.That(items.Count, Is.EqualTo(6));
for (int i = 0; i < 6; i++)
{
InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", names[i]);
Assert.That(item, Is.Not.Null);
Common.TheInstance.AssertPermissions(perms[i], (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
}
}
private void TakeOneBox(List<SceneObjectGroup> objs, string name, PermissionMask mask)
{
SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID);
Assert.That(box, Is.Not.Null, name);
// A2's inventory (index 1)
Common.TheInstance.TakeCopyToInventory(1, box);
}
private void MakeCopyable(List<SceneObjectGroup> objs, string name)
{
SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID);
Assert.That(box, Is.Not.Null, name);
// field = 8 is Everyone
// set = 1 means add the permission; set = 0 means remove permission
Common.TheScene.HandleObjectPermissionsUpdate((IClientAPI)Common.TheAvatars[0].ClientView, Common.TheAvatars[0].UUID,
Common.TheAvatars[0].ControllingClient.SessionId, 8, box.LocalId, (uint)PermissionMask.Copy, 1);
Common.TheInstance.PrintPerms(box);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -49,19 +49,13 @@
; this section defines constants for grid services
; to simplify other configuration files default settings
; BaseURL
; should be the externally accessible IP/DNS name of grid or standalone
; http://externalHostName or https://externalHostName if using ssl
; examples: http://mymachine.example.com, https://mymachine.example.com, https://127.0.0.1
; default: http://127.0.0.1
;# {BaseURL} {} {BaseURL} {"http://example.com" "http://127.0.0.1"} ""
BaseURL = http://127.0.0.1
;# {BaseHostname} {} {BaseHostname} {"example.com" "127.0.0.1"} "127.0.0.1"
BaseHostname = "127.0.0.1"
; default public port
; usually 8002 for grids.
; on standalones it needs to match http_listener_port or http_listener_sslport if using ssl
; in [Network] section below (defaults 9000 or 9001 if using ssl)
;# {PublicPort} {} {PublicPort} {8002 9000 9001} "8002"
;# {BaseURL} {} {BaseURL} {"http://${Const|BaseHostname}} "http://${Const|BaseHostname}"
BaseURL = http://${Const|BaseHostname}
;# {PublicPort} {} {PublicPort} {8002 9000} "8002"
PublicPort = "8002"
;grid default private port 8003, not used in standalone
@ -569,9 +563,8 @@
;# {ExternalHostNameForLSL} {} {Hostname to use for HTTP-IN URLs. This should be reachable from the internet.} {}
;; Hostname to use in llRequestURL/llRequestSecureURL
;; if not defined - default machine name is being used
;; (on Windows this mean NETBIOS name - useably only inside local network)
; ExternalHostNameForLSL = "127.0.0.1"
;; if not defined - llRequestURL/llRequestSecureURL are disabled
ExternalHostNameForLSL = ${Const|BaseHostname}
;# {shard} {} {Name to use for X-Secondlife-Shard header? (press enter if unsure)} {} OpenSim
;; What is reported as the "X-Secondlife-Shard"

View File

@ -614,8 +614,7 @@
; Hostname to use in llRequestURL/llRequestSecureURL
; must be a valid hostname for the ssl cert.
; if not defined - default machine name is being used
; (on Windows this mean NETBIOS name - useably only inside local network)
; if not defined - llRequestURL/llRequestSecureURL are disabled
; ExternalHostNameForLSL=127.0.0.1
; Disallow the following address ranges for user scripting calls (e.g. llHttpRequest())
@ -1913,7 +1912,8 @@
; regex specifying for which regions concierge service is desired; if
; empty, then for all
regions = "^MeetingSpace-"
;regions = "^MeetingSpace-"
regions = ""
; for each region that matches the regions regexp you can provide
; (optionally) a welcome template using format substitution:
@ -1921,14 +1921,14 @@
; {1} is replaced with the name of the region
; {2} is replaced with the name of the concierge (whoami variable above)
welcomes = /path/to/welcome/template/directory
;welcomes = /path/to/welcome/template/directory
; Concierge can send attendee lists to an event broker whenever an
; avatar enters or leaves a concierged region. the URL is subject
; to format substitution:
; {0} is replaced with the region's name
; {1} is replaced with the region's UUID
broker = "http://broker.place.com/{1}"
;broker = "http://broker.place.com/{1}"
[MRM]

View File

@ -3300,6 +3300,45 @@
</Files>
</Project>
<Project frameworkVersion="v4_0" name="OpenSim.Tests.Permissions" path="OpenSim/Tests/Permissions" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="System.Xml"/>
<Reference name="Mono.Addins" path="../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenSim"/>
<Reference name="OpenSim.ApplicationPlugins.RegionModulesController"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Services.Interfaces"/>
<!-- Unit tests -->
<!-- <Reference name="OpenSim.Tests.Common"/> -->
<Reference name="OpenSim.Tests.Common"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="nunit.framework" path="../../../bin/"/>
<Reference name="log4net" path="../../../bin/"/>
<Files>
<Match pattern="*.cs" recurse="false"/>
</Files>
</Project>
<?include file="addon-modules/*/prebuild*.xml" ?>
</Solution>