From patchwork Mon Sep 30 07:49:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vit Mojzis X-Patchwork-Id: 11166149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3582413BD for ; Mon, 30 Sep 2019 07:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D80C218DE for ; Mon, 30 Sep 2019 07:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729748AbfI3HtI (ORCPT ); Mon, 30 Sep 2019 03:49:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41888 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729740AbfI3HtI (ORCPT ); Mon, 30 Sep 2019 03:49:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61C1DC049E23 for ; Mon, 30 Sep 2019 07:49:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.12.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5C9D5D6D0 for ; Mon, 30 Sep 2019 07:49:07 +0000 (UTC) From: Vit Mojzis To: selinux@vger.kernel.org Subject: [PATCH] python/semanage: fix moduleRecords.customized() Date: Mon, 30 Sep 2019 09:49:04 +0200 Message-Id: <20190930074904.25219-1-vmojzis@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 30 Sep 2019 07:49:08 +0000 (UTC) Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 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 --- 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):