Discussion:
[PATCH] python/semanage: Fix export of ibendport entries
Vit Mojzis
2017-11-10 15:28:44 UTC
Permalink
Replace nonexistent switch "-x" by "-z" (entry name).
Fix invalid index (the dictionary key is a 2-tuple).
Add MLS/MCS range (present in all entries).

Fixes:
#semanage ibendport -E
File "/usr/sbin/semanage", line 1049, in <module>
do_parser()
File "/usr/sbin/semanage", line 1028, in do_parser
args.func(args)
File "/usr/sbin/semanage", line 605, in handleIbendport
for i in OBJECT.customized():
File "/usr/lib64/python2.7/site-packages/seobject/__init__.py", line 1806, in customized
l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0]))
IndexError: tuple index out of range

Signed-off-by: Vit Mojzis <***@redhat.com>
---
python/semanage/seobject.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index 228c8ae..380256b 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
@@ -1788,7 +1788,7 @@ class ibendportRecords(semanageRecords):
keys = ddict.keys()
keys.sort()
for k in keys:
- l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0]))
+ l.append("-a -t %s -r %s -z %s %s" % (ddict[k][0], ddict[k][1], k[1], k[0]))
return l

def list(self, heading=1, locallist=0):
--
2.9.4
Petr Lautrbach
2017-11-14 08:33:54 UTC
Permalink
Update Infiniband "port" and "key" listing and export to work on
python3.
{}.keys() does not support .sort() operation on Py3.
Both patches look good to me. I'll merge them tomorrow if there's no
other comments.

Thanks,

Petr
---
python/semanage/seobject.py | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index 380256b..770745e 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
l = []
ddict = self.get_all(True)
- keys = ddict.keys()
- keys.sort()
+
l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0]))
keys = ddict.keys()
return
- keys.sort()
print("%-30s %-18s %s\n" % (_("SELinux IB Pkey Type"), _("Subnet_Prefix"), _("Pkey Number")))
rec = "%-30s %-18s " % i
rec += "%s" % ddict[i][0]
l = []
ddict = self.get_all(True)
- keys = ddict.keys()
- keys.sort()
+
l.append("-a -t %s -r %s -z %s %s" % (ddict[k][0], ddict[k][1], k[1], k[0]))
return l
keys = ddict.keys()
return
- keys.sort()
print("%-30s %-18s %s\n" % (_("SELinux IB End Port Type"), _("IB Device Name"), _("Port Number")))
rec = "%-30s %-18s " % i
rec += "%s" % ddict[i][0]
--
2.9.4
Petr Lautrbach
2017-11-15 13:21:27 UTC
Permalink
Post by Petr Lautrbach
Update Infiniband "port" and "key" listing and export to work on
python3.
{}.keys() does not support .sort() operation on Py3.
Both patches look good to me. I'll merge them tomorrow if there's no
other comments.
Merged. Thanks!
Post by Petr Lautrbach
---
python/semanage/seobject.py | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index 380256b..770745e 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
l = []
ddict = self.get_all(True)
- keys = ddict.keys()
- keys.sort()
+
l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0]))
keys = ddict.keys()
return
- keys.sort()
print("%-30s %-18s %s\n" % (_("SELinux IB Pkey Type"), _("Subnet_Prefix"), _("Pkey Number")))
rec = "%-30s %-18s " % i
rec += "%s" % ddict[i][0]
l = []
ddict = self.get_all(True)
- keys = ddict.keys()
- keys.sort()
+
l.append("-a -t %s -r %s -z %s %s" % (ddict[k][0], ddict[k][1], k[1], k[0]))
return l
keys = ddict.keys()
return
- keys.sort()
print("%-30s %-18s %s\n" % (_("SELinux IB End Port Type"), _("IB Device Name"), _("Port Number")))
rec = "%-30s %-18s " % i
rec += "%s" % ddict[i][0]
--
2.9.4
Loading...