diff options
author | BlueWall | 2015-02-27 11:05:15 -0500 |
---|---|---|
committer | BlueWall | 2015-02-27 11:05:15 -0500 |
commit | a3681f3052fb5e98e31e7051329a5b748a8bdd8d (patch) | |
tree | 44a4c6beed75c2eb829a7770c2fa4a9498068a31 | |
parent | When an avatar is walking across a region border, force the first AgentUpdate... (diff) | |
download | opensim-SC-a3681f3052fb5e98e31e7051329a5b748a8bdd8d.zip opensim-SC-a3681f3052fb5e98e31e7051329a5b748a8bdd8d.tar.gz opensim-SC-a3681f3052fb5e98e31e7051329a5b748a8bdd8d.tar.bz2 opensim-SC-a3681f3052fb5e98e31e7051329a5b748a8bdd8d.tar.xz |
Adding dynamic ossl permission control
Add permission by identifying uuid (owner/creator/group) and function. Revoke
permission in the same manner. Permission adjustments immediately effect
running scripts ability to call os functions.
osGrantScriptPermissions(UUID key,string function) Threat Level Severe
osRevokeScriptPermissions(UUID key,string function) Threat Level Severe
work sponsored by: Rage
4 files changed, 119 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 21d47aa..018e837 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -170,6 +170,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
170 | } | 170 | } |
171 | private bool m_scripts_enabled; | 171 | private bool m_scripts_enabled; |
172 | 172 | ||
173 | // Dynamic ossl function permissions | ||
174 | private Dictionary<string, List<UUID>> m_DynaPerms = new Dictionary<string, List<UUID>>(); | ||
175 | |||
173 | public SynchronizeSceneHandler SynchronizeScene; | 176 | public SynchronizeSceneHandler SynchronizeScene; |
174 | 177 | ||
175 | /// <summary> | 178 | /// <summary> |
@@ -5893,5 +5896,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
5893 | 5896 | ||
5894 | m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); | 5897 | m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); |
5895 | } | 5898 | } |
5899 | |||
5900 | public bool AddOsslPerm (UUID key, string function) | ||
5901 | { | ||
5902 | StackTrace calls = new StackTrace (); | ||
5903 | string caller = calls.GetFrame (1).GetMethod ().Name; | ||
5904 | if (caller != "osGrantScriptPermissions") | ||
5905 | { | ||
5906 | m_log.ErrorFormat("[SCENE]: {0} cannot adjust script perms!",caller); | ||
5907 | return false; | ||
5908 | } | ||
5909 | |||
5910 | if (string.IsNullOrEmpty(function)) | ||
5911 | return false; | ||
5912 | |||
5913 | if (!m_DynaPerms.ContainsKey(function)) | ||
5914 | { | ||
5915 | List<UUID> keys = new List<UUID> (); | ||
5916 | keys.Add (key); | ||
5917 | m_DynaPerms[function] = keys; | ||
5918 | return true; | ||
5919 | } | ||
5920 | |||
5921 | if (!m_DynaPerms[function].Contains(key)) | ||
5922 | m_DynaPerms[function].Add(key); | ||
5923 | |||
5924 | return true; | ||
5925 | } | ||
5926 | |||
5927 | public bool GetOsslPerms(UUID avatar, string function) | ||
5928 | { | ||
5929 | if (m_DynaPerms.ContainsKey(function)) | ||
5930 | if(m_DynaPerms[function].Contains(avatar)) | ||
5931 | return true; | ||
5932 | |||
5933 | return false; | ||
5934 | } | ||
5935 | |||
5936 | public bool RemoveOsslPerm(UUID key, string function) | ||
5937 | { | ||
5938 | StackTrace calls = new StackTrace (); | ||
5939 | string caller = calls.GetFrame (1).GetMethod ().Name; | ||
5940 | if (caller != "osRevokeScriptPermissions") | ||
5941 | { | ||
5942 | m_log.ErrorFormat("[SCENE]: {0} cannot adjust script perms!",caller); | ||
5943 | return false; | ||
5944 | } | ||
5945 | |||
5946 | if (m_DynaPerms.ContainsKey (function)) | ||
5947 | { | ||
5948 | if (m_DynaPerms [function].Contains (key)) | ||
5949 | { | ||
5950 | m_DynaPerms [function].Remove (key); | ||
5951 | if (m_DynaPerms [function].Count == 0) | ||
5952 | m_DynaPerms.Remove (function); | ||
5953 | } | ||
5954 | } | ||
5955 | return true; | ||
5956 | } | ||
5896 | } | 5957 | } |
5897 | } | 5958 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 10ddf14..f4bc45f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -264,6 +264,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
264 | // or a string explaining why this function can't be used. | 264 | // or a string explaining why this function can't be used. |
265 | private string CheckThreatLevelTest(ThreatLevel level, string function) | 265 | private string CheckThreatLevelTest(ThreatLevel level, string function) |
266 | { | 266 | { |
267 | if(GetDynaPerms(m_item.CreatorID, m_item.OwnerID, m_item.GroupID, function)) | ||
268 | return string.Empty; | ||
269 | |||
267 | if (!m_FunctionPerms.ContainsKey(function)) | 270 | if (!m_FunctionPerms.ContainsKey(function)) |
268 | { | 271 | { |
269 | FunctionPerms perms = new FunctionPerms(); | 272 | FunctionPerms perms = new FunctionPerms(); |
@@ -431,6 +434,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
431 | System.Threading.Thread.Sleep(delay); | 434 | System.Threading.Thread.Sleep(delay); |
432 | } | 435 | } |
433 | 436 | ||
437 | private bool GetDynaPerms(UUID owner, UUID creator, UUID group, string function) | ||
438 | { | ||
439 | if (World.GetOsslPerms(owner, function)) | ||
440 | return true; | ||
441 | if (World.GetOsslPerms(creator, function)) | ||
442 | return true; | ||
443 | if (World.GetOsslPerms(creator, function)) | ||
444 | return true; | ||
445 | |||
446 | return false; | ||
447 | |||
448 | } | ||
449 | |||
450 | public void osGrantScriptPermissions(LSL_Key avatar, LSL_List osfunctions) | ||
451 | { | ||
452 | CheckThreatLevel(ThreatLevel.Severe, "osGrantScriptPermissions"); | ||
453 | m_host.AddScriptLPS(1); | ||
454 | UUID key; | ||
455 | UUID.TryParse(avatar.m_string, out key); | ||
456 | |||
457 | for (int item = 0; item <= osfunctions.Length - 1; item++) | ||
458 | { | ||
459 | string function = osfunctions.GetLSLStringItem(item); | ||
460 | World.AddOsslPerm(key, function); | ||
461 | } | ||
462 | } | ||
463 | |||
464 | public void osRevokeScriptPermissions (LSL_Key avatar, LSL_List osfunctions) | ||
465 | { | ||
466 | CheckThreatLevel(ThreatLevel.Severe, "osRevokeScriptPermissions"); | ||
467 | m_host.AddScriptLPS(1); | ||
468 | UUID key; | ||
469 | UUID.TryParse(avatar.m_string, out key); | ||
470 | |||
471 | for (int item = 0; item <= osfunctions.Length - 1; item++) | ||
472 | { | ||
473 | string function = osfunctions.GetLSLStringItem(item); | ||
474 | World.RemoveOsslPerm(key, function); | ||
475 | } | ||
476 | } | ||
477 | |||
434 | public LSL_Integer osSetTerrainHeight(int x, int y, double val) | 478 | public LSL_Integer osSetTerrainHeight(int x, int y, double val) |
435 | { | 479 | { |
436 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); | 480 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 38d4574..2cbaf5a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -116,6 +116,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
116 | { | 116 | { |
117 | void CheckThreatLevel(ThreatLevel level, string function); | 117 | void CheckThreatLevel(ThreatLevel level, string function); |
118 | 118 | ||
119 | // Scripted Script Permissions | ||
120 | void osGrantScriptPermissions(LSL_Key avatar, LSL_List functions); | ||
121 | void osRevokeScriptPermissions(LSL_Key avatar, LSL_List functions); | ||
122 | |||
119 | //OpenSim functions | 123 | //OpenSim functions |
120 | string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); | 124 | string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); |
121 | string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, | 125 | string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 352a35d..a98f6ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -61,6 +61,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
61 | Prim = new OSSLPrim(this); | 61 | Prim = new OSSLPrim(this); |
62 | } | 62 | } |
63 | 63 | ||
64 | public void osGrantScriptPermissions (LSL_Key avatar, LSL_List osfunctions) | ||
65 | { | ||
66 | m_OSSL_Functions.osGrantScriptPermissions(avatar, osfunctions); | ||
67 | } | ||
68 | |||
69 | public void osRevokeScriptPermissions (LSL_Key avatar, LSL_List osfunctions) | ||
70 | { | ||
71 | m_OSSL_Functions.osRevokeScriptPermissions(avatar, osfunctions); | ||
72 | } | ||
73 | |||
64 | public void osSetRegionWaterHeight(double height) | 74 | public void osSetRegionWaterHeight(double height) |
65 | { | 75 | { |
66 | m_OSSL_Functions.osSetRegionWaterHeight(height); | 76 | m_OSSL_Functions.osSetRegionWaterHeight(height); |