From c9f494c00e97cca24bc4fd264ece1fc3382bb96b Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 8 Aug 2014 16:44:22 -0400 Subject: [PATCH] Added RestrictEmail to make llEmail only send to avatars email address if true. --- .../Shared/Api/Implementation/LSL_Api.cs | 34 +++++++++++++++++++ bin/OpenSimDefaults.ini | 5 +++ 2 files changed, 39 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 991107ea46..0e6e8bbd71 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -120,6 +120,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected IUrlModule m_UrlModule = null; protected Dictionary m_userInfoCache = new Dictionary(); protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. + protected string m_internalObjectHost = "lsl.opensim.local"; + protected bool m_restrictEmail = false; protected ISoundModule m_SoundModule = null; //An array of HTTP/1.1 headers that are not allowed to be used @@ -193,11 +195,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (seConfigSource != null) { + IConfig lslConfig = seConfigSource.Configs["LL-Functions"]; + if (lslConfig != null) + { + m_restrictEmail = lslConfig.GetBoolean("RestrictEmail", m_restrictEmail); + } + IConfig smtpConfig = seConfigSource.Configs["SMTP"]; if (smtpConfig != null) { // there's an smtp config, so load in the snooze time. EMAIL_PAUSE_TIME = smtpConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); + + m_internalObjectHost = smtpConfig.GetString("internal_object_host", m_internalObjectHost); } } } @@ -3387,6 +3397,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } + //Restrict email destination to the avatars registered email address? + //The restriction only applies if the destination address is not local. + if (m_restrictEmail == true && address.Contains(m_internalObjectHost) == false) + { + UserAccount account = + World.UserAccountService.GetUserAccount( + World.RegionInfo.ScopeID, + m_host.OwnerID); + + if (account == null) + { + Error("llEmail", "Can't find user account for '" + m_host.OwnerID.ToString() + "'"); + return; + } + + if (String.IsNullOrEmpty(account.Email)) + { + Error("llEmail", "User account has not registered an email address."); + return; + } + + address = account.Email; + } + emailModule.SendEmail(m_host.UUID, address, subject, message); ScriptSleep(EMAIL_PAUSE_TIME * 1000); } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 180d1f3b53..bfc9e9393d 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1318,6 +1318,11 @@ ; If false then gods cannot execute these functions either. AllowGodFunctions = false + ; Restrict the email address used by llEmail to the address associated with the avatars user account? + ; If true then llEmail will only send email to the address in the user account of the avatar who owns the object containing the script. + ; If false then email may be sent to any valid email address. + RestrictEmail = false + ; Maximum number of llListen events we allow over the entire region. ; Set this to 0 to have no limit imposed max_listens_per_region = 1000