mirror of
https://github.com/SELinuxProject/setools
synced 2025-04-22 23:25:16 +00:00
Fix xperm rendering to use Python built-in "0x" formatting
Also swap low/high if they are backwards in the TERuleQuery setter instead of erroring out
This commit is contained in:
parent
1370cfd20f
commit
02f5b9a329
@ -182,9 +182,9 @@ class ioctlSet(set):
|
|||||||
for _, i in itertools.groupby(perms, key=lambda k, c=itertools.count(): k - next(c)):
|
for _, i in itertools.groupby(perms, key=lambda k, c=itertools.count(): k - next(c)):
|
||||||
group = list(i)
|
group = list(i)
|
||||||
if len(group) > 1:
|
if len(group) > 1:
|
||||||
shortlist.append("0x{0:04x}-0x{1:04x}".format(group[0], group[-1]))
|
shortlist.append("{0:#06x}-{1:#06x}".format(group[0], group[-1]))
|
||||||
else:
|
else:
|
||||||
shortlist.append("0x{0:04x}".format(group[0]))
|
shortlist.append("{0:#06x}".format(group[0]))
|
||||||
|
|
||||||
if not spec:
|
if not spec:
|
||||||
return " ".join(shortlist)
|
return " ".join(shortlist)
|
||||||
|
@ -107,14 +107,13 @@ class TERuleQuery(mixins.MatchObjClass, mixins.MatchPermission, query.PolicyQuer
|
|||||||
|
|
||||||
for low, high in value:
|
for low, high in value:
|
||||||
if not (0 <= low <= 0xffff):
|
if not (0 <= low <= 0xffff):
|
||||||
raise ValueError("{0:04x} is not a valid ioctl.".format(low))
|
raise ValueError("{0:#07x} is not a valid ioctl.".format(low))
|
||||||
|
|
||||||
if not (0 <= high <= 0xffff):
|
if not (0 <= high <= 0xffff):
|
||||||
raise ValueError("{0:04x} is not a valid ioctl.".format(high))
|
raise ValueError("{0:#07x} is not a valid ioctl.".format(high))
|
||||||
|
|
||||||
if high < low:
|
if high < low:
|
||||||
raise ValueError("0x{0:04x}-0x{1:04x} is not a valid ioctl range.".
|
high, low = low, high
|
||||||
format(low, high))
|
|
||||||
|
|
||||||
pending_xperms.update(i for i in range(low, high+1))
|
pending_xperms.update(i for i in range(low, high+1))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user