diff mbox series

python/semanage: fix moduleRecords.customized()

Message ID 20190930074904.25219-1-vmojzis@redhat.com (mailing list archive)
State Accepted
Headers show
Series python/semanage: fix moduleRecords.customized() | expand

Commit Message

Vit Mojzis Sept. 30, 2019, 7:49 a.m. UTC
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

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

Comments

Stephen Smalley Oct. 1, 2019, 6:28 p.m. UTC | #1
On 9/30/19 3:49 AM, Vit Mojzis wrote:
> 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
> 
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>

Thanks, both patches applied.

> ---
>   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 5e9e3eb5..f4c29854 100644
> --- a/python/semanage/seobject.py
> +++ b/python/semanage/seobject.py
> @@ -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):
>
diff mbox series

Patch

diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index 5e9e3eb5..f4c29854 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
@@ -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):