From patchwork Thu Sep 22 15:17:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Zaman X-Patchwork-Id: 9345521 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 8BDFC6077A for ; Thu, 22 Sep 2016 15:20:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791142AB8E for ; Thu, 22 Sep 2016 15:20:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BE132ABA9; Thu, 22 Sep 2016 15:20:04 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) (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 68E6B2AB8E for ; Thu, 22 Sep 2016 15:20:01 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.30,378,1470700800"; d="scan'208";a="19469728" IronPort-PHdr: =?us-ascii?q?9a23=3AltFo8R9v3XO3EP9uRHKM819IXTAuvvDOBiVQ1KB9?= =?us-ascii?q?1+0cTK2v8tzYMVDF4r011RmSDN+ds64P27eempujcFRI2YyGvnEGfc4EfD4+ou?= =?us-ascii?q?JSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47AblHf6ke/8SQVUk2mc1Ek?= =?us-ascii?q?fKKtRsWC0oye7KObw9XreQJGhT6wM/tZDS6dikHvjPQQmpZoMa0ryxHE8TNicu?= =?us-ascii?q?VSwn50dxrIx06vrvqq+NZf1wgY+7d4r48TGZn9Kr81Sb1eESQOL3E+5MqtswLK?= =?us-ascii?q?CwSI+CgySGITxzhBGA/DpCPzW573+n/4v/F63gGCMNf4TLY1XjLk5KBuHky7wB?= =?us-ascii?q?wbPiI0pTmEwvd7i7hW9Vf4/xE=3D?= X-IPAS-Result: =?us-ascii?q?A2FlBgDJ9eNX/wHyM5BeHQEFAQsBGQYMgn0TAQEBAQEegVO?= =?us-ascii?q?6cCWBe4V0TAEBAQEBAQEBAgECWyeCMgQDEwV5Wz0CAQMBAg8oBgEBDCAMAgMJA?= =?us-ascii?q?QEXKQgIAwEtAwEFAQsRDgsFGAQBiCkBoQOBMj4yilaFMAEBBYgoCBCEF4p6EQF?= =?us-ascii?q?ohRKINIZ7RIoHj2hlgQeHaiUMhWOPIjGBEVSDC4IHZQGFO3iBJwEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 22 Sep 2016 15:19:58 +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 u8MFJeSs015394; Thu, 22 Sep 2016 11:19:42 -0400 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 u8MFI5Sv125853 for ; Thu, 22 Sep 2016 11:18:05 -0400 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 u8MFI2iD015286 for ; Thu, 22 Sep 2016 11:18:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BmAgBR9eNXesPAVdFeHAYMgyoTAQEBAQGBcbZphBOGHgKBaEwBAgEBAQEBAhMBAQkLDAgZhRECAQMSLgEBNwEPUTQBBQEcGSKIKQGhAIEyPjKKVoUwAQEFh38BAQEBAQUCARwIEIQXi3SCAAuDB4g0hntEigePaGWBB4dqMYVjjyIxgRGFZmUBh1oBAQE X-IPAS-Result: A1BmAgBR9eNXesPAVdFeHAYMgyoTAQEBAQGBcbZphBOGHgKBaEwBAgEBAQEBAhMBAQkLDAgZhRECAQMSLgEBNwEPUTQBBQEcGSKIKQGhAIEyPjKKVoUwAQEFh38BAQEBAQUCARwIEIQXi3SCAAuDB4g0hntEigePaGWBB4dqMYVjjyIxgRGFZmUBh1oBAQE X-IronPort-AV: E=Sophos;i="5.30,378,1470715200"; d="scan'208";a="5722215" 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; 22 Sep 2016 11:18:04 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AtLm/tRZLc4hQGdRStNqQSBf/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZpc+4bnLW6fgltlLVR4KTs6sC0LuM9fi8Ejxdqb+681k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZv?= =?us-ascii?q?IaytQ8iJ3p7xj7z5q8CbSj4LrQL1Wal1IhSyoFeZnegtqqwmFJwMzADUqGBDYe?= =?us-ascii?q?VcyDAgD1uSmxHh+pX4p8Y7oGwD884motVNVaT8YrQQUa1TDDNgNXs8osLsq0rt?= =?us-ascii?q?VwyKs1kVSWIQ2ihBBgHDpEX4V4z2tAPiu/Bz2S+bOsuwRrcxD2fxp5x3QQPl3X?= =?us-ascii?q?9UfwUy93va35R9?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0EyBABR9eNXesPAVdFeHAYMGwYMgn0TA?= =?us-ascii?q?QEBAQGBcbZphBOCFIQKAoFoTAEBAQEBAQEBAgECEAEBCQsMCBkvgjIYgQBbPQI?= =?us-ascii?q?BAxIuAQE3AQ9RNAEFARwZIogpAaEAgTI+MopWhTABAQWHfwEBAQEBBQIBHAgQh?= =?us-ascii?q?BeLdIIAC4MHiDSGe0SKB49oZYEHh2oxhWOPIjGBEYVmZQGHWgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0EyBABR9eNXesPAVdFeHAYMGwYMgn0TAQEBAQGBcbZphBO?= =?us-ascii?q?CFIQKAoFoTAEBAQEBAQEBAgECEAEBCQsMCBkvgjIYgQBbPQIBAxIuAQE3AQ9RN?= =?us-ascii?q?AEFARwZIogpAaEAgTI+MopWhTABAQWHfwEBAQEBBQIBHAgQhBeLdIIAC4MHiDS?= =?us-ascii?q?Ge0SKB49oZYEHh2oxhWOPIjGBEYVmZQGHWgEBAQ?= X-IronPort-AV: E=Sophos;i="5.30,378,1470700800"; d="scan'208";a="17864359" Received: from mail-pf0-f195.google.com ([209.85.192.195]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/AES128-GCM-SHA256; 22 Sep 2016 15:18:03 +0000 Received: by mail-pf0-f195.google.com with SMTP id q2so3941290pfj.0 for ; Thu, 22 Sep 2016 08:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tYCLDGCc68IhMrgpcaE4wHmkFgD3+g5A49IxErXPwz0=; b=wbIdNxc5HfarHJ7Fp3O1Vmvo/FMiLLMqRMVOhQwI70Sps3NYoaEdWY6ZdpVN6CsiNf Sh0ZoE1qA3oHcAzCJOO+v4vcUIka2W/eDN1q0iV1V65bk+6Rx8AZotEtsTHF9wfrK2iU bEkw9LK7q5yyafYaFqinz141VQ84xFKcJOjp3Fe2RslUR5qLWFuMbFAVC6sanXpLQSpd IaTE9Y9CaHHWvKv7rdHzt9y8Xs01zkgnjPQq4Wsw59K08vznpGg5Odj0PC9/6d8ek8hB GX438LloWWHMrSOo0hQzrSEz8J1fupzzMGzu8tripJYJ65Xy4qjlUs59mAdtWmXBNyGT psXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tYCLDGCc68IhMrgpcaE4wHmkFgD3+g5A49IxErXPwz0=; b=mmgrvJwFNf0osFGakaIXkkN7GOuLCeauCl4TklkPhUob/5KxOkwvnHbOL2I6nxKqPp znoy2/ixU5vuQiV47UcKnQ8yG9QPI7Qq70quRnSwuYiiLaC5Vr8/J3tttDHG9BxkKzHE tTemaKpjlMer7vqcQpZUrZusX3ZMdXPLRYIQcTdu6I+ch1mFYQ+Tvdy50a52zORfZGiF rGaUl7Zd9UuUFKvMYHQWvhN9qd0KHjTiipUG9unAHZK5HJ7nnOx70u+nOnyWjkp3DJi0 50iPQKwqQpfuipbmfMycmApmqV/x5un+b1hV2aoq8eyPREAoG0FLjnaBeTjinI+IDVfy labg== X-Gm-Message-State: AE9vXwMr0aiYt7YAP9M4nbDAR0Otf+Xe6lZcBLLto6VwvrsESbWmVC/D7VzdYY9ozN6M9g== X-Received: by 10.98.33.146 with SMTP id o18mr4064390pfj.177.1474557482801; Thu, 22 Sep 2016 08:18:02 -0700 (PDT) Received: from localhost ([2404:e800:e600:57b:e014:183:951f:342c]) by smtp.gmail.com with ESMTPSA id w15sm4926684pfi.68.2016.09.22.08.18.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 08:18:02 -0700 (PDT) From: Jason Zaman To: selinux@tycho.nsa.gov Subject: [PATCH 2/7] sepolicy: initialize setools4 Date: Thu, 22 Sep 2016 23:17:28 +0800 Message-Id: <1474557453-14379-3-git-send-email-jason@perfinion.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1474557453-14379-1-git-send-email-jason@perfinion.com> References: <1474557453-14379-1-git-send-email-jason@perfinion.com> 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 Signed-off-by: Jason Zaman --- policycoreutils/sepolicy/sepolicy/__init__.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/policycoreutils/sepolicy/sepolicy/__init__.py b/policycoreutils/sepolicy/sepolicy/__init__.py index 4d9d6ad..f24750a 100644 --- a/policycoreutils/sepolicy/sepolicy/__init__.py +++ b/policycoreutils/sepolicy/sepolicy/__init__.py @@ -2,9 +2,11 @@ # Author: Dan Walsh # Author: Ryan Hallisey +# Author: Jason Zaman from . import _policy import selinux +import setools import glob import sepolgen.defaults as defaults import sepolgen.interfaces as interfaces @@ -31,13 +33,13 @@ except: import __builtin__ __builtin__.__dict__['_'] = unicode -TYPE = _policy.TYPE -ROLE = _policy.ROLE -ATTRIBUTE = _policy.ATTRIBUTE -PORT = _policy.PORT -USER = _policy.USER -BOOLEAN = _policy.BOOLEAN -TCLASS = _policy.CLASS +TYPE = 1 +ROLE = 2 +ATTRIBUTE = 3 +PORT = 4 +USER = 5 +BOOLEAN = 6 +TCLASS = 7 ALLOW = 'allow' AUDITALLOW = 'auditallow' @@ -88,6 +90,9 @@ trans_file_type_str["-s"] = "s" trans_file_type_str["-l"] = "l" trans_file_type_str["-p"] = "p" +# the setools policy handle +_pol = None + # cache the lookup results file_equiv_modified = None file_equiv = None @@ -145,6 +150,7 @@ def policy(policy_file): try: _policy.policy(policy_file) + _pol = setools.SELinuxPolicy(policy_file) except: raise ValueError(_("Failed to read %s policy file") % policy_file)