Commit 50223519 authored by Jan Koester's avatar Jan Koester
Browse files

test

parent dcb21e04
Loading
Loading
Loading
Loading
Loading
+33 −0
Changes for src/session.cpp: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -383,6 +383,39 @@ void reloadSessionData(AuthBackend &backend, SessionData *cursess){
            cursess->_members.emplace_back(gid);
    }
    cursess->_username=username;

    // Re-evaluate GPOs as well (same rules as createSessionData); otherwise new or
    // changed GPOs only take effect for sessions created afterwards.
    std::vector<std::pair<uuid::uuid, bool>> results;
    Gpo gpo;
    std::vector<uuid::uuid> gpoids;
    std::vector<uuid::uuid> allow;
    gpo.list(backend, gpoids);
    for(auto &gpoid : gpoids){
        std::shared_ptr<class GpoData> gpodat=std::make_shared<class GpoData>(gpoid);
        size_t gpos2=sizeof(AuthHeader);
        gpo.info(backend,*gpodat,gpos2);
        bool res=gpodat->getGpoValue();
        allow.clear();
        gpodat->getAlowed(allow);
        for(const uuid::uuid &al : allow){
            for(const uuid::uuid &member : cursess->_members){
                if(member==al)
                    res=gpodat->getGpoValue() ? false : true;
            }
        }
        results.emplace_back(gpoid,res);
    }
    // Keep defaults for built-in GPOs that are not stored in the backend
    for(size_t i=0; gpo_default[i][0]!=nullptr; ++i){
        uuid::uuid defid(gpo_default[i][0]);
        bool found=false;
        for(const auto &r : results)
            if(r.first==defid){ found=true; break; }
        if(!found)
            results.emplace_back(defid, strcmp(gpo_default[i][3],"true")==0);
    }
    cursess->setGPOResults(results);
}

} // namespace authdb