From patchwork Mon Nov 7 08:01:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Bigonville X-Patchwork-Id: 9414415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69A536022E for ; Mon, 7 Nov 2016 08:02:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58C6B28D60 for ; Mon, 7 Nov 2016 08:02:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D70928D62; Mon, 7 Nov 2016 08:02:43 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from emsm-gh1-uea10.nsa.gov (smtp.nsa.gov [8.44.101.8]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 345ED28D61 for ; Mon, 7 Nov 2016 08:02:41 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.31,605,1473120000"; d="scan'208";a="663373" IronPort-PHdr: =?us-ascii?q?9a23=3AZQ9U/Rx/UjA4VCTXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?0e8VIJqq85mqBkHD//Il1AaPBtSBraMfwLCJ4+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL2PbrnD61zMOABK3bVMz?= =?us-ascii?q?fbWvXN+JxJ7oh6ibwN76W01wnj2zYLd/fl2djD76kY0ou7ZkMbs70RDTo3FFKK?= =?us-ascii?q?x8zGJsIk+PzV6nvp/jtKN592xsn95pt4sZCeSpN5g/GKdVCDUgLnAd+NzgtR6F?= =?us-ascii?q?SxCGoHQbTDY4iB1NVizM8Qv3WIu5mCr1sexj2S2eMIWiR7E7XjKK46phSRbuzi?= =?us-ascii?q?AdOGhqoynslsVsgfcD81qarBtlztuROdmY?= X-IPAS-Result: =?us-ascii?q?A2HlHwDWNCBY/wHyM5BdHAEBBAEBCgEBgxQaAQEBAQEfgVS?= =?us-ascii?q?jCgoBBpdqKoF7hiBTAQEBAQEBAQECAQJfKIIzBAMTBXlbQwI3BgEBDCAMAgMJA?= =?us-ascii?q?hcIIQgIAwEtCwofCwUYBIg3AQMBr2KDJzgCgl8BAQWIJR0IhXSJOBEBaIUUmiy?= =?us-ascii?q?JQIZ5C4oNhgORLgJVViQbgweCCXGFXHiBNQEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 07 Nov 2016 08:02:21 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id uA781W6N006321; Mon, 7 Nov 2016 03:01:42 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id uA781Uqi194054 for ; Mon, 7 Nov 2016 03:01:30 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id uA781U69006318 for ; Mon, 7 Nov 2016 03:01:30 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BxJQBSNCBY/2OteVtdHAEBBAEBCgEBgxQaAQEBAQEfgVSjCgUBAQEBAQEGk1+EMIggUwECAQEBAQECYiiFKAEBOC9tNIhZAwGvYoMngxkBAQWIQgiFdIoyhRSaLIlAhnkLkBCRLgJVehuCRAw3gglxiAkBAQE X-IPAS-Result: A1BxJQBSNCBY/2OteVtdHAEBBAEBCgEBgxQaAQEBAQEfgVSjCgUBAQEBAQEGk1+EMIggUwECAQEBAQECYiiFKAEBOC9tNIhZAwGvYoMngxkBAQWIQgiFdIoyhRSaLIlAhnkLkBCRLgJVehuCRAw3gglxiAkBAQE X-IronPort-AV: E=Sophos;i="5.31,605,1473134400"; d="scan'208";a="5807429" Received: from emsm-gh1-uea10.corp.nsa.gov (HELO emsm-gh1-uea10.nsa.gov) ([10.208.41.36]) by goalie.tycho.ncsc.mil with ESMTP; 07 Nov 2016 03:01:25 -0500 IronPort-PHdr: =?us-ascii?q?9a23=3AESxlMRUxq+fhM832cC9IxFujX4DV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYZhePt8tkgFKBZ4jH8fUM07OQ6PG6Hz1bqsze4DgrS99lb1c9k8?= =?us-ascii?q?IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9?= =?us-ascii?q?HOnpAIma153xjLHovcyIKF8X1HKUWvBbFF2OtwLft80b08NJC50a7V/3mEZOYP?= =?us-ascii?q?lc3mhyJFiezF7W78a0+4N/oWwL46pyv50IbaKvZKk8TLpFHBw6Ims144vtrhCF?= =?us-ascii?q?QgyRtVUGVWBDthNVGQXD8FnQX5j2tDX7su5wkH2QPMLxS5g4VD6j5qEtTwXn3n?= =?us-ascii?q?RUfwUl+X3a35QjxJlQpwis8kRy?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HdIAC9MyBY/2OteVtdHQEFAQsBGAEFA?= =?us-ascii?q?QsBgmkaAQEBAQEfgVSjCgoBBpNfhDCCAIYfUwEBAQEBAQEBAgECXyiCMxiBAFu?= =?us-ascii?q?BAgEBOC9tNIhZAwGvYYMngxkBAQWIQgiFdIoyhRSaLIlAhnkLkBCRLgJVehuCR?= =?us-ascii?q?Aw3gglxiAkBAQE?= X-IPAS-Result: =?us-ascii?q?A0HdIAC9MyBY/2OteVtdHQEFAQsBGAEFAQsBgmkaAQEBAQE?= =?us-ascii?q?fgVSjCgoBBpNfhDCCAIYfUwEBAQEBAQEBAgECXyiCMxiBAFuBAgEBOC9tNIhZA?= =?us-ascii?q?wGvYYMngxkBAQWIQgiFdIoyhRSaLIlAhnkLkBCRLgJVehuCRAw3gglxiAkBAQE?= X-IronPort-AV: E=Sophos;i="5.31,605,1473120000"; d="scan'208";a="663368" Received: from anor.bigon.be ([91.121.173.99]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2016 08:01:22 +0000 Received: from anor.bigon.be (localhost.localdomain [127.0.0.1]) by anor.bigon.be (Postfix) with ESMTP id EE4871A1AF for ; Mon, 7 Nov 2016 09:01:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bigon.be; h= x-mailer:message-id:date:date:subject:subject:from:from:received :received:received; s=key1; t=1478505678; x=1480320079; bh=JXKwZ RimlzV66aKVW5g3u5Sn04ZJTNNpfMvWRtKDcHQ=; b=BmXHcAYoF7/OTZSPt5Bw8 jrkia5fy9Hy4YM9WbTcQtbbmEra9pKdSeMU25f0rd7WGY7QF/CSeUHbBjSZ1wUDr VKHIKtoCXptT5VW5d6Ens5Rl3rkps9b0e3tqc1Tz4RaBKz5auSqGY+E18XNzpsPg 2jDMBBJaDNqKCnaryx8HHM= X-Virus-Scanned: Debian amavisd-new at bigon.be Received: from anor.bigon.be ([127.0.0.1]) by anor.bigon.be (anor.bigon.be [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cy3Ag4o_u-r6 for ; Mon, 7 Nov 2016 09:01:18 +0100 (CET) Received: from fornost.bigon.be (unknown [IPv6:2a02:a03f:6c:e500:edf:2fd8:fc0a:f176]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bigon) by anor.bigon.be (Postfix) with ESMTPSA id 2C8D01A1AE for ; Mon, 7 Nov 2016 09:01:18 +0100 (CET) Received: from bigon (uid 1000) (envelope-from bigon@bigon.be) id 3fb6d by fornost.bigon.be (DragonFly Mail Agent v0.11); Mon, 07 Nov 2016 09:01:17 +0100 From: Laurent Bigonville To: selinux@tycho.nsa.gov Subject: [PATCH 1/2] Sandbox: Use next() over the sepolicy.info() result Date: Mon, 7 Nov 2016 09:01:16 +0100 Message-Id: <20161107080117.24030-1-bigon@debian.org> X-Mailer: git-send-email 2.10.2 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Bigonville sepolicy.info() now returns a generator, use next() to get the results. Signed-off-by: Laurent Bigonville --- policycoreutils/sandbox/sandbox | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/policycoreutils/sandbox/sandbox b/policycoreutils/sandbox/sandbox index 4010e83..c07a1d8 100644 --- a/policycoreutils/sandbox/sandbox +++ b/policycoreutils/sandbox/sandbox @@ -305,8 +305,8 @@ kill -TERM $WM_PID 2> /dev/null types = _(""" Policy defines the following types for use with the -t: \t%s -""") % "\n\t".join(list(sepolicy.info(sepolicy.ATTRIBUTE, "sandbox_type"))[0]['types']) - except RuntimeError: +""") % "\n\t".join(next(sepolicy.info(sepolicy.ATTRIBUTE, "sandbox_type"))['types']) + except StopIteration: pass usage = _(""" @@ -380,8 +380,8 @@ sandbox [-h] [-l level ] [-[X|M] [-H homedir] [-T tempdir]] [-I includefile ] [- self.setype = DEFAULT_X_TYPE else: try: - sepolicy.info(sepolicy.TYPE, "sandbox_t") - except RuntimeError: + next(sepolicy.info(sepolicy.TYPE, "sandbox_t")) + except StopIteration: raise ValueError(_("Sandbox Policy is not currently installed.\nYou need to install the selinux-policy-sandbox package in order to run this command")) if self.__options.setype: