S32 LLInventoryItem::packBinaryBucket(U8* bin_bucket, LLPermissions* perm_override) const { // Figure out which permissions to use. LLPermissions perm; if (perm_override) { // Use the permissions override. perm = *perm_override; } else { // Use the current permissions. perm = getPermissions(); } // describe the inventory item char* buffer = (char*) bin_bucket; std::string creator_id_str; perm.getCreator().toString(creator_id_str); std::string owner_id_str; perm.getOwner().toString(owner_id_str); std::string last_owner_id_str; perm.getLastOwner().toString(last_owner_id_str); std::string group_id_str; perm.getGroup().toString(group_id_str); std::string asset_id_str; getAssetUUID().toString(asset_id_str); S32 size = sprintf(buffer, /* Flawfinder: ignore */ "%d|%d|%s|%s|%s|%s|%s|%x|%x|%x|%x|%x|%s|%s|%d|%d|%x", getType(), getInventoryType(), getName().c_str(), creator_id_str.c_str(), owner_id_str.c_str(), last_owner_id_str.c_str(), group_id_str.c_str(), perm.getMaskBase(), perm.getMaskOwner(), perm.getMaskGroup(), perm.getMaskEveryone(), perm.getMaskNextOwner(), asset_id_str.c_str(), getDescription().c_str(), getSaleInfo().getSaleType(), getSaleInfo().getSalePrice(), getFlags()) + 1; return size; }
void permission_object_t::test<1>() { LLPermissions permissions; LLUUID uuid = permissions.getCreator(); LLUUID uuid1 = permissions.getOwner(); LLUUID uuid2 = permissions.getGroup(); LLUUID uuid3 = permissions.getLastOwner(); ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null && uuid2 == LLUUID::null && uuid3 == LLUUID::null)); ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL && permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL)); ensure("Ownership functions failed", (permissions.isGroupOwned() == FALSE && permissions.isOwned() == FALSE)); }
LLSD ll_create_sd_from_permissions(const LLPermissions& perm) { LLSD rv; rv[PERM_CREATOR_ID_LABEL] = perm.getCreator(); rv[PERM_OWNER_ID_LABEL] = perm.getOwner(); rv[PERM_LAST_OWNER_ID_LABEL] = perm.getLastOwner(); rv[PERM_GROUP_ID_LABEL] = perm.getGroup(); rv[PERM_IS_OWNER_GROUP_LABEL] = perm.isGroupOwned(); rv[PERM_BASE_MASK_LABEL] = (S32)perm.getMaskBase(); rv[PERM_OWNER_MASK_LABEL] = (S32)perm.getMaskOwner(); rv[PERM_GROUP_MASK_LABEL] = (S32)perm.getMaskGroup(); rv[PERM_EVERYONE_MASK_LABEL] = (S32)perm.getMaskEveryone(); rv[PERM_NEXT_OWNER_MASK_LABEL] = (S32)perm.getMaskNextOwner(); return rv; }
void permission_object_t::test<3>() { LLPermissions permissions; U32 base = PERM_ALL; U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER; U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY; U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY; U32 next = PERM_NONE; U32 fixedbase = base; U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify. U32 fixednext = PERM_NONE; permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed. ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase()); ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner()); ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup()); ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone()); ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner()); // explictly set should maintain the values permissions.setMaskBase(base); //no fixing ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase()); permissions.setMaskOwner(owner); ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner()); permissions.setMaskEveryone(everyone); ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone()); permissions.setMaskGroup(group); ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup()); permissions.setMaskNext(next); ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner()); // further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed. // code however suggests that there is no explict check if the perms are correct and the user of this // class is expected to know how to use them correctly. skipping further test cases for now for various // perm combinations. }