From patchwork Sat Jan 5 15:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 10749299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87A1614E2 for ; Sat, 5 Jan 2019 15:46:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76B1F28800 for ; Sat, 5 Jan 2019 15:46:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ACA128802; Sat, 5 Jan 2019 15:46:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D18C028800 for ; Sat, 5 Jan 2019 15:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726279AbfAEPqW (ORCPT ); Sat, 5 Jan 2019 10:46:22 -0500 Received: from mx1.polytechnique.org ([129.104.30.34]:34514 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbfAEPqW (ORCPT ); Sat, 5 Jan 2019 10:46:22 -0500 Received: from localhost.localdomain (89-156-252-9.rev.numericable.fr [89.156.252.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id D1AA1561204 for ; Sat, 5 Jan 2019 16:46:19 +0100 (CET) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 1/2] python/semanage: explain why sepolicy is imported in a function Date: Sat, 5 Jan 2019 16:45:50 +0100 Message-Id: <20190105154551.18768-1-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jan 5 16:46:20 2019 +0100 (CET)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Importing modules inside functions is quite uncommon in Python. This is nevertheless required with sepolicy because it loads the current SELinux policy when it is imported (and raises ValueError when this fails). Signed-off-by: Nicolas Iooss --- python/semanage/semanage | 1 + 1 file changed, 1 insertion(+) diff --git a/python/semanage/semanage b/python/semanage/semanage index 1cb136831422..49add51ec24e 100644 --- a/python/semanage/semanage +++ b/python/semanage/semanage @@ -83,6 +83,7 @@ class CheckRole(argparse.Action): if not newval: newval = [] try: + # sepolicy tries to load the SELinux policy and raises ValueError if it fails. import sepolicy roles = sepolicy.get_all_roles() except ValueError: