Merge branch 'master' into httptests

httptests
UbitUmarov 2017-01-05 16:33:01 +00:00
commit 9d28fd41c6
10 changed files with 116 additions and 72 deletions

View File

@ -496,7 +496,7 @@ namespace OpenSim.Groups
if (!unlimited && limited)
{
// check whether person's has this role
RoleMembershipData rolemembership = m_Database.RetrieveRoleMember(GroupID, RoleID, AgentID);
RoleMembershipData rolemembership = m_Database.RetrieveRoleMember(GroupID, RoleID, RequestingAgentID);
if (rolemembership == null)
{
m_log.DebugFormat("[Groups]: ({0}) Attempt at assigning {1} to role {2} denied because of limited permission", RequestingAgentID, AgentID, RoleID);
@ -516,13 +516,26 @@ namespace OpenSim.Groups
return false;
// check permissions
bool limited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMemberLimited);
bool unlimited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMember) || IsOwner(RequestingAgentID, GroupID);
if (!unlimited)
if (!limited && !unlimited)
{
m_log.DebugFormat("[Groups]: ({0}) Attempt at removing {1} from role {2} denied because of lack of permission", RequestingAgentID, AgentID, RoleID);
return false;
}
// AssignMemberLimited means that the person can assign another person to the same roles that she has in the group
if (!unlimited && limited)
{
// check whether person's has this role
RoleMembershipData rolemembership = m_Database.RetrieveRoleMember(GroupID, RoleID, RequestingAgentID);
if (rolemembership == null)
{
m_log.DebugFormat("[Groups]: ({0}) Attempt at removing {1} from role {2} denied because of limited permission", RequestingAgentID, AgentID, RoleID);
return false;
}
}
RoleMembershipData rolemember = m_Database.RetrieveRoleMember(GroupID, RoleID, AgentID);
if (rolemember == null)
@ -812,7 +825,7 @@ namespace OpenSim.Groups
if (RoleID != UUID.Zero)
_AddAgentToGroupRole(RequestingAgentID, AgentID, GroupID, RoleID);
// Make thit this active group
// Make this the active group
PrincipalData pdata = new PrincipalData();
pdata.PrincipalID = AgentID;
pdata.ActiveGroupID = GroupID;

View File

@ -11,6 +11,6 @@ CREATE TABLE IF NOT EXISTS `im_offline` (
PRIMARY KEY (`ID`),
KEY `PrincipalID` (`PrincipalID`),
KEY `FromID` (`FromID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;

View File

@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS `prims` (
PRIMARY KEY (`UUID`),
KEY `prims_regionuuid` (`RegionUUID`),
KEY `prims_scenegroupid` (`SceneGroupID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `primshapes` (
`Shape` int(11) DEFAULT NULL,
@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS `primshapes` (
`Media` text,
`LastAttachPoint` int(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`UUID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `primitems` (
`invType` int(11) DEFAULT NULL,
@ -154,13 +154,13 @@ CREATE TABLE IF NOT EXISTS `primitems` (
`lastOwnerID` char(36) DEFAULT NULL,
PRIMARY KEY (`itemID`),
KEY `primitems_primid` (`primID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `terrain` (
`RegionUUID` varchar(255) DEFAULT NULL,
`Revision` int(11) DEFAULT NULL,
`Heightfield` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `land` (
`UUID` varchar(255) NOT NULL,
@ -204,21 +204,21 @@ CREATE TABLE IF NOT EXISTS `land` (
`ObscureMusic` tinyint(1) NOT NULL DEFAULT '0',
`ObscureMedia` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`UUID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `landaccesslist` (
`LandUUID` varchar(255) DEFAULT NULL,
`AccessUUID` varchar(255) DEFAULT NULL,
`Flags` int(11) DEFAULT NULL,
`Expires` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `regionban` (
`regionUUID` varchar(36) NOT NULL,
`bannedUUID` varchar(36) NOT NULL,
`bannedIp` varchar(16) NOT NULL,
`bannedIpHostMask` varchar(16) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `regionsettings` (
`regionUUID` char(36) NOT NULL,
@ -265,7 +265,7 @@ CREATE TABLE IF NOT EXISTS `regionsettings` (
`parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
`covenant_datetime` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`regionUUID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `regionwindlight` (
`region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000',

View File

@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `usernotes` (
`targetuuid` varchar(36) NOT NULL,
`notes` text NOT NULL,
UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `userpicks` (
@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `userpicks` (
`enabled` enum('true','false') NOT NULL,
`gatekeeper` varchar(255),
PRIMARY KEY (`pickuuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `userprofile` (
@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS `userprofile` (
`profileFirstImage` varchar(36) NOT NULL,
`profileFirstText` text NOT NULL,
PRIMARY KEY (`useruuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `userdata` (
`UserId` char(36) NOT NULL,
@ -73,7 +73,7 @@ CREATE TABLE IF NOT EXISTS `userdata` (
`DataKey` varchar(255),
`DataVal` varchar(255),
PRIMARY KEY (`UserId`,`TagId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `usersettings` (
`useruuid` varchar(36) NOT NULL,
@ -81,6 +81,6 @@ CREATE TABLE IF NOT EXISTS `usersettings` (
`visible` enum('true','false') NOT NULL,
`email` varchar(254) NOT NULL,
PRIMARY KEY (`useruuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
commit;

View File

@ -18,7 +18,7 @@ CREATE TABLE `os_groups_groups` (
PRIMARY KEY (`GroupID`),
UNIQUE KEY `Name` (`Name`),
FULLTEXT KEY `Name_2` (`Name`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
CREATE TABLE `os_groups_membership` (
@ -31,7 +31,7 @@ CREATE TABLE `os_groups_membership` (
`AccessToken` char(36) NOT NULL default '',
PRIMARY KEY (`GroupID`,`PrincipalID`),
KEY `PrincipalID` (`PrincipalID`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
CREATE TABLE `os_groups_roles` (
@ -43,7 +43,7 @@ CREATE TABLE `os_groups_roles` (
`Powers` bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (`GroupID`,`RoleID`),
KEY `GroupID` (`GroupID`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
CREATE TABLE `os_groups_rolemembership` (
@ -52,7 +52,7 @@ CREATE TABLE `os_groups_rolemembership` (
`PrincipalID` VARCHAR(255) NOT NULL default '',
PRIMARY KEY (`GroupID`,`RoleID`,`PrincipalID`),
KEY `PrincipalID` (`PrincipalID`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
CREATE TABLE `os_groups_invites` (
@ -63,7 +63,7 @@ CREATE TABLE `os_groups_invites` (
`TMStamp` timestamp NOT NULL,
PRIMARY KEY (`InviteID`),
UNIQUE KEY `PrincipalGroup` (`GroupID`,`PrincipalID`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
CREATE TABLE `os_groups_notices` (
@ -81,13 +81,13 @@ CREATE TABLE `os_groups_notices` (
PRIMARY KEY (`NoticeID`),
KEY `GroupID` (`GroupID`),
KEY `TMStamp` (`TMStamp`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
CREATE TABLE `os_groups_principals` (
`PrincipalID` VARCHAR(255) NOT NULL default '',
`ActiveGroupID` char(36) NOT NULL default '',
PRIMARY KEY (`PrincipalID`)
) ENGINE=MyISAM;
) ENGINE=InnoDB;
COMMIT;

View File

@ -71,6 +71,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
public event ChangeDelegate OnRegionInfoChange;
public event ChangeDelegate OnEstateInfoChange;
public event MessageDelegate OnEstateMessage;
public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
private int m_delayCount = 0;
@ -1193,13 +1195,20 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
{
EstateTeleportOneUserHomeRequest evOverride = OnEstateTeleportOneUserHomeRequest;
if(evOverride != null)
{
evOverride(remover_client, invoice, senderID, prey);
return;
}
if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
return;
if (prey != UUID.Zero)
{
ScenePresence s = Scene.GetScenePresence(prey);
if (s != null)
if (s != null && !s.IsDeleted && !s.IsInTransit)
{
if (!Scene.TeleportClientHome(prey, s.ControllingClient))
{
@ -1212,6 +1221,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
{
EstateTeleportAllUsersHomeRequest evOverride = OnEstateTeleportAllUsersHomeRequest;
if(evOverride != null)
{
evOverride(remover_client, invoice, senderID);
return;
}
if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
return;

View File

@ -46,16 +46,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected XEstateModule m_EstateModule;
private string token;
public EstateConnector(XEstateModule module)
public EstateConnector(XEstateModule module, string _token)
{
m_EstateModule = module;
token = _token;
}
public void SendTeleportHomeOneUser(uint EstateID, UUID PreyID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "teleport_home_one_user";
sendData["TOKEN"] = token;
sendData["EstateID"] = EstateID.ToString();
sendData["PreyID"] = PreyID.ToString();
@ -67,6 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "teleport_home_all_users";
sendData["TOKEN"] = token;
sendData["EstateID"] = EstateID.ToString();
@ -77,6 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "update_covenant";
sendData["TOKEN"] = token;
sendData["CovenantID"] = CovenantID.ToString();
sendData["EstateID"] = EstateID.ToString();
@ -99,6 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "update_estate";
sendData["TOKEN"] = token;
sendData["EstateID"] = EstateID.ToString();
@ -119,6 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "estate_message";
sendData["TOKEN"] = token;
sendData["EstateID"] = EstateID.ToString();
sendData["FromID"] = FromID.ToString();
@ -132,47 +139,43 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
List<UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID);
UUID ScopeID = UUID.Zero;
// Don't send to the same instance twice
List<string> done = new List<string>();
// Handle local regions locally
//
lock (m_EstateModule.Scenes)
{
foreach (Scene s in m_EstateModule.Scenes)
{
if (regions.Contains(s.RegionInfo.RegionID))
RegionInfo sreg = s.RegionInfo;
if (regions.Contains(sreg.RegionID))
{
// All regions in one estate are in the same scope.
// Use that scope.
//
ScopeID = s.RegionInfo.ScopeID;
regions.Remove(s.RegionInfo.RegionID);
string url = sreg.ExternalHostName + ":" + sreg.HttpPort;
regions.Remove(sreg.RegionID);
if(!done.Contains(url)) // we may have older regs with same url lost in dbs
done.Add(url);
}
}
}
// Our own region should always be in the above list.
// In a standalone this would not be true. But then,
// Scope ID is not relevat there. Use first scope.
//
if (ScopeID == UUID.Zero)
ScopeID = m_EstateModule.Scenes[0].RegionInfo.ScopeID;
if(regions.Count == 0)
return;
// Don't send to the same instance twice
//
List<string> done = new List<string>();
Scene baseScene = m_EstateModule.Scenes[0];
UUID ScopeID = baseScene.RegionInfo.ScopeID;
IGridService gridService = baseScene.GridService;
if(gridService == null)
return;
// Send to remote regions
//
foreach (UUID regionID in regions)
{
GridRegion region = m_EstateModule.Scenes[0].GridService.GetRegionByUUID(ScopeID, regionID);
GridRegion region = gridService.GetRegionByUUID(ScopeID, regionID);
if (region != null)
{
string url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
string url = region.ExternalHostName + ":" + region.HttpPort;
if(done.Contains(url))
continue;
Call(region, sendData);
done.Add(url);
}
@ -185,7 +188,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
// m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString);
try
{
string url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
string url = "";
if(string.IsNullOrEmpty(region.ServerURI))
url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
else
url = region.ServerURI;
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
url + "/estate",
reqString);

View File

@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
protected List<Scene> m_Scenes = new List<Scene>();
protected bool m_InInfoUpdate = false;
private string token = "7db8eh2gvgg45jj";
public bool InInfoUpdate
{
@ -69,17 +70,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
int port = 0;
IConfig estateConfig = config.Configs["Estate"];
IConfig estateConfig = config.Configs["Estates"];
if (estateConfig != null)
{
port = estateConfig.GetInt("Port", 0);
// this will need to came from somewhere else
token = estateConfig.GetString("Token", token);
}
m_EstateConnector = new EstateConnector(this);
m_EstateConnector = new EstateConnector(this, token);
// Instantiate the request handler
IHttpServer server = MainServer.GetHttpServer((uint)port);
server.AddStreamHandler(new EstateRequestHandler(this));
server.AddStreamHandler(new EstateRequestHandler(this, token));
}
public void PostInitialise()
@ -94,8 +97,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
lock (m_Scenes)
m_Scenes.Add(scene);
scene.EventManager.OnNewClient += OnNewClient;
}
public void RegionLoaded(Scene scene)
@ -105,12 +106,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
em.OnRegionInfoChange += OnRegionInfoChange;
em.OnEstateInfoChange += OnEstateInfoChange;
em.OnEstateMessage += OnEstateMessage;
em.OnEstateTeleportOneUserHomeRequest += OnEstateTeleportOneUserHomeRequest;
em.OnEstateTeleportAllUsersHomeRequest += OnEstateTeleportAllUsersHomeRequest;
}
public void RemoveRegion(Scene scene)
{
scene.EventManager.OnNewClient -= OnNewClient;
lock (m_Scenes)
m_Scenes.Remove(scene);
}
@ -181,13 +182,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
m_EstateConnector.SendEstateMessage(estateID, FromID, FromName, Message);
}
private void OnNewClient(IClientAPI client)
{
client.OnEstateTeleportOneUserHomeRequest += OnEstateTeleportOneUserHomeRequest;
client.OnEstateTeleportAllUsersHomeRequest += OnEstateTeleportAllUsersHomeRequest;
}
private void OnEstateTeleportOneUserHomeRequest(IClientAPI client, UUID invoice, UUID senderID, UUID prey)
{
if (prey == UUID.Zero)
@ -205,17 +199,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
foreach (Scene s in Scenes)
{
if (s == scene)
continue; // Already handles by estate module
if (s.RegionInfo.EstateSettings.EstateID != estateID)
continue;
ScenePresence p = scene.GetScenePresence(prey);
if (p != null && !p.IsChildAgent )
{
if(!p.IsDeleted && !p.IsInTransit)
{
p.ControllingClient.SendTeleportStart(16);
scene.TeleportClientHome(prey, p.ControllingClient);
}
return;
}
}
m_EstateConnector.SendTeleportHomeOneUser(estateID, prey);
@ -235,8 +231,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
foreach (Scene s in Scenes)
{
if (s == scene)
continue; // Already handles by estate module
if (s.RegionInfo.EstateSettings.EstateID != estateID)
continue;

View File

@ -48,11 +48,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
protected XEstateModule m_EstateModule;
protected Object m_RequestLock = new Object();
private string token;
public EstateRequestHandler(XEstateModule fmodule)
public EstateRequestHandler(XEstateModule fmodule, string _token)
: base("POST", "/estate")
{
m_EstateModule = fmodule;
token = _token;
}
protected override byte[] ProcessRequest(string path, Stream requestData,
@ -75,6 +77,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!request.ContainsKey("METHOD"))
return FailureResult();
if (!request.ContainsKey("TOKEN"))
return FailureResult();
string reqToken = request["TOKEN"].ToString();
request.Remove("TOKEN");
if(token != reqToken)
return FailureResult();
string method = request["METHOD"].ToString();
request.Remove("METHOD");

View File

@ -39,6 +39,8 @@ namespace OpenSim.Region.Framework.Interfaces
event ChangeDelegate OnRegionInfoChange;
event ChangeDelegate OnEstateInfoChange;
event MessageDelegate OnEstateMessage;
event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
uint GetRegionFlags();
bool IsManager(UUID avatarID);