コード例 #1
0
ファイル: auth.php プロジェクト: ehironymous/racktables
function gotClearanceForTagChain($const_base)
{
    global $rackCode, $expl_tags, $impl_tags;
    $ptable = array();
    foreach ($rackCode as $sentence) {
        switch ($sentence['type']) {
            case 'SYNT_DEFINITION':
                $ptable[$sentence['term']] = $sentence['definition'];
                break;
            case 'SYNT_GRANT':
                if (eval_expression($sentence['condition'], array_merge($const_base, $expl_tags, $impl_tags), $ptable)) {
                    switch ($sentence['decision']) {
                        case 'LEX_ALLOW':
                            return TRUE;
                        case 'LEX_DENY':
                            return FALSE;
                        default:
                            throw new RackTablesError("Condition match for unknown grant decision '{$sentence['decision']}'", RackTablesError::INTERNAL);
                    }
                }
                break;
            case 'SYNT_ADJUSTMENT':
                if (eval_expression($sentence['condition'], array_merge($const_base, $expl_tags, $impl_tags), $ptable) and processAdjustmentSentence($sentence['modlist'], $expl_tags)) {
                    // recalculate implicit chain only after actual change, not just on matched condition
                    $impl_tags = getImplicitTags($expl_tags);
                }
                // recalculate
                break;
            default:
                throw new RackTablesError("Can't process sentence of unknown type '{$sentence['type']}'", RackTablesError::INTERNAL);
        }
    }
    return FALSE;
}
コード例 #2
0
ファイル: auth.php プロジェクト: spartak-radchenko/racktables
function gotClearanceForTagChain($const_base)
{
    global $rackCode, $expl_tags, $impl_tags;
    $context = array_merge($const_base, $expl_tags, $impl_tags);
    $context = reindexById($context, 'tag', TRUE);
    foreach ($rackCode as $sentence) {
        switch ($sentence['type']) {
            case 'SYNT_GRANT':
                if (eval_expression($sentence['condition'], $context)) {
                    return $sentence['decision'];
                }
                break;
            case 'SYNT_ADJUSTMENT':
                if (eval_expression($sentence['condition'], $context) and processAdjustmentSentence($sentence['modlist'], $expl_tags)) {
                    $impl_tags = getImplicitTags($expl_tags);
                    // recalculate
                    $context = array_merge($const_base, $expl_tags, $impl_tags);
                    $context = reindexById($context, 'tag', TRUE);
                }
                break;
            default:
                throw new RackTablesError("Can't process sentence of unknown type '{$sentence['type']}'", RackTablesError::INTERNAL);
        }
    }
    return FALSE;
}