mirror of
https://github.com/SELinuxProject/setools
synced 2025-04-11 03:51:26 +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)):
|
||||
group = list(i)
|
||||
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:
|
||||
shortlist.append("0x{0:04x}".format(group[0]))
|
||||
shortlist.append("{0:#06x}".format(group[0]))
|
||||
|
||||
if not spec:
|
||||
return " ".join(shortlist)
|
||||
|
@ -107,14 +107,13 @@ class TERuleQuery(mixins.MatchObjClass, mixins.MatchPermission, query.PolicyQuer
|
||||
|
||||
for low, high in value:
|
||||
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):
|
||||
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:
|
||||
raise ValueError("0x{0:04x}-0x{1:04x} is not a valid ioctl range.".
|
||||
format(low, high))
|
||||
high, low = low, high
|
||||
|
||||
pending_xperms.update(i for i in range(low, high+1))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user