From patchwork Thu Aug 4 18:33:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Zaman X-Patchwork-Id: 9264057 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 168A56048B for ; Thu, 4 Aug 2016 18:38:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A1AC283E4 for ; Thu, 4 Aug 2016 18:38:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2A6C2841F; Thu, 4 Aug 2016 18:38:33 +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, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from emsm-gh1-uea10.nsa.gov (smtp.nsa.gov [8.44.101.8]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54808283E4 for ; Thu, 4 Aug 2016 18:38:33 +0000 (UTC) Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 04 Aug 2016 18:38:30 +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 u74IcUuG011898; Thu, 4 Aug 2016 14:38:30 -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 u74IYW80250309 for ; Thu, 4 Aug 2016 14:34:32 -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 u74IYMKY011354 for ; Thu, 4 Aug 2016 14:34:34 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BgAQBGiqNXdMLAVdFcHQGCeoF/txCEDIYdAoFITAEBAQEBARMBCgsUF4UQAgEDEi4BATcBD0ARNAEFARwZIogPAaEUgTI+MYpUhSoBAQWLRQEBAQEGAgEcCBCED4tkgX0LgweOHHSKKY8EZYhfhXqOaTCBD4JZDRyBWWEBhyoBAQE X-IPAS-Result: A1BgAQBGiqNXdMLAVdFcHQGCeoF/txCEDIYdAoFITAEBAQEBARMBCgsUF4UQAgEDEi4BATcBD0ARNAEFARwZIogPAaEUgTI+MYpUhSoBAQWLRQEBAQEGAgEcCBCED4tkgX0LgweOHHSKKY8EZYhfhXqOaTCBD4JZDRyBWWEBhyoBAQE X-IronPort-AV: E=Sophos;i="5.28,471,1464667200"; d="scan'208";a="5626386" 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; 04 Aug 2016 14:35:22 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/AES128-GCM-SHA256; 04 Aug 2016 18:34:33 +0000 Received: by mail-pf0-f194.google.com with SMTP id y134so18686338pfg.3 for ; Thu, 04 Aug 2016 11:34:33 -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=fqQEGF7vGGFQokrkkuqzHfoOF5O1Cnozfog0SwktpAY=; b=JPx4MxX/aHC5qN7HBaj2vamqDWqKXIno2aXKmFONKCu3cBt1W3IcqoBQLIfWJZL/DQ T2i5bg+jsFUyHz+pS//JlimTAc0NHs9LbnHJp/eauNdyHtrXzvgiTM3t6Ej8+KhmuTFG uucqAk3r41My4/EOHH4B2ghDqVcXjaj3r6sV8U0FduWt9GnLtQEscT1T1AAJopdCEZqC miDXQW4GJ7sLh8ssl2yRff9ucfhNEHyg6OFiSy7bX5NpqS4/1mDxQMD43jFdDzqNayBK 98yaCdS663FQP5aLJxUckM0afK6ogXn+1TUEzwq2zblUXkIsrrv0pNltIMCgrEQE/Ixu xscg== 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=fqQEGF7vGGFQokrkkuqzHfoOF5O1Cnozfog0SwktpAY=; b=KAuMRxc2BhtPrBSyy9GsQWJ5ThFKQj87jZngjIN8appFHHdzm2cmeq+Hic0+yWgGKs vKNDq5JzpRDbsAySh3EalkeVJhzR+2ri1xYZLOMKECPcAlKx1yM5pJC1bsxwFjKJY9R9 /hcyHf6iCPyou95no8NT6fSPZv36mgmPDK5izqaSKJ0GaiGdHASfH+tlLwG5MTmvGhue b7Z7vECVYoOE09EJDyDPsC6IGgns97R+f+twcwaIMgSvlP1VS5CFaUbsox7rdkkohzun zCpRgUl6njIDTZHYPCVxxR/NVf9BpgHANkg+5dOtw+BsoIsZ7h8iDaaY2dJBd7mF9+5L W3Mw== X-Gm-Message-State: AEkoouvIh/aEq39i9Af00h/weGPsNC2EaE8XuXPPeutoXLFhfu3PLnmlRqMsYEqyWLTaZw== X-Received: by 10.98.207.6 with SMTP id b6mr128114825pfg.25.1470335672900; Thu, 04 Aug 2016 11:34:32 -0700 (PDT) Received: from localhost ([2404:e800:e600:57b:dcfa:b5a4:c9d2:f744]) by smtp.gmail.com with ESMTPSA id h86sm22068512pfh.46.2016.08.04.11.34.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 11:34:32 -0700 (PDT) From: Jason Zaman To: selinux@tycho.nsa.gov Subject: [PATCH 05/12] sepolicy: C Module init for python3 Date: Fri, 5 Aug 2016 02:33:58 +0800 Message-Id: <1470335645-24224-6-git-send-email-jason@perfinion.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1470335645-24224-1-git-send-email-jason@perfinion.com> References: <1470335645-24224-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 --- policycoreutils/sepolicy/policy.c | 29 ++++++++++++++++++++++++--- policycoreutils/sepolicy/sepolicy/__init__.py | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/policycoreutils/sepolicy/policy.c b/policycoreutils/sepolicy/policy.c index b7e3536..423a926 100644 --- a/policycoreutils/sepolicy/policy.c +++ b/policycoreutils/sepolicy/policy.c @@ -86,8 +86,31 @@ static PyMethodDef methods[] = { {NULL, NULL, 0, NULL} /* sentinel */ }; +#if PY_MAJOR_VERSION >= 3 + +static struct PyModuleDef module_def = +{ + PyModuleDef_HEAD_INIT, + "_policy", /* name of module */ + "", /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */ + (PyMethodDef*)&methods, +}; + +PyMODINIT_FUNC PyInit__policy(void) +{ + PyObject *m; + m = PyModule_Create(&module_def); + init_info(m); + return m; +} + +#else // python 2 + void init_policy(void) { -PyObject *m; -m = Py_InitModule("_policy", methods); -init_info(m); + PyObject *m; + m = Py_InitModule("_policy", methods); + init_info(m); } + +#endif diff --git a/policycoreutils/sepolicy/sepolicy/__init__.py b/policycoreutils/sepolicy/sepolicy/__init__.py index 693c6fe..7804b5c 100644 --- a/policycoreutils/sepolicy/sepolicy/__init__.py +++ b/policycoreutils/sepolicy/sepolicy/__init__.py @@ -3,7 +3,7 @@ # Author: Dan Walsh # Author: Ryan Hallisey -import _policy +from . import _policy import selinux import glob PROGNAME = "policycoreutils"