mirror of
https://github.com/SELinuxProject/setools
synced 2025-04-01 22:58:12 +00:00
policyrep: Misc cython tweaks.
This commit is contained in:
parent
8f77510bcb
commit
6e67c3b8b4
setools/policyrep
@ -45,7 +45,7 @@ cdef class Bounds(PolicySymbol):
|
|||||||
b.policy = policy
|
b.policy = policy
|
||||||
return b
|
return b
|
||||||
|
|
||||||
def __init__(self, parent, child):
|
def __cinit__(self, parent, child):
|
||||||
self.ruletype = BoundsRuletype.typebounds
|
self.ruletype = BoundsRuletype.typebounds
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.child = child
|
self.child = child
|
||||||
@ -97,10 +97,11 @@ cdef class TypeboundsIterator(HashtabIterator):
|
|||||||
Type.factory(self.policy, datum))
|
Type.factory(self.policy, datum))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
cdef sepol.type_datum_t *datum
|
cdef:
|
||||||
cdef sepol.hashtab_node_t *node
|
sepol.type_datum_t *datum
|
||||||
cdef uint32_t bucket = 0
|
sepol.hashtab_node_t *node
|
||||||
cdef size_t count = 0
|
uint32_t bucket = 0
|
||||||
|
size_t count = 0
|
||||||
|
|
||||||
while bucket < self.table[0].size:
|
while bucket < self.table[0].size:
|
||||||
node = self.table[0].htable[bucket]
|
node = self.table[0].htable[bucket]
|
||||||
|
@ -44,7 +44,7 @@ cdef class MLSRule(PolicyRule):
|
|||||||
r.handle = symbol
|
r.handle = symbol
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def __init__(self, rng):
|
def __cinit__(self, rng):
|
||||||
self.ruletype = MLSRuletype.range_transition
|
self.ruletype = MLSRuletype.range_transition
|
||||||
self.rng = rng
|
self.rng = rng
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ cdef class RoleAllow(PolicyRule):
|
|||||||
r.handle = symbol
|
r.handle = symbol
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def __init__(self):
|
def __cinit__(self):
|
||||||
self.ruletype = RBACRuletype.allow
|
self.ruletype = RBACRuletype.allow
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -106,7 +106,7 @@ cdef class RoleTransition(PolicyRule):
|
|||||||
r.handle = symbol
|
r.handle = symbol
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def __init__(self):
|
def __cinit__(self):
|
||||||
self.ruletype = RBACRuletype.role_transition
|
self.ruletype = RBACRuletype.role_transition
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -22,11 +22,9 @@ cdef class PolicyRule(PolicySymbol):
|
|||||||
|
|
||||||
"""This is base class for policy rules."""
|
"""This is base class for policy rules."""
|
||||||
|
|
||||||
|
# This is initialized to False
|
||||||
cdef readonly bint extended
|
cdef readonly bint extended
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.extended = False
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -25,8 +25,7 @@ cdef class PolicySymbol:
|
|||||||
|
|
||||||
"""This is a base class for all policy objects."""
|
"""This is a base class for all policy objects."""
|
||||||
|
|
||||||
cdef:
|
cdef readonly SELinuxPolicy policy
|
||||||
readonly SELinuxPolicy policy
|
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(str(self))
|
return hash(str(self))
|
||||||
@ -145,6 +144,7 @@ cdef class EbitmapIterator(PolicyIterator):
|
|||||||
cdef:
|
cdef:
|
||||||
sepol.ebitmap_node_t *node
|
sepol.ebitmap_node_t *node
|
||||||
size_t curr
|
size_t curr
|
||||||
|
size_t count = 0
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
curr = sepol.ebitmap_start(self.bmap, &node)
|
curr = sepol.ebitmap_start(self.bmap, &node)
|
||||||
@ -184,7 +184,7 @@ cdef class HashtabIterator(PolicyIterator):
|
|||||||
sepol.hashtab_node_t *curr
|
sepol.hashtab_node_t *curr
|
||||||
unsigned int bucket
|
unsigned int bucket
|
||||||
|
|
||||||
def _next_bucket(self):
|
cdef void _next_bucket(self):
|
||||||
"""Internal method for advancing to the next bucket."""
|
"""Internal method for advancing to the next bucket."""
|
||||||
self.bucket += 1
|
self.bucket += 1
|
||||||
if self.bucket < self.table[0].size:
|
if self.bucket < self.table[0].size:
|
||||||
@ -192,7 +192,7 @@ cdef class HashtabIterator(PolicyIterator):
|
|||||||
else:
|
else:
|
||||||
self.node = NULL
|
self.node = NULL
|
||||||
|
|
||||||
def _next_node(self):
|
cdef void _next_node(self):
|
||||||
"""Internal method for advancing to the next node."""
|
"""Internal method for advancing to the next node."""
|
||||||
if self.node != NULL and self.node.next != NULL:
|
if self.node != NULL and self.node.next != NULL:
|
||||||
self.node = self.node.next
|
self.node = self.node.next
|
||||||
|
@ -282,7 +282,7 @@ cdef class AVRuleXperm(AVRule):
|
|||||||
r._conditional_block = conditional_block
|
r._conditional_block = conditional_block
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def __init__(self):
|
def __cinit__(self):
|
||||||
self.extended = True
|
self.extended = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -481,7 +481,7 @@ cdef class FileNameTERule(PolicyRule):
|
|||||||
r.datum = datum
|
r.datum = datum
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def __init__(self):
|
def __cinit__(self):
|
||||||
self.ruletype = TERuletype.type_transition
|
self.ruletype = TERuletype.type_transition
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user