Пример #1
0
void findUnusedFilesInDFS(StringArray &unusedFiles, const char *process, const MapStringTo<bool> &usedFileMap)
{
    Owned<IRemoteConnection> globalLock = querySDS().connect("/Files/", myProcessSession(), RTM_LOCK_READ, SDS_LOCK_TIMEOUT);
    Owned<IPropertyTree> root = globalLock->getRoot();

    VStringBuffer xpath("//File[Cluster/@name='%s']/OrigName", process);
    Owned<IPropertyTreeIterator> files = root->getElements(xpath);
    ForEach(*files)
    {
        const char *lfn = skipTilda(files->query().queryProp(NULL));
        if (lfn && !usedFileMap.getValue(lfn))
            unusedFiles.append(lfn);
    }
}
Пример #2
0
bool SecHandler::validateSecFeaturesAccess(MapStringTo<SecAccessFlags> & accessmap, bool throwExcpt)
{
    StringArray features;
    unsigned reqarray[100];
    if (accessmap.ordinality() >= 100)
        throw MakeStringException(-1, "Attempting to validate too many security features!");

    HashIterator iter(accessmap);
    int index = 0;
    ForEach(iter)
    {
        IMapping &cur = iter.query();
        const char * key = (const char *)cur.getKey();
        SecAccessFlags val = *accessmap.getValue(key);
        features.append(key);
        reqarray[index++] = val;
    }

    Owned<IEspStringIntMap> pmap=createStringIntMap();

    if (authorizeSecReqFeatures(features, *pmap, reqarray))
    {
        for(unsigned i = 0; i < features.length(); i++)
        {
            int accessAllowed = pmap->queryValue(features.item(i));
            if ((accessAllowed == -1) || (reqarray[i] && (accessAllowed < reqarray[i])))
            {
                if (throwExcpt)
                    throw MakeStringException(-1, "Access Denied!");
                return false;
            }
        }

        return true;
    }

    if (throwExcpt)
        throw MakeStringException(-1, "Access Denied!");

    return false;
}