public bool PutItemToTaskInv(BotClient Client, uint localID, SimObject exportPrim, string name) { InventoryItem found = GetInvItem(Client, name); if (found == null) { Failure("Cant find InvItem " + name); return(false); } bool canModifyObject = true; if (exportPrim != null) { PermissionWho pwo = Importing.TheSimAvatar.EffectivePermissionWho(exportPrim); PermissionMask pmo = CogbotHelpers.PermMaskForWho(pwo, exportPrim.Properties.Permissions); canModifyObject = Permissions.HasPermissions(pmo, PermissionMask.Modify); if (!canModifyObject) { } } if (found.InventoryType == InventoryType.LSL) { Client.Inventory.CopyScriptToTask(localID, (InventoryItem)found, true); //Client.Inventory.RequestSetScriptRunning(exportPrim.ID, found.UUID, true); } else { Client.Inventory.UpdateTaskInventory(localID, (InventoryItem)found); } return(canModifyObject); }
private bool checkTaskPerm(SimObject exportPrim, InventoryItem item, BotClient Client, OutputDelegate Failure, bool mustModify) { SimAvatarClient theAvatar = Client.TheSimAvatar; PermissionWho pw = theAvatar.EffectivePermissionWho(item.OwnerID, item.GroupID, item.GroupOwned); PermissionMask pm = CogbotHelpers.PermMaskForWho(pw, item.Permissions); bool modify = Permissions.HasPermissions(pm, PermissionMask.Modify); bool cmt = Permissions.HasPermissions(pm, PermissionMask.Copy) || Permissions.HasPermissions(pm, PermissionMask.Modify) || Permissions.HasPermissions(pm, PermissionMask.Transfer); if (mustModify) { if (!modify) { Failure("ItemPerms NOMODIFY " + pm + " for " + pw + " on " + ItemDesc(item, exportPrim)); return(false); } } if (!cmt) { Failure("ItemPerms " + pm + " for " + pw + " on " + ItemDesc(item, exportPrim)); var p = exportPrim.Parent; if (p != null && p != exportPrim) { exportPrim = p; } lock (SIPrims) SIPrims.Add(exportPrim); return(false); } return(true); }
public static PermissionMask PermMaskForWho(PermissionWho who, Permissions perms) { switch (who) { case PermissionWho.Base: return(perms.BaseMask); break; case PermissionWho.Owner: return(perms.OwnerMask); break; case PermissionWho.Group: return(perms.GroupMask); break; case PermissionWho.Everyone: return(perms.EveryoneMask); break; case PermissionWho.NextOwner: return(perms.NextOwnerMask); break; case PermissionWho.All: return(perms.EveryoneMask); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Set the permissions on multiple objects /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the objects reside</param> /// <param name="localIDs">An array which contains the IDs of the objects to set the permissions on</param> /// <param name="who">The new Who mask to set</param> /// <param name="permissions">The new Permissions mark to set</param> /// <param name="set">TODO: What does this do?</param> public void SetPermissions(Simulator simulator, List<uint> localIDs, PermissionWho who, PermissionMask permissions, bool set) { ObjectPermissionsPacket packet = new ObjectPermissionsPacket(); packet.AgentData.AgentID = Client.Self.AgentID; packet.AgentData.SessionID = Client.Self.SessionID; // Override can only be used by gods packet.HeaderData.Override = false; packet.ObjectData = new ObjectPermissionsPacket.ObjectDataBlock[localIDs.Count]; for (int i = 0; i < localIDs.Count; i++) { packet.ObjectData[i] = new ObjectPermissionsPacket.ObjectDataBlock(); packet.ObjectData[i].ObjectLocalID = localIDs[i]; packet.ObjectData[i].Field = (byte)who; packet.ObjectData[i].Mask = (uint)permissions; packet.ObjectData[i].Set = Convert.ToByte(set); } Client.Network.SendPacket(packet, simulator); }
private void SetPerms(Simulator CurrentSim, List <uint> localIDs, PermissionWho who, PermissionMask Perms, bool tf) { try { if (!skipPerms) { PermCount = 0; if ((Perms & PermissionMask.Modify) == PermissionMask.Modify) { Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Modify, tf); } PermsSent = true; // if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) // return Failure("failed to set the modify bit, permissions in an unknown state"; PermCount = 0; if ((Perms & PermissionMask.Copy) == PermissionMask.Copy) { Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Copy, tf); } PermsSent = true; // if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) // return Failure("failed to set the copy bit, permissions in an unknown state"; PermCount = 0; if ((Perms & PermissionMask.Transfer) == PermissionMask.Transfer) { Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Transfer, tf); } PermsSent = true; PermCount = 0; if ((Perms & PermissionMask.Move) == PermissionMask.Move) { Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Transfer, tf); } PermsSent = true; } /* * else * { * Client.Objects.SetPermissions(CurrentSim, localIDs, PermissionWho.Owner, PermissionMask.All, true); * Client.Objects.SetPermissions(CurrentSim, localIDs, PermissionWho.Group, PermissionMask.Modify, true); * Client.Objects.SetPermissions(CurrentSim, localIDs, PermissionWho.Group, PermissionMask.All, true); * } * // if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) * // return Failure("failed to set the transfer bit, permissions in an unknown state"; */ } catch (Exception e) { DLRConsole.DebugWriteLine("ERROR {0}", e); } }
public override CmdResult ExecuteRequest(CmdRequest args) { //opensim drew this line because of clients might be hardcoded to only support 255? or was this trying to copy linden? try { //Client.Objects.OnObjectProperties += callback; int argsUsed; Simulator CurSim = TryGetSim(args, out argsUsed) ?? Client.Network.CurrentSim; UUID groupID = UUID.Zero; Simulator CurrentSim = CurSim; Permissions AddPerms = new Permissions(); Permissions SubPerms = new Permissions(); bool doTaskInv = false; List <Primitive> TaskPrims = new List <Primitive>(); List <uint> localIDs = new List <uint>(); // Reset class-wide variables PermsSent = false; Objects.Clear(); PermCount = 0; bool oneAtATime = false; if (args.Length < 3) { return(ShowUsage()); } List <SimObject> PS = WorldSystem.GetSingleArg(args, out argsUsed); if (IsEmpty(PS)) { return(Failure("Cannot find objects from " + args.str)); } PermissionWho who = 0; bool deed = false; for (int i = argsUsed; i < args.Length; i++) { bool add = true; bool setPerms = false; string arg = args[i]; int whoint = (int)who; PermissionMask Perms = PermsAdd[whoint]; if (arg.StartsWith("+")) { arg = arg.Substring(1); } else if (arg.StartsWith("-")) { arg = arg.Substring(1); add = false; Perms = PermsSub[whoint]; } switch (arg.ToLower()) { // change owner referall case "who": who = 0; break; case "o": who |= PermissionWho.Owner; break; case "g": who |= PermissionWho.Group; break; case "e": who |= PermissionWho.Everyone; break; case "n": who |= PermissionWho.NextOwner; break; case "a": who = PermissionWho.All; break; // change perms for owner case "copy": Perms |= PermissionMask.Copy; setPerms = true; break; case "mod": Perms |= PermissionMask.Modify; setPerms = true; break; case "xfer": Perms |= PermissionMask.Transfer; setPerms = true; break; case "all": Perms |= PermissionMask.All; setPerms = true; break; case "dmg": Perms |= PermissionMask.Damage; setPerms = true; break; case "move": Perms |= PermissionMask.Move; setPerms = true; break; // dont change perms at all case "noperms": skipPerms = true; break; // deed (implies will use group) case "deed": deed = true; break; // set object group case "group": i++; setGroup = true; groupID = Client.GroupName2UUID(args[i]); break; case "task": doTaskInv = true; break; case "incr": oneAtATime = true; break; default: return(ShowUsage()); } if (setPerms) { skipPerms = false; if (add) { PermsAdd[whoint] = Perms; } else { PermsSub[whoint] = Perms; } } } ulong CurrentSimHandle = CurrentSim.Handle; foreach (SimObject o in PS) { if (o is SimAvatar) { continue; } if (o.RegionHandle != CurrentSimHandle) { continue; } // Find the requested prim Primitive rootPrim = o.Prim; if (rootPrim == null) { continue; } localIDs.Add(rootPrim.LocalID); Objects[rootPrim.ID] = rootPrim; if (doTaskInv) { TaskPrims.Add(rootPrim); } continue; ; UUID rootID = UUID.Zero; if (rootPrim == null) { return(Failure("Cannot find requested prim " + rootID.ToString())); } else { WriteLine("Found requested prim " + rootPrim.ID.ToString(), Client); } if (rootPrim.ParentID != 0) { // This is not actually a root prim, find the root if (!CurrentSim.ObjectsPrimitives.TryGetValue(rootPrim.ParentID, out rootPrim)) { return(Failure("Cannot find root prim for requested object")); } else { WriteLine("Set root prim to " + rootPrim.ID.ToString(), Client); } } List <Primitive> childPrims; // Find all of the child objects linked to this root childPrims = CurrentSim.ObjectsPrimitives.FindAll( delegate(Primitive prim) { return(prim.ParentID == rootPrim.LocalID); }); // Build a dictionary of primitives for referencing later // Objects[rootPrim.ID] = rootPrim; for (int i = 0; i < childPrims.Count; i++) { Objects[childPrims[i].ID] = childPrims[i]; } // Build a list of all the localIDs to set permissions for localIDs.Add(rootPrim.LocalID); for (int i = 0; i < childPrims.Count; i++) { localIDs.Add(childPrims[i].LocalID); } if (doTaskInv) { TaskPrims.AddRange(childPrims); TaskPrims.Add(rootPrim); } } WriteLine("Using PermissionMask: +" + PermsAdd.ToString() + " -" + PermsSub.ToString(), Client); // Go through each of the three main permissions and enable or disable them #region Set Linkset Permissions if (oneAtATime) { List <uint> smallList = new List <uint>(); foreach (var o in Objects.Values) { if (o.OwnerID == Client.Self.AgentID) //if (o.GroupID!=groupID) { if (doTaskInv) { TaskPrims.Add(o); } smallList.Clear(); smallList.Add(o.LocalID); SetDeed(CurrentSim, smallList, groupID, deed); } } } else { if (localIDs.Count < 50) { SetDeed(CurrentSim, localIDs, groupID, deed); } else { List <uint> smallList = new List <uint>(); while (localIDs.Count > 0) { if (localIDs.Count < 50) { SetDeed(CurrentSim, localIDs, groupID, deed); break; } smallList.Clear(); smallList.AddRange(localIDs.GetRange(0, 50)); SetDeed(CurrentSim, smallList, groupID, deed); localIDs.RemoveRange(0, 50); } } } #endregion Set Linkset Permissions // Check each prim for task inventory and set permissions on the task inventory int taskItems = 0; if (doTaskInv) { foreach (Primitive prim in TaskPrims) { if ((prim.Flags & PrimFlags.InventoryEmpty) == 0) { List <InventoryBase> items = Client.Inventory.GetTaskInventory(prim.ID, prim.LocalID, 1000 * 10); if (items != null) { for (int i = 0; i < items.Count; i++) { if (!(items[i] is InventoryFolder)) { InventoryItem item = (InventoryItem)items[i]; // prev and not (W or All) item.Permissions.GroupMask &= ~(PermsSub[(int)PermissionWho.Group] | PermsSub[(int)PermissionWho.All]); item.Permissions.OwnerMask &= ~(PermsSub[(int)PermissionWho.Owner] | PermsSub[(int)PermissionWho.All]); item.Permissions.NextOwnerMask &= ~(PermsSub[(int)PermissionWho.NextOwner] | PermsSub[(int)PermissionWho.All]); item.Permissions.EveryoneMask &= ~(PermsSub[(int)PermissionWho.Everyone] | PermsSub[(int)PermissionWho.All]); // prev and (W or All) item.Permissions.GroupMask |= PermsAdd[(int)PermissionWho.Group] | PermsAdd[(int)PermissionWho.All]; item.Permissions.OwnerMask |= PermsAdd[(int)PermissionWho.Owner] | PermsAdd[(int)PermissionWho.All]; item.Permissions.NextOwnerMask |= PermsAdd[(int)PermissionWho.NextOwner] | PermsAdd[(int)PermissionWho.All]; item.Permissions.EveryoneMask |= PermsAdd[(int)PermissionWho.Everyone] | PermsAdd[(int)PermissionWho.All]; Client.Inventory.UpdateTaskInventory(prim.LocalID, item); ++taskItems; } } } } } } return (Success("Using PermissionMask: +" + PermsAdd.ToString() + " -" + PermsSub.ToString() + " on " + Objects.Count + " objects and " + taskItems + " inventory items")); } finally { // Client.Objects.OnObjectProperties -= callback; } }
public static bool checkPerms(BotClient Client, SimObject exportPrim, OutputDelegate Failure, bool mustModify) { if (exportPrim != null) { var Properties = exportPrim.Properties; if (Properties == null) { Client.Objects.RequestObjectPropertiesFamily(exportPrim.GetSimulator(), exportPrim.ID, true); Failure("No props yet for " + named(exportPrim)); return(false); } // Check for export permission first //GotPermissions = false; // //if (!GotPermissions) // { // Properties = exportPrim.Properties ?? new Primitive.ObjectProperties(); //} // GotPermissionsEvent.WaitOne(1000 * 10, false); if (Properties.OwnerID != Client.Self.AgentID && Properties.OwnerID != Client.MasterKey && Properties.GroupID != Client.Self.ActiveGroup) { Failure("That object is owned by " + Properties.OwnerID + ", we don't have permission " + "to export " + named(exportPrim)); } SimAvatarClient theAvatar = Client.TheSimAvatar; PermissionWho pw = theAvatar.EffectivePermissionWho(exportPrim); PermissionMask pm = theAvatar.EffectivePermissionsMask(exportPrim); bool modify = Permissions.HasPermissions(pm, PermissionMask.Modify); bool cmt = Permissions.HasPermissions(pm, PermissionMask.Copy) || Permissions.HasPermissions(pm, PermissionMask.Modify) || Permissions.HasPermissions(pm, PermissionMask.Transfer); if (mustModify) { if (!modify) { Failure("ObjPerms NOMODIFY " + pm + " for " + pw + " on " + named(exportPrim)); return(false); } } if (!cmt) { Failure("ObjPerms " + pm + " for " + pw + " on " + named(exportPrim)); return(false); } //List<SimObject> family = new List<SimObject>(); //family.Add(exportPrim); //family.AddRange(exportPrim.Children); /*bool complete = RequestObjectProperties(family, 250, exportPrim.GetSimulator()); * exportedPrims.AddRange(family); * * if (!complete) * { * Logger.Log("Warning: Unable to retrieve full properties for:", Helpers.LogLevel.Warning, Client); * foreach (UUID uuid in PrimsWaiting.Keys) * Logger.Log(uuid.ToString(), Helpers.LogLevel.Warning, Client); * } * return true;*/ } return(true); }
private void SetPerms(Simulator CurrentSim, List<uint> localIDs, PermissionWho who, PermissionMask Perms, bool tf) { try { if (!skipPerms) { PermCount = 0; if ((Perms & PermissionMask.Modify) == PermissionMask.Modify) Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Modify, tf); PermsSent = true; // if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) // return Failure("failed to set the modify bit, permissions in an unknown state"; PermCount = 0; if ((Perms & PermissionMask.Copy) == PermissionMask.Copy) Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Copy, tf); PermsSent = true; // if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) // return Failure("failed to set the copy bit, permissions in an unknown state"; PermCount = 0; if ((Perms & PermissionMask.Transfer) == PermissionMask.Transfer) Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Transfer, tf); PermsSent = true; PermCount = 0; if ((Perms & PermissionMask.Move) == PermissionMask.Move) Client.Objects.SetPermissions(CurrentSim, localIDs, who, PermissionMask.Transfer, tf); PermsSent = true; } /* else { Client.Objects.SetPermissions(CurrentSim, localIDs, PermissionWho.Owner, PermissionMask.All, true); Client.Objects.SetPermissions(CurrentSim, localIDs, PermissionWho.Group, PermissionMask.Modify, true); Client.Objects.SetPermissions(CurrentSim, localIDs, PermissionWho.Group, PermissionMask.All, true); } // if (!GotPermissionsEvent.WaitOne(1000 * 30, false)) // return Failure("failed to set the transfer bit, permissions in an unknown state"; */ } catch (Exception e) { DLRConsole.DebugWriteLine("ERROR {0}", e); } }