Exemplo n.º 1
0
        public bool CanTakeCopy(IAgent agent, ObjectGroup group, Vector3 location)
        {
            UGUI agentOwner = agent.Owner;
            UGUI groupOwner = group.Owner;

            if (IsPossibleGod(agentOwner))
            {
                return(true);
            }
            /* deny modification of admin objects by non-admins */
            else if (IsPossibleGod(groupOwner))
            {
                return(false);
            }

            /* check locked state */
            if (group.RootPart.IsLocked)
            {
                return(false);
            }

            /* check object owner */
            if (agentOwner.EqualsGrid(groupOwner))
            {
            }
            else if (group.IsAttached)
            {
                /* others should not be able to edit attachments */
                return(false);
            }

            var checkMask = InventoryPermissionsMask.Copy;

            if (!agentOwner.EqualsGrid(groupOwner))
            {
                checkMask |= InventoryPermissionsMask.Transfer;
            }

            ParcelInfo pinfo;

            if (Parcels.TryGetValue(location, out pinfo) &&
                pinfo.Owner.EqualsGrid(agentOwner) &&
                ParcelOwnerIsAdmin)
            {
                return(true);
            }

            if (group.RootPart.CheckPermissions(agentOwner, group.Group, checkMask))
            {
                return(true);
            }
            else if ((group.RootPart.EveryoneMask & InventoryPermissionsMask.Copy) != 0)
            {
                return(true);
            }
            return(false);
        }
        bool IExperiencePermissionsInterface.TryGetValue(UEI experienceID, UGUI agent, out bool allowed)
        {
            using (var conn = new SqlConnection(m_ConnectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand("SELECT User,IsAllowed FROM experienceusers WHERE ExperienceID = @experienceid AND User LIKE @user", conn))
                {
                    cmd.Parameters.AddParameter("@experienceid", experienceID.ID);
                    cmd.Parameters.AddParameter("@user", agent.ID.ToString() + "%");
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            UGUI ret = reader.GetUGUI("User");
                            if (ret.EqualsGrid(agent))
                            {
                                allowed = (bool)reader["IsAllowed"];
                                return(true);
                            }
                        }
                    }
                }
            }

            allowed = false;
            return(false);
        }
        Dictionary <UEI, bool> IExperiencePermissionsInterface.this[UGUI agent]
        {
            get
            {
                var result = new Dictionary <UEI, bool>();
                using (var conn = new SqlConnection(m_ConnectionString))
                {
                    conn.Open();
                    using (var cmd = new SqlCommand("SELECT ExperienceID,User,IsAllowed FROM experienceusers WHERE User LIKE @user", conn))
                    {
                        cmd.Parameters.AddParameter("@user", agent.ID.ToString() + "%");
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                UGUI ret = reader.GetUGUI("User");
                                if (ret.EqualsGrid(agent))
                                {
                                    result.Add(new UEI(reader.GetUUID("ExperienceID")), (bool)reader["IsAllowed"]);
                                }
                            }
                        }
                    }
                }

                return(result);
            }
        }
Exemplo n.º 4
0
        public bool CanRunScript(UGUI agent, Vector3 location, UUID scriptassetid)
        {
            ParcelInfo pinfo;

            if (!Parcels.TryGetValue(location, out pinfo))
            {
                return(false);
            }

            if ((pinfo.Flags & ParcelFlags.AllowOtherScripts) != 0)
            {
                return(true);
            }
            else if (agent.EqualsGrid(pinfo.Owner) || IsPossibleGod(agent))
            {
                return(true);
            }
            else if ((pinfo.Flags & ParcelFlags.AllowGroupScripts) != 0 &&
                     pinfo.Group.IsSet &&
                     IsGroupMember(agent, pinfo.Group))
            {
                return(true);
            }
            else if (WhiteListedRunScriptAssetIds.Contains(scriptassetid))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 List <uint> IEstateOwnerServiceInterface.this[UGUI owner]
 {
     get
     {
         var estates = new List <uint>();
         using (var conn = new MySqlConnection(m_ConnectionString))
         {
             conn.Open();
             using (var cmd = new MySqlCommand("SELECT ID, Owner FROM estates WHERE Owner LIKE @agentid", conn))
             {
                 cmd.Parameters.AddParameter("@id", owner.ID);
                 cmd.Parameters.AddParameter("@agentid", owner.ID.ToString() + "%");
                 using (MySqlDataReader reader = cmd.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         UGUI uui = reader.GetUGUI("Owner");
                         if (uui.EqualsGrid(owner))
                         {
                             estates.Add(reader.GetUInt32("ID"));
                         }
                     }
                     return(estates);
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 List <uint> IEstateOwnerServiceInterface.this[UGUI owner]
 {
     get
     {
         var estates = new List <uint>();
         using (var conn = new NpgsqlConnection(m_ConnectionString))
         {
             conn.Open();
             using (var cmd = new NpgsqlCommand("SELECT \"ID\", \"Owner\" FROM estates WHERE \"Owner\" LIKE @id", conn))
             {
                 cmd.Parameters.AddParameter("@id", owner.ID.ToString() + "%");
                 using (NpgsqlDataReader reader = cmd.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         UGUI uui = reader.GetUGUI("Owner");
                         if (uui.EqualsGrid(owner))
                         {
                             estates.Add((uint)(int)reader["ID"]);
                         }
                     }
                     return(estates);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
        public bool IsEstateOwner(UGUI agent)
        {
            uint estateID;
            UGUI estateOwner;

            return(EstateService.RegionMap.TryGetValue(ID, out estateID) &&
                   EstateService.EstateOwner.TryGetValue(estateID, out estateOwner) &&
                   agent.EqualsGrid(estateOwner));
        }
Exemplo n.º 8
0
        public bool CanReturn(UGUI agentOwner, ObjectGroup group, Vector3 location)
        {
            UGUI groupOwner = group.Owner;

            if (IsPossibleGod(agentOwner))
            {
                return(true);
            }
            /* deny modification of admin objects by non-admins */
            else if (IsPossibleGod(groupOwner))
            {
                return(false);
            }

            /* check locked state */
            if (group.RootPart.IsLocked)
            {
                return(false);
            }

            /* check object owner */
            if (agentOwner.EqualsGrid(groupOwner))
            {
                return(true);
            }
            else if (group.IsAttached)
            {
                /* others should not be able to edit attachments */
                return(false);
            }

#warning Add Friends Rights to CanReturn?

            if (HasGroupPower(agentOwner, group.Group, GroupPowers.ReturnGroupSet) ||
                (group.IsGroupOwned &&
                 HasGroupPower(agentOwner, group.Group, GroupPowers.ReturnGroupOwned)))
            {
                return(true);
            }

            ParcelInfo pinfo;
            if (Parcels.TryGetValue(location, out pinfo))
            {
                if (pinfo.Owner.EqualsGrid(agentOwner))
                {
                    return(true);
                }

                if (!pinfo.Group.Equals(group.Group) && HasGroupPower(agentOwner, pinfo.Group, GroupPowers.ReturnNonGroup))
                {
                    return(true);
                }
            }

            return(false);
        }
 bool IEstateManagerServiceInterface.this[uint estateID, UGUI agent]
 {
     get
     {
         using (var conn = new SqlConnection(m_ConnectionString))
         {
             conn.Open();
             using (var cmd = new SqlCommand("SELECT UserID FROM estate_managers WHERE EstateID = @estateid AND UserID LIKE @agentid", conn))
             {
                 cmd.Parameters.AddParameter("@estateid", estateID);
                 cmd.Parameters.AddParameter("@agentid", agent.ID.ToString() + "%");
                 using (SqlDataReader reader = cmd.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         UGUI uui = reader.GetUGUI("UserID");
                         if (uui.EqualsGrid(agent))
                         {
                             return(true);
                         }
                     }
                     return(false);
                 }
             }
         }
     }
     set
     {
         using (var conn = new SqlConnection(m_ConnectionString))
         {
             conn.Open();
             if (value)
             {
                 var vals = new Dictionary <string, object>
                 {
                     ["EstateID"] = estateID,
                     ["UserID"]   = agent
                 };
                 conn.ReplaceInto("estate_managers", vals, new string[] { "EstateID", "UserID" });
             }
             else
             {
                 using (var cmd = new SqlCommand("DELETE FROM estate_managers WHERE EstateID = @estateid AND UserID LIKE @userid", conn))
                 {
                     cmd.Parameters.AddParameter("@estateid", estateID);
                     cmd.Parameters.AddParameter("@userid", agent.ID.ToString() + "%");
                     if (cmd.ExecuteNonQuery() < 1 && value)
                     {
                         throw new EstateUpdateFailedException();
                     }
                 }
             }
         }
     }
 }
        bool IEstateManagerServiceInterface.this[uint estateID, UGUI agent]
        {
            get
            {
                using (var conn = new MySqlConnection(m_ConnectionString))
                {
                    conn.Open();
                    using (var cmd = new MySqlCommand("SELECT UserID FROM estate_managers WHERE EstateID = @estateid AND UserID LIKE @agentid", conn))
                    {
                        cmd.Parameters.AddParameter("@estateid", estateID);
                        cmd.Parameters.AddParameter("@agentid", agent.ID.ToString() + "%");
                        using (MySqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                UGUI uui = reader.GetUGUI("UserID");
                                if (uui.EqualsGrid(agent))
                                {
                                    return(true);
                                }
                            }
                            return(false);
                        }
                    }
                }
            }
            set
            {
                string query = value ?
                               "REPLACE INTO estate_managers (EstateID, UserID) VALUES (@estateid, @userid)" :
                               "DELETE FROM estate_managers WHERE EstateID = @estateid AND UserID LIKE @userid";

                using (var conn = new MySqlConnection(m_ConnectionString))
                {
                    conn.Open();
                    using (var cmd = new MySqlCommand(query, conn))
                    {
                        cmd.Parameters.AddParameter("@estateid", estateID);
                        if (value)
                        {
                            cmd.Parameters.AddParameter("@userid", agent);
                        }
                        else
                        {
                            cmd.Parameters.AddParameter("@userid", agent.ID.ToString() + "%");
                        }
                        if (cmd.ExecuteNonQuery() < 1 && value)
                        {
                            throw new EstateUpdateFailedException();
                        }
                    }
                }
            }
        }
        bool IEstateAccessServiceInterface.this[uint estateID, UGUI agent]
        {
            get
            {
                using (var conn = new NpgsqlConnection(m_ConnectionString))
                {
                    conn.Open();
                    using (var cmd = new NpgsqlCommand("SELECT \"UserID\" FROM estate_users WHERE \"EstateID\" = @estateid AND \"UserID\" LIKE @userid", conn))
                    {
                        cmd.Parameters.AddParameter("@estateid", estateID);
                        cmd.Parameters.AddParameter("@userid", agent.ID.ToString() + "%");
                        using (NpgsqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                UGUI uui = reader.GetUGUI("UserID");
                                if (uui.EqualsGrid(agent))
                                {
                                    return(true);
                                }
                            }
                            return(false);
                        }
                    }
                }
            }
            set
            {
                string query = value ?
                               "INSERT INTO estate_users (\"EstateID\", \"UserID\") VALUES (@estateid, @userid)" :
                               "DELETE FROM estate_users WHERE \"EstateID\" = @estateid AND \"UserID\" LIKE @userid";

                using (var conn = new NpgsqlConnection(m_ConnectionString))
                {
                    conn.Open();
                    using (var cmd = new NpgsqlCommand(query, conn))
                    {
                        cmd.Parameters.AddParameter("@estateid", estateID);
                        if (value)
                        {
                            cmd.Parameters.AddParameter("@userid", agent);
                        }
                        else
                        {
                            cmd.Parameters.AddParameter("@userid", agent.ID.ToString() + "%");
                        }
                        if (cmd.ExecuteNonQuery() < 0 && value)
                        {
                            throw new EstateUpdateFailedException();
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
 public bool TryGetValue(UGUI input, out UGUIWithName uui)
 {
     if (TryGetValue(input.ID, out uui))
     {
         if (!input.IsAuthoritative || input.EqualsGrid(uui))
         {
             return(true);
         }
     }
     uui = UGUIWithName.Unknown;
     return(false);
 }
Exemplo n.º 13
0
        public UGUIWithName ResolveName(UGUI ugui)
        {
            UGUIWithName resultuui;

            if (TryGetValue(ugui, out resultuui))
            {
                if (!ugui.IsAuthoritative || ugui.EqualsGrid(resultuui))
                {
                    return(resultuui);
                }
            }
            return((UGUIWithName)ugui);
        }
Exemplo n.º 14
0
 public bool CheckAgentPermissions(UGUI creator, UGUI owner, UGI ownergroup, UGUI accessor, UGI accessorgroup, InventoryPermissionsMask wanted)
 {
     if (accessor.EqualsGrid(creator))
     {
         return(true);
     }
     else if (wanted == InventoryPermissionsMask.None)
     {
         return(false);
     }
     else if (accessorgroup.EqualsGrid(ownergroup) && (wanted & Group) == wanted && (Base & Current & InventoryPermissionsMask.FullPerm) == InventoryPermissionsMask.FullPerm)
     {
         return(true);
     }
     else if (accessor.EqualsGrid(owner))
     {
         return((wanted & Base & Current) == wanted);
     }
     else
     {
         return((wanted & Base & EveryOne) == wanted);
     }
 }
Exemplo n.º 15
0
 public UGUIWithName this[UGUI input]
 {
     get
     {
         UGUIWithName resultuui;
         if (TryGetValue(input.ID, out resultuui))
         {
             if (!input.IsAuthoritative || input.EqualsGrid(resultuui))
             {
                 return(resultuui);
             }
         }
         throw new KeyNotFoundException();
     }
 }
Exemplo n.º 16
0
        public bool TryGetValue(UGUI input, out UGUI ugui)
        {
            UGUI uui;

            if (TryGetValue(input.ID, out uui))
            {
                if (!input.IsAuthoritative || input.EqualsGrid(uui))
                {
                    ugui = uui;
                    return(true);
                }
            }
            ugui = default(UGUI);
            return(false);
        }
Exemplo n.º 17
0
 public bool CheckGroupPermissions(UGUI creator, UGI ownergroup, UGUI accessor, UGI accessorgroup, InventoryPermissionsMask wanted)
 {
     if (accessor.EqualsGrid(creator))
     {
         return(true);
     }
     else if (wanted == InventoryPermissionsMask.None)
     {
         return(false);
     }
     else if (accessorgroup.Equals(ownergroup))
     {
         return((wanted & Base & Group) == wanted);
     }
     else
     {
         return((wanted & Base & EveryOne) == wanted);
     }
 }
        public override bool Remove(UGUI requestingAgent, UEI id)
        {
            ExperienceInfo info;

            if (!m_Experiences.TryGetValue(id.ID, out info))
            {
                return(false);
            }
            if (!requestingAgent.EqualsGrid(info.Owner))
            {
                return(false);
            }

            bool f = m_Experiences.Remove(id.ID);

            m_Perms.Remove(id);
            m_KeyValues.Remove(id);
            m_Admins.Remove(id);
            return(f);
        }
Exemplo n.º 19
0
        /** <summary>special call variant for supporting assetid based overrides</summary> */
        public bool CanRez(UUID rezzerid, UGUI agent, Vector3 location, UUID assetID, UUID rezzingassetid)
        {
            ParcelInfo pinfo;

            if (BlackListedRezzableAssetIds.Contains(assetID))
            {
                OnRezzingDenied?.Invoke(ID, agent, rezzerid, RezDenialReason.Blacklisted, rezzingassetid, assetID);
                return(false);
            }

            if (!Parcels.TryGetValue(location, out pinfo))
            {
                OnRezzingDenied?.Invoke(ID, agent, rezzerid, RezDenialReason.ParcelNotFound, rezzingassetid, assetID);
                return(false);
            }

            if ((pinfo.Flags & ParcelFlags.CreateObjects) != 0 && !WhiteListedRezzingScriptAssetIds.Contains(rezzingassetid))
            {
                return(true);
            }
            else if (assetID != UUID.Zero && WhiteListedRezzableAssetIds.Contains(assetID))
            {
                /* white listed asset */
                return(true);
            }
            else if (agent.EqualsGrid(pinfo.Owner) || IsPossibleGod(agent))
            {
                return(true);
            }
            else if ((pinfo.Flags & ParcelFlags.CreateGroupObjects) != 0 &&
                     pinfo.Group.IsSet &&
                     HasGroupPower(agent, pinfo.Group, GroupPowers.AllowRez))
            {
                return(true);
            }
            else
            {
                OnRezzingDenied?.Invoke(ID, agent, rezzerid, RezDenialReason.ParcelNotAllowed, rezzingassetid, assetID);
                return(false);
            }
        }
Exemplo n.º 20
0
        public bool IsSimConsoleAllowed(UGUI agent)
        {
            if (RegionOwnerIsSimConsoleUser &&
                agent.EqualsGrid(Owner))
            {
                return(true);
            }

            if (EstateOwnerIsSimConsoleUser &&
                IsEstateOwner(agent))
            {
                return(true);
            }

            if (EstateManagerIsSimConsoleUser &&
                IsEstateManager(agent))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 21
0
 public bool IsRegionOwner(UGUI agent) => agent.EqualsGrid(Owner);
Exemplo n.º 22
0
        private bool IsInGodAgents(UGUI agent)
        {
            RwLockedList <UGUI> activeList = m_GodAgentsSetToLocal ? m_GodAgentsLocal : m_GodAgentsGlobal;

            return(activeList.Find((e) => agent.EqualsGrid(e)) != null);
        }
Exemplo n.º 23
0
 public bool IsPossibleGod(UGUI agent) => agent.EqualsGrid(Owner) ||
 (EstateManagerIsGod && IsEstateManager(agent)) ||
 IsInGodAgents(agent);
Exemplo n.º 24
0
        public bool CanMove(IAgent agent, ObjectGroup group, Vector3 location)
        {
            UGUI agentOwner = agent.Owner;
            UGUI groupOwner = group.Owner;

            if (IsPossibleGod(agentOwner))
            {
                if (group.RootPart.IsLocked && groupOwner.EqualsGrid(agentOwner))
                {
                    return(false);
                }
                return(true);
            }
            /* deny modification of admin objects by non-admins */
            else if (IsPossibleGod(groupOwner))
            {
                return(false);
            }

            /* check locked state */
            if (group.RootPart.IsLocked)
            {
                return(false);
            }

            /* check object owner */
            if (agentOwner.EqualsGrid(groupOwner))
            {
                return(true);
            }
            else if (group.IsAttached)
            {
                /* others should not be able to edit attachments */
                return(false);
            }

#warning Add Friends Rights to CanMove

            if (group.RootPart.CheckPermissions(agentOwner, agent.Group, InventoryPermissionsMask.Move))
            {
                return(true);
            }
            else if ((group.RootPart.EveryoneMask & InventoryPermissionsMask.Move) != 0)
            {
                return(true);
            }

            if (HasGroupPower(agent.Owner, group.Group, GroupPowers.ObjectManipulate))
            {
                return(true);
            }

            ParcelInfo pinfo;
            if (Parcels.TryGetValue(location, out pinfo))
            {
                if (pinfo.Owner.EqualsGrid(agentOwner))
                {
                    return(true);
                }

                if (HasGroupPower(agent.Owner, pinfo.Group, GroupPowers.ObjectManipulate))
                {
                    return(true);
                }
            }

            return(false);
        }
        public override bool ContainsKey(UGUI input)
        {
            UGUIWithName entry;

            return(m_Data.TryGetValue(input.ID, out entry) && input.EqualsGrid(entry));
        }