Fix dereferencing in policyrep.typeattr factories.

Qpol already dereferences aliases internally.
This commit is contained in:
Chris PeBenito 2015-03-16 10:40:53 -04:00
parent f4b1b68195
commit 39898d9572
2 changed files with 6 additions and 17 deletions

2
seinfo
View File

@ -225,7 +225,7 @@ try:
print(" Sensitivities: {0:7} Categories: {1:7}".format(
p.level_count, p.category_count))
print(" Types: {0:7} Attributes: {1:7}".format(
p.type_count, p.type_attribute_count))
p.type_count, p.attribute_count))
print(" Users: {0:7} Roles: {1:7}".format(
p.user_count, p.role_count))
print(" Booleans: {0:7} Cond. Expr.: {1:7}".format(

View File

@ -37,18 +37,13 @@ def _symbol_lookup(qpol_policy, name):
raise InvalidType("{0} is not a valid type/attribute".format(name))
def _dereference_alias(qpol_policy, qpol_symbol):
"""Determine the actual type by from an alias."""
raise NotImplementedError
def attribute_factory(qpol_policy, name):
"""Factory function for creating attribute objects."""
qpol_symbol = _symbol_lookup(qpol_policy, name)
if not qpol_symbol.isattr(qpol_policy):
raise TypeError("{0} is not an attribute".format(qpol_symbol.name(qpol_policy)))
raise TypeError("{0} is a type".format(qpol_symbol.name(qpol_policy)))
return TypeAttribute(qpol_policy, qpol_symbol)
@ -59,11 +54,8 @@ def type_factory(qpol_policy, name, deref=False):
qpol_symbol = _symbol_lookup(qpol_policy, name)
if qpol_symbol.isattr(qpol_policy):
raise TypeError("{0} is a not an attribute type".format(qpol_symbol.name(qpol_policy)))
elif qpol_symbol.isalias(qpol_policy):
if deref:
qpol_symbol = _dereference_alias(qpol_policy, qpol_symbol)
else:
raise TypeError("{0} is an attribute".format(qpol_symbol.name(qpol_policy)))
elif qpol_symbol.isalias(qpol_policy) and not deref:
raise TypeError("{0} is an alias.".format(qpol_symbol.name(qpol_policy)))
return Type(qpol_policy, qpol_symbol)
@ -74,11 +66,8 @@ def type_or_attr_factory(qpol_policy, name, deref=False):
qpol_symbol = _symbol_lookup(qpol_policy, name)
if qpol_symbol.isalias(qpol_policy):
if deref:
qpol_symbol = _dereference_alias(qpol_policy, qpol_symbol)
else:
raise TypeError("{0} is an alias.".format(qpol_symbol.name(qpol_policy)))
if qpol_symbol.isalias(qpol_policy) and not deref:
raise TypeError("{0} is an alias.".format(qpol_symbol.name(qpol_policy)))
if qpol_symbol.isattr(qpol_policy):
return TypeAttribute(qpol_policy, qpol_symbol)