Ejemplo n.º 1
0
def check_dominance2(con1, con2, debug=False):
    (rc, raw_con1) = selinux.selinux_trans_to_raw_context(con1)
    (rc, raw_con2) = selinux.selinux_trans_to_raw_context(con2)

    avd = selinux.av_decision()
    selinux.avc_reset()
    if debug:
        logging.debug("check_dominance2: " + raw_con1 + " " + raw_con2)
    rc = selinux.security_compute_av_raw(raw_con1, raw_con2, SECCLASS_CONTEXT, CONTEXT__CONTAINS, avd)
    if rc < 0:
        raise Exception("selinux.security_compute_av_raw failed")
    if (avd.allowed & CONTEXT__CONTAINS) == CONTEXT__CONTAINS:
        return True
    else:
        return False
Ejemplo n.º 2
0
def check_dominance2(con1, con2, debug=False):
    (rc, raw_con1) = selinux.selinux_trans_to_raw_context(con1)
    (rc, raw_con2) = selinux.selinux_trans_to_raw_context(con2)

    avd = selinux.av_decision()
    selinux.avc_reset()
    if debug:
        logging.debug("check_dominance2: " + raw_con1 + " " + raw_con2)
    rc = selinux.security_compute_av_raw(raw_con1, raw_con2, SECCLASS_CONTEXT,
                                         CONTEXT__CONTAINS, avd)
    if rc < 0:
        raise Exception("selinux.security_compute_av_raw failed")
    if (avd.allowed & CONTEXT__CONTAINS) == CONTEXT__CONTAINS:
        return True
    else:
        return False
Ejemplo n.º 3
0
def check_dominance(con, debug=False):
    (rc, raw_con) = selinux.selinux_trans_to_raw_context(con)
    if rc != 0:
        raise Exception("selinux.selinux_trans_to_raw_context failed: %d" % rc)
 
    avd = selinux.av_decision()
    selinux.avc_reset()
    if debug:
        logging.debug("check_dominance: %s %s" % (dom_raw_context, raw_con))
    rc = selinux.security_compute_av_raw(dom_raw_context, raw_con, SECCLASS_CONTEXT, CONTEXT__CONTAINS, avd)
    if rc < 0:
        raise Exception("selinux.security_compute_av_raw failed")
    if (avd.allowed & CONTEXT__CONTAINS) == CONTEXT__CONTAINS:
        if debug:
            logging.debug("check_dominance: returned True")
        return True
    else:
        if debug:
            logging.debug("check_dominance: returned False")
        return False
Ejemplo n.º 4
0
def check_dominance(con, debug=False):
    (rc, raw_con) = selinux.selinux_trans_to_raw_context(con)
    if rc != 0:
        raise Exception("selinux.selinux_trans_to_raw_context failed: %d" % rc)

    avd = selinux.av_decision()
    selinux.avc_reset()
    if debug:
        logging.debug("check_dominance: %s %s" % (dom_raw_context, raw_con))
    rc = selinux.security_compute_av_raw(dom_raw_context, raw_con,
                                         SECCLASS_CONTEXT, CONTEXT__CONTAINS,
                                         avd)
    if rc < 0:
        raise Exception("selinux.security_compute_av_raw failed")
    if (avd.allowed & CONTEXT__CONTAINS) == CONTEXT__CONTAINS:
        if debug:
            logging.debug("check_dominance: returned True")
        return True
    else:
        if debug:
            logging.debug("check_dominance: returned False")
        return False