Skip to contentSkip to conversation

python/semaange: fix moduleRecords.customized()

PATCH In review Vit Mojzis 3 participants 4 messages Sep 27, 2019 – Oct 1, 2019 SELinux security module

lore
Share & tools
lore

Vit Mojzis

author
#0 lore raw

PATCH 1/1 python/semaange: fix moduleRecords.customized()

Return value of "customized" has to be iterable.

Fixes:
"semanage export" with no modules in the system (eg. monolithic policy) crashes:

Traceback (most recent call last):
File "/usr/sbin/semanage", line 970, in <module>
do_parser()
File "/usr/sbin/semanage", line 949, in do_parser
args.func(args)
File "/usr/sbin/semanage", line 771, in handleExport
for c in OBJECT.customized():
TypeError: 'NoneType' object is not iterable

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -1
index 5e9e3eb5..f4c29854 100644
@@ -380,7 +380,7 @@ class moduleRecords(semanageRecords):
     def customized(self):
         all = self.get_all()
         if len(all) == 0:
-            return
+            return []
         return ["-d %s" % x[0] for x in [t for t in all if t[1] == 0]]
 
     def list(self, heading=1, locallist=0):
Signature · 1 line
2.21.0
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Vit Mojzis

Return value of "customized" has to be iterable.

Fixes:
"semanage export" with no modules in the system (eg. monolithic policy) crashes:

Traceback (most recent call last):
File "/usr/sbin/semanage", line 970, in <module>
do_parser()
File "/usr/sbin/semanage", line 949, in do_parser
args.func(args)
File "/usr/sbin/semanage", line 771, in handleExport
for c in OBJECT.customized():
TypeError: 'NoneType' object is not iterable

Quoted 1 line

This looks good to me, but there is a misspelling in the subject of the patch: semaange -> semanage.

Thanks!
Nicolas

Quoted 20 lines
---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -2
index 5e9e3eb5..f4c29854 100644
@@ -380,7 +380,7 @@ class moduleRecords(semanageRecords):
     def customized(self):
         all = self.get_all()
         if len(all) == 0:
-            return
+            return []
         return ["-d %s" % x[0] for x in [t for t in all if t[1] == 0]]
 
     def list(self, heading=1, locallist=0):
--

2.21.0

author
#2 lore raw

PATCH 1/1 python/semanage: fix moduleRecords.customized()

Return value of "customized" has to be iterable.

Fixes:
"semanage export" with no modules in the system (eg. monolithic policy) crashes:

Traceback (most recent call last):
File "/usr/sbin/semanage", line 970, in <module>
do_parser()
File "/usr/sbin/semanage", line 949, in do_parser
args.func(args)
File "/usr/sbin/semanage", line 771, in handleExport
for c in OBJECT.customized():
TypeError: 'NoneType' object is not iterable

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -1
index 5e9e3eb5..f4c29854 100644
@@ -380,7 +380,7 @@ class moduleRecords(semanageRecords):
     def customized(self):
         all = self.get_all()
         if len(all) == 0:
-            return
+            return []
         return ["-d %s" % x[0] for x in [t for t in all if t[1] == 0]]
 
     def list(self, heading=1, locallist=0):
Signature · 1 line
2.21.0
#3 lore raw

Re: [PATCH] python/semanage: fix moduleRecords.customized()

Quoted 15 lines · Vit Mojzis

Return value of "customized" has to be iterable.

Fixes:
"semanage export" with no modules in the system (eg. monolithic policy) crashes:

Traceback (most recent call last):
File "/usr/sbin/semanage", line 970, in <module>
do_parser()
File "/usr/sbin/semanage", line 949, in do_parser
args.func(args)
File "/usr/sbin/semanage", line 771, in handleExport
for c in OBJECT.customized():
TypeError: 'NoneType' object is not iterable

Quoted 1 line

Thanks, both patches applied.

Quoted 18 lines
---
  python/semanage/seobject.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -1
index 5e9e3eb5..f4c29854 100644
@@ -380,7 +380,7 @@ class moduleRecords(semanageRecords):
      def customized(self):
          all = self.get_all()
          if len(all) == 0:
-            return
+            return []
          return ["-d %s" % x[0] for x in [t for t in all if t[1] == 0]]
 
      def list(self, heading=1, locallist=0):