public static ItemPermissionBlock CalculateCoalescedPermissions(IEnumerable <ItemPermissionBlock> allPermissions)
        {
            // Include support for the Export permission.
            ItemPermissionBlock resultPermissions = new ItemPermissionBlock();

            resultPermissions.BasePermissions     = (uint)(PermissionMask.All | PermissionMask.Export);
            resultPermissions.CurrentPermissions  = (uint)(PermissionMask.All | PermissionMask.Export);
            resultPermissions.GroupPermissions    = (uint)PermissionMask.All;
            resultPermissions.EveryOnePermissions = (uint)(PermissionMask.All | PermissionMask.Export);
            resultPermissions.NextPermissions     = (uint)(PermissionMask.All | PermissionMask.Export);

            //we want to grab the minimum permissions for each object for each permission class
            foreach (ItemPermissionBlock permBlock in allPermissions)
            {
                resultPermissions.BasePermissions     &= permBlock.BasePermissions;
                resultPermissions.CurrentPermissions  &= permBlock.CurrentPermissions;
                resultPermissions.GroupPermissions    &= permBlock.GroupPermissions;
                resultPermissions.EveryOnePermissions &= permBlock.EveryOnePermissions;
                resultPermissions.NextPermissions     &= permBlock.NextPermissions;
            }

            // Now don't let any of these exceed the calculated BasePermissions.
            resultPermissions.CurrentPermissions  &= resultPermissions.BasePermissions;
            resultPermissions.GroupPermissions    &= resultPermissions.BasePermissions;
            resultPermissions.EveryOnePermissions &= resultPermissions.BasePermissions;
            resultPermissions.NextPermissions     &= resultPermissions.BasePermissions;

            return(resultPermissions);
        }
Example #2
0
        public static ItemPermissionBlock CalculateCoalescedPermissions(IEnumerable<ItemPermissionBlock> allPermissions)
        {
            // Include support for the Export permission.
            ItemPermissionBlock resultPermissions = new ItemPermissionBlock();
            resultPermissions.BasePermissions = (uint)(PermissionMask.All | PermissionMask.Export);
            resultPermissions.CurrentPermissions = (uint)(PermissionMask.All | PermissionMask.Export);
            resultPermissions.GroupPermissions = (uint)PermissionMask.All;
            resultPermissions.EveryOnePermissions = (uint)(PermissionMask.All | PermissionMask.Export);
            resultPermissions.NextPermissions = (uint)(PermissionMask.All | PermissionMask.Export);

            //we want to grab the minimum permissions for each object for each permission class
            foreach (ItemPermissionBlock permBlock in allPermissions)
            {
                resultPermissions.BasePermissions &= permBlock.BasePermissions;
                resultPermissions.CurrentPermissions &= permBlock.CurrentPermissions;
                resultPermissions.GroupPermissions &= permBlock.GroupPermissions;
                resultPermissions.EveryOnePermissions &= permBlock.EveryOnePermissions;
                resultPermissions.NextPermissions &= permBlock.NextPermissions;
            }

            // Now don't let any of these exceed the calculated BasePermissions.
            resultPermissions.CurrentPermissions &= resultPermissions.BasePermissions;
            resultPermissions.GroupPermissions &= resultPermissions.BasePermissions;
            resultPermissions.EveryOnePermissions &= resultPermissions.BasePermissions;
            resultPermissions.NextPermissions &= resultPermissions.BasePermissions;

            return resultPermissions;
        }
        public static ItemPermissionBlock FromOther(IInventoryItem other)
        {
            ItemPermissionBlock newBlock = new ItemPermissionBlock();

            newBlock.BasePermissions     = other.BasePermissions;
            newBlock.NextPermissions     = other.NextPermissions;
            newBlock.EveryOnePermissions = other.EveryOnePermissions;
            newBlock.GroupPermissions    = other.GroupPermissions;
            newBlock.CurrentPermissions  = other.CurrentPermissions;

            return(newBlock);
        }
Example #4
0
        public static ItemPermissionBlock FromOther(IInventoryItem other)
        {
            ItemPermissionBlock newBlock = new ItemPermissionBlock();
            newBlock.BasePermissions = other.BasePermissions;
            newBlock.NextPermissions = other.NextPermissions;
            newBlock.EveryOnePermissions = other.EveryOnePermissions;
            newBlock.GroupPermissions = other.GroupPermissions;
            newBlock.CurrentPermissions = other.CurrentPermissions;

            return newBlock;
        }
        private SceneObjectGroup RezSingleObjectToWorld(IClientAPI remoteClient, UUID itemID, 
            SceneObjectGroup group, Vector3 RayEnd, Vector3 RayStart,
            UUID RayTargetID, byte BypassRayCast, byte bRayEndIsIntersection,
            bool RezSelected, bool attachment, Vector3 pos, string name,
            string description, IInventoryItem item, ItemPermissionBlock itemPermissions,
            int? startParam, UUID? newAvatarGroupId, UUID? rezzedByObjectUUID)
        {
            bool ownerChanged = false;  // record this for the CHANGED_OWNER changed event

            if (IsBadUserLoad(group))
            {
                if (remoteClient != null)
                    remoteClient.SendAgentAlertMessage("You are currently not allowed to rez objects in this region.", false);
                return null;   // already reported above
            }
            if (IsBlacklistedLoad(group))
            {
                if (remoteClient != null)
                    remoteClient.SendAgentAlertMessage("Cannot rez blacklisted object '" + group.Name + "'.", false);
                return null;   // already reported above
            }

            //set the group here so that positioning in world will enable/disable the
            //script correctly based on the group the use is currently in

            // Initialize the server weight (LI)
            group.RecalcPrimWeights();

            group.RezzedFromFolderId = item.Folder;
            //group.FromAssetId = item.AssetID; //not needed yet

            if (newAvatarGroupId.HasValue)
            {
                //set the object's land group
                group.SetGroup(newAvatarGroupId.Value, null);
            }

            if (attachment)
            {
                group.SetFromItemID(itemID);
            }
            else
            {
                group.RootPart.SetGroupPositionDirect(pos);

                if (RezSelected)
                {
                    //also tell the client there is a new object being rezzed
                    foreach (SceneObjectPart part in group.GetParts())
                    {
                        part.AddFlag(PrimFlags.CreateSelected);
                    }
                }
            }

            SceneObjectPart rootPart = group.GetChildPart(group.UUID);
            if (rootPart == null) {
                string what = "object ";
                if (attachment)
                    what = " attachment ";
                m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + what + " root part not found.");
                return null;
            }

            // Since renaming the item in the inventory does not affect the name stored
            // in the serialization, transfer the correct name from the inventory to the
            // object itself before we rez.
            rootPart.Name = name;
            rootPart.Description = description;

            var partList = group.GetParts();

            foreach (SceneObjectPart part in partList)
            {
                /// This fixes inconsistencies between this part and the root part.
                /// In the past, there was a bug in Link operations that did not force 
                /// these permissions on child prims when linking.
                part.SyncChildPermsWithRoot();
            }

            if (rootPart.OwnerID != item.Owner)
            {
                if (Permissions.PropagatePermissions())
                {
                    if ((itemPermissions.CurrentPermissions & ScenePermBits.SLAM) != 0)
                    {    // enforce slam bit, apply item perms to the group parts
                        foreach (SceneObjectPart part in partList)
                        {
                            part.EveryoneMask = item.EveryOnePermissions;
                            part.NextOwnerMask = item.NextPermissions;
                            part.GroupMask = 0; // DO NOT propagate here
                        }
                    }
                    group.ApplyNextOwnerPermissions();
                }
            }

            ownerChanged |= group.Rationalize(item.Owner, false);

            foreach (SceneObjectPart part in partList)
            {
                if (part.OwnerID != item.Owner)
                {
                    part.LastOwnerID = part.OwnerID;
                    part.OwnerID = item.Owner;
                    part.Inventory.ChangeInventoryOwner(item.Owner);
                    ownerChanged = true;
                }
                else if (((itemPermissions.CurrentPermissions & ScenePermBits.SLAM) != 0) && (!attachment)) // Slam!
                {
                    part.EveryoneMask = itemPermissions.EveryOnePermissions;
                    part.NextOwnerMask = itemPermissions.NextPermissions;

                    part.GroupMask = 0; // DO NOT propagate here
                }
            }

            rootPart.TrimPermissions();

            if (!attachment)
            {
                if (group.RootPart.IsPrim)
                {
                    group.ClearPartAttachmentData();
                }
            }

            if (this.AddObjectToSceneIfPermitted(group, remoteClient, pos, attachment, rezzedByObjectUUID))
            {
                if (ownerChanged)
                {
                    foreach (SceneObjectPart part in partList)
                        part.TriggerScriptChangedEvent(Changed.OWNER);
                }

                if (!attachment)
                {
                    // Fire on_rez
                    group.CreateScriptInstances(startParam, ScriptStartFlags.PostOnRez, DefaultScriptEngine, (int)ScriptStateSource.PrimData, null);

                    rootPart.ScheduleFullUpdate(PrimUpdateFlags.ForcedFullUpdate);
                }

            } 
            else 
            {
                // The viewer automatically removes no-copy items from inventory on a rez attempt.
                // Since this one did not rez, it's still in inventory so let's "put it back".
                if (remoteClient != null)
                {
                    InventoryItemBase ib = item as InventoryItemBase;

                    if (item != null)
                    {
                        //this is a folder item, not a task item. update the user
                        remoteClient.SendInventoryItemCreateUpdate(ib, 0);
                    }
                }
                return null;
            }

            return rootPart.ParentGroup;
        }
Example #6
0
        /// <summary>
        /// For each of the items, if i am the owner, permissions don't change, otherwise apply next owner perms
        /// </summary>
        /// <param name="inventoryOwner"></param>
        /// <param name="sceneItem"></param>
        /// <param name="newItem"></param>
        public ItemPermissionBlock GetNewItemPermissions(UUID inventoryOwner)
        {
            ItemPermissionBlock newItem = new ItemPermissionBlock();
            uint eperms = this.GetEffectivePermissions(true);
            uint nperms = this.GetEffectiveNextPermissions(true);

            // item perms become folded, but ignored if rezzed by the same owner
            if (inventoryOwner != this.OwnerID && this.Scene != null && this.Scene.Permissions.PropagatePermissions())
            {
                newItem.BasePermissions = eperms & this.RootPart.NextOwnerMask;
                newItem.CurrentPermissions = eperms & nperms;
                newItem.NextPermissions = eperms & nperms;
                newItem.EveryOnePermissions = 0;
                newItem.GroupPermissions = 0;
            }
            else
            {
                newItem.BasePermissions = eperms;
                newItem.CurrentPermissions = eperms;
                newItem.NextPermissions = eperms & nperms;
                newItem.EveryOnePermissions = eperms & this.RootPart.EveryoneMask;
                newItem.GroupPermissions = eperms & this.RootPart.GroupMask;
            }

            newItem.ItemId = this.RootPart.UUID;

            return newItem;
        }
        public static ItemPermissionBlock FromXml(XmlReader xmlReader)
        {
            ItemPermissionBlock perm = (ItemPermissionBlock)serializer.Deserialize(xmlReader);

            return(perm);
        }