Jump to content

Tool for Testing Permissions


Rolig Loon
 Share

You are about to reply to a thread that has been inactive for 2252 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

The SL permissions system can be confusing, to say the least.  Creators and merchants commonly make mistakes in setting permissions on items that they offer for customers.  Those mistakes can be costly and embarrassing, and they can lead to hard feelings (and bad reviews). There is no substitute for learning how the permissions system works, and there's no excuse for not double checking perms before you release a product into the wild.  This compact tool can make the checking easier, however.

Create the tool by placing this script in a prim that you own.  Then add as many test items as you wish.  Have your alt test each item by clicking on the tool and selecting a test object to be delivered.  The tool should deliver the item (if it is transferable) and should send a report in chat that tells you how perms are set for the current owner, the next owner, the group that the tool is set to, and anyone in general.  Your alt should then verify by checking perms on the object that the tool delivered.

IMPORTANT NOTES:

  • Please note that this tool cannot tell you how permissions are set on items that are in the inventory of your test object.  For example, if you have set the next owner perms on a test object to copy/mod/transfer but have included a no-mod script or texture, the tool will report that the test object is copy/no-mod/trans but it cannot tell you that it is the script or texture that forced the change. You will still need to examine the inventory of every single child prim in the object if you want to account for unexpected overall perms.
  • Note also that the tool is scripted to test OBJECTS.  If you want to test other items (texture, animations, sounds, ...), you will need to change the lines in the state_entry, dataserver, and touch_start events where NumObj is defined or INVENTORY_OBJECT is used.  If you use INVENTORY_ALL or INVENTORY_SCRIPT, note that the tool will include a copy of this script in its dialog selection.

This script incorporates a version of Void Singer's uDlgBtnLst routine for managing a multipage dialog  ( https://community.secondlife.com/forums/topic/32399-dynamic-multi-page-dialog-aka-pagination/ ) and the getPermsAsReadableString routine from the LSL wiki at http://wiki.secondlife.com/wiki/LlGetInventoryPermMask#Examples

 

// Verify Object Permissions  --- Rolig Loon --- February 2018

list uDlgBtnLst( integer vIntPag )
{
    integer vIdxBeg = 10 * (~-vIntPag);          //-- 10 * (vIntPag - 1), enclose "~-X" in parens to avoid LSL bug
    integer vIdxMax = -~(~([] != gLstMnu) / 10); //-- (llGetListLength( gLstMnu ) - 1) / 10 + 1
    list vLstRtn =
      llListInsertList(
        llList2List( gLstMnu, vIdxBeg, vIdxBeg + 9 ), //-- grab 10 dialog buttons
        (list)("  <<---(" + (string)(vIntPag + (-(vIntPag > 1) | vIdxMax - vIntPag)) + ")"), //-- back button
        -1 ) + //-- inserts back button at index 9, pushing the last menu item to index 10
      (list)("  (" + (string)(-~((vIntPag < vIdxMax) * vIntPag)) + ")--->>"); //-- add fwd button at index 11

    return //-- fix the order to L2R/T2B
      llList2List( vLstRtn, -3, -1 ) + llList2List( vLstRtn, -6, -4 ) +
      llList2List( vLstRtn, -9, -7 ) + llList2List( vLstRtn, -12, -10 );
}

string getPermsAsReadableString(integer perm)
{
    integer fullPerms = PERM_COPY | PERM_MODIFY | PERM_TRANSFER;
    integer copyModPerms = PERM_COPY | PERM_MODIFY;
    integer copyTransPerms = PERM_COPY | PERM_TRANSFER;
    integer modTransPerms = PERM_MODIFY | PERM_TRANSFER;
 
    string output = " perms: ";
 
    if ((perm & fullPerms) == fullPerms)
        output += "full";
    else if ((perm & copyModPerms) == copyModPerms)
        output += "copy & modify";
    else if ((perm & copyTransPerms) == copyTransPerms)
        output += "copy & transfer";
    else if ((perm & modTransPerms) == modTransPerms)
        output += "modify & transfer";
    else if ((perm & PERM_COPY) == PERM_COPY)
        output += "copy";
    else if ((perm & PERM_TRANSFER) == PERM_TRANSFER)
        output += "transfer";
    else if ((perm & PERM_MODIFY) == PERM_MODIFY)
        output += "modify";
    else
        output += "none";
    return  output;
}

integer gDChan;
key gkAv;
list gLstMnu;
list gDLabels;
list gObjMnu;
key gkOwner;
string gsOwnerName;

default
{
    state_entry()
    {
        gDChan = -1 * (integer)llFrand(10000000.0) - 562;
        llListen(gDChan,"","","");
        integer NumObj = llGetInventoryNumber(INVENTORY_OBJECT);
        gLstMnu = [];
        gDLabels = [];
        gObjMnu = [];
        integer i;
        while (i < NumObj)
        {
            gObjMnu += [llGetInventoryName(INVENTORY_OBJECT,i)];
            gDLabels += [(string)(i + 1) + ". " +llGetInventoryName(INVENTORY_OBJECT,i) + " \n"]; //Dialog text
            gLstMnu += [(string)(i + 1)]; // Button labels
            ++i;
        }
        gkOwner = llRequestAgentData(llGetOwner(),DATA_NAME);
    }
     
    dataserver(key id, string data)
    {
        string OwnerName = data;
        integer NumObj = llGetInventoryNumber(INVENTORY_OBJECT);
        llSetText("PERM TEST BOX \n (Owner = " + OwnerName + ") \n \n Take a copy. \n Add test objects. \n Get your alt to click and select items for testing. \n \n \n There are " + (string)NumObj + " objects in the tester now.",<1,1,1>,1.0);
    }
    
    changed (integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }

    touch_start(integer total_number)
    {
        gkAv = llDetectedKey(0);
        if (llGetInventoryNumber(INVENTORY_OBJECT) > 0)
        {
            string temp = "";
            integer i;
            //Display the first 10 sites in dialog
            for (i=0;i<10;++i)
            {
                temp += llList2String(gDLabels,i);
            }
            llDialog( gkAv, "\n" + temp, uDlgBtnLst( 1 ), gDChan );
        }
        else
        {
            llRegionSayTo(gkAv,0,"There are no objects in the tester. Please add objects to be tested.");
        }
    }
    
    listen( integer vIntChn, string vStrNom, key vKeySpk, string vStrMsg )
    {
        // Has the user clicked either the ">>" or "<<" button?
        if (!llSubStringIndex( vStrMsg, "  " ))  //-- detects 2 (hidden) leading spaces
        {
            string temp = "";
            integer menu =  (integer)llGetSubString( vStrMsg, -~llSubStringIndex( vStrMsg, "(" ), -1 );
            integer i;
            for (i=(10*(menu-1));i<(10*menu);++i)
            {
                temp += llList2String(gDLabels,i);
            }
            llDialog( vKeySpk,"\n" +temp, uDlgBtnLst(menu), vIntChn );
        }
        else
        {
            integer idx = (integer)vStrMsg - 1;
            string Item = llList2String(gObjMnu,idx);
            integer basePerms      = llGetInventoryPermMask(Item, MASK_BASE);
            integer ownerPerms     = llGetInventoryPermMask(Item, MASK_OWNER);
            integer nextOwnerPerms = llGetInventoryPermMask(Item, MASK_NEXT);
            integer groupPerms     = llGetInventoryPermMask(Item, MASK_GROUP);
            integer everyonePerms  = llGetInventoryPermMask(Item, MASK_EVERYONE);
     
            llSay(0, "/me [" + Item
                + "]: current owner" + getPermsAsReadableString(ownerPerms));
            llSay(0, "/me [" + Item
                + "]: next owner" + getPermsAsReadableString(nextOwnerPerms));
            llSay(0, "/me [" + Item
                + "]: group" + getPermsAsReadableString(groupPerms));
            llSay(0, "/me [" + Item
                + "]: anyone" + getPermsAsReadableString(everyonePerms));

            if (!(PERM_TRANSFER & llGetInventoryPermMask(Item, MASK_OWNER)))
            {
                llSay(0, "/me [" + Item + "]: owner doesn't have transfer perms.");
            }
            else
            {
                if ( !(PERM_COPY & llGetInventoryPermMask(Item, MASK_OWNER)) )
                {
                    llSay(0, "/me [" + Item + "]: owner doesn't have copy perms. The only copy has just been given away.");
                }
                llGiveInventory(gkAv,Item);
            }
        }
    }
}

 

Edited by Rolig Loon
  • Like 2
  • Thanks 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2252 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...