From 319bbce5176b5ba667bfc720f4cfd963ee937455 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Jul 2014 21:32:20 +0100 Subject: If REMOVEAGENTFROMGROUP core groups call fails because requesting agent does not have sufficient permission, return null failure result rather than true. On non-HG this is on the only recognized failure state so we can return more information in the error result. On HG there are multiple failure states which would require more work to distinguish, so currently return the unsatisfying "Internal Error" like some other existing calls. --- .../Groups/Hypergrid/HGGroupsServiceRobustConnector.cs | 7 ++++--- OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs | 7 ++++--- OpenSim/Addons/Groups/Service/GroupsService.cs | 6 ++++-- OpenSim/Addons/Groups/Service/HGGroupsService.cs | 12 ++++++++++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs index 207d810..f60c1a5 100644 --- a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs @@ -209,9 +209,10 @@ namespace OpenSim.Groups string agentID = request["AgentID"].ToString(); string token = request["AccessToken"].ToString(); - m_GroupsService.RemoveAgentFromGroup(agentID, agentID, groupID, token); - - result["RESULT"] = "true"; + if (!m_GroupsService.RemoveAgentFromGroup(agentID, agentID, groupID, token)) + NullResult(result, "Internal error"); + else + result["RESULT"] = "true"; } //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 5cf6ec7..26e844e 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs @@ -285,9 +285,10 @@ namespace OpenSim.Groups string agentID = request["AgentID"].ToString(); string requestingAgentID = request["RequestingAgentID"].ToString(); - m_GroupsService.RemoveAgentFromGroup(requestingAgentID, agentID, groupID); - - result["RESULT"] = "true"; + if (!m_GroupsService.RemoveAgentFromGroup(requestingAgentID, agentID, groupID)) + NullResult(result, string.Format("Insufficient permissions.", agentID)); + else + result["RESULT"] = "true"; } //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); diff --git a/OpenSim/Addons/Groups/Service/GroupsService.cs b/OpenSim/Addons/Groups/Service/GroupsService.cs index 037ef59..f44c094 100644 --- a/OpenSim/Addons/Groups/Service/GroupsService.cs +++ b/OpenSim/Addons/Groups/Service/GroupsService.cs @@ -393,13 +393,15 @@ namespace OpenSim.Groups return true; } - public void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID) + public bool RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID) { // check perms if (RequestingAgentID != AgentID && !HasPower(RequestingAgentID, GroupID, GroupPowers.Eject)) - return; + return false; _RemoveAgentFromGroup(RequestingAgentID, AgentID, GroupID); + + return true; } public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID) diff --git a/OpenSim/Addons/Groups/Service/HGGroupsService.cs b/OpenSim/Addons/Groups/Service/HGGroupsService.cs index 9d7961c..56e999b 100644 --- a/OpenSim/Addons/Groups/Service/HGGroupsService.cs +++ b/OpenSim/Addons/Groups/Service/HGGroupsService.cs @@ -131,19 +131,27 @@ namespace OpenSim.Groups return true; } - public void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID, string token) + public bool RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID, string token) { // check the token MembershipData membership = m_Database.RetrieveMember(GroupID, AgentID); if (membership != null) { if (token != string.Empty && token.Equals(membership.Data["AccessToken"])) - RemoveAgentFromGroup(RequestingAgentID, AgentID, GroupID); + { + return RemoveAgentFromGroup(RequestingAgentID, AgentID, GroupID); + } else + { m_log.DebugFormat("[Groups.HGGroupsService]: access token {0} did not match stored one {1}", token, membership.Data["AccessToken"]); + return false; + } } else + { m_log.DebugFormat("[Groups.HGGroupsService]: membership not found for {0}", AgentID); + return false; + } } public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string groupName, string token) -- cgit v1.1