From patchwork Wed Nov 2 15:24:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Bigonville X-Patchwork-Id: 9409351 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 6FAA1601C2 for ; Wed, 2 Nov 2016 15:25:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60D9D2A31C for ; Wed, 2 Nov 2016 15:25:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54DA62A31E; Wed, 2 Nov 2016 15:25:35 +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 (emsm-gh1-uea10.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 C47322A31C for ; Wed, 2 Nov 2016 15:25:33 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.31,583,1473120000"; d="scan'208";a="533054" IronPort-PHdr: =?us-ascii?q?9a23=3AMvf40Bfmifa1/qCHGWJKTM+AlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc6/ZR7h7PlgxGXEQZ/co6odzbGH6eawAiddud6oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3Dwdp?= =?us-ascii?q?POO9QteU1JXtkbDpsMCLKyxzxxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP?= =?us-ascii?q?5Xz247bXianhL7+9vitMU7q3cYhuglv/Jkfe26Ov1gDO8QMDNzKG0x5cv2pTHf?= =?us-ascii?q?XACP4T0aSWxQnR1WUCbf6xSvep7sqCb8qqJX2SadO9P3SbQ5EWCo7qhsTjfkhS?= =?us-ascii?q?0GPjh/93vY3J8jxJlHqQ6s8kQsi7XfZ5uYYb8nJq4=3D?= X-IPAS-Result: =?us-ascii?q?A2GYIACCBBpY/wHyM5BdHQEFAQsBGAEFAQsBgwEBAQEBAR+?= =?us-ascii?q?BVKMMCQEBBpdgJoF6hi5TAQEBAQEBAQECAQJfKIIzBAMTBXlbQwI3BgEBDCAMA?= =?us-ascii?q?gMJAhcIHwIICAMBLQsKHwsFGASINQQBrDWFMAEBBYhCHQiFcok5EQFohRSITpF?= =?us-ascii?q?UkC8LigyFewKRGgJUZ4MZDB+BVHGGMHiBNAEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 02 Nov 2016 15:25:18 +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 uA2FOiRB006272; Wed, 2 Nov 2016 11:24:51 -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 uA2FOfxT064925 for ; Wed, 2 Nov 2016 11:24:41 -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 uA2FOf5N006270 for ; Wed, 2 Nov 2016 11:24:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DzDgA0BBpY/2OteVtdHQEFAQsBgywBAQEBAR+BVKMMCwaTU4QuiC1TAQIBAQEBAQJiKEISAYRTAQE4Lx9ONIhaAaw1hTABAQWIXwiFcoozhRSITpFUkC8LkAcCkRoCVGeCVgw3DB+BVHGDcoRqAQEB X-IPAS-Result: A1DzDgA0BBpY/2OteVtdHQEFAQsBgywBAQEBAR+BVKMMCwaTU4QuiC1TAQIBAQEBAQJiKEISAYRTAQE4Lx9ONIhaAaw1hTABAQWIXwiFcoozhRSITpFUkC8LkAcCkRoCVGeCVgw3DB+BVHGDcoRqAQEB X-IronPort-AV: E=Sophos;i="5.31,583,1473134400"; d="scan'208";a="5800859" 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; 02 Nov 2016 11:24:39 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AUXw7vh/bLoV9DP9uRHKM819IXTAuvvDOBiVQ1KB9?= =?us-ascii?q?0OwcTK2v8tzYMVDF4r011RmSDN+du6kP1rKempujcFRI2YyGvnEGfc4EfD4+ou?= =?us-ascii?q?JSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47AblHf6ke/8SQVUk2mc1Ek?= =?us-ascii?q?fKKlQcWP14ye7KObw9XreQJGhT6wM/tZDS6dikHvjPQQmpZoMa0ryxHE8TNicu?= =?us-ascii?q?VSwn50dxrIx06vrpT4wJk26ClUuvQ85+ZcQK76eOI+VrUeAzM4YE4v48i+kRDe?= =?us-ascii?q?VwaJ+jM2U2oRlARJBwzIpEXwX5j2tAP2u+B80S/cOtf5G+NnEQ++5rtmHUe7wB?= =?us-ascii?q?wMMCQ0pTna?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HjOgCCBBpY/2OteVtdHQEFAQsBGAEFA?= =?us-ascii?q?QsBgwEBAQEBAR+BD0WjDAkBAQaTU4QugX+GLlMBAQEBAQEBAQIBAl8oQhIBgV4?= =?us-ascii?q?YgQBbgQIBATgvH040iFoBrDWFMAEBBYhfCIVyijOFFIhOkVSQLwuQBwKRGgJUZ?= =?us-ascii?q?4JWDDcMH4FUcYNyhGoBAQE?= X-IPAS-Result: =?us-ascii?q?A0HjOgCCBBpY/2OteVtdHQEFAQsBGAEFAQsBgwEBAQEBAR+?= =?us-ascii?q?BD0WjDAkBAQaTU4QugX+GLlMBAQEBAQEBAQIBAl8oQhIBgV4YgQBbgQIBATgvH?= =?us-ascii?q?040iFoBrDWFMAEBBYhfCIVyijOFFIhOkVSQLwuQBwKRGgJUZ4JWDDcMH4FUcYN?= =?us-ascii?q?yhGoBAQE?= X-IronPort-AV: E=Sophos;i="5.31,583,1473120000"; d="scan'208";a="533003" Received: from anor.bigon.be ([91.121.173.99]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2016 15:24:37 +0000 Received: from anor.bigon.be (localhost.localdomain [127.0.0.1]) by anor.bigon.be (Postfix) with ESMTP id AA7D81A1A8 for ; Wed, 2 Nov 2016 16:24:34 +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=1478100272; x=1479914673; bh=cqont wfatTSVbfJYzttvXk6dLDG6USgGtdjnF/rYlhI=; b=hMFKTqsdVbFwyZDxIObOc eM+lqWwlYuWUNFoY8Vo8DPsbXXoTXmuaEnWzPtH2b5wQWtwzytgoPev3B/OPuuKz gCx2g7ptWjx1tu4Bz1IjXUPP2eQdzifytc807eTE9cQ64Bpgv82P9rdpfFKKDuXz rEWGw8kavBfW2FXaYt7wvg= 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 FqjN4HXjxo2n for ; Wed, 2 Nov 2016 16:24:32 +0100 (CET) Received: from valinor.bigon.be (d54c71dba.static.telenet.be [84.199.29.186]) (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 746271A06E for ; Wed, 2 Nov 2016 16:24:32 +0100 (CET) Received: from bigon (uid 1000) (envelope-from bigon@bigon.be) id 5fa71 by valinor.bigon.be (DragonFly Mail Agent v0.11); Wed, 02 Nov 2016 16:24:31 +0100 From: Laurent Bigonville To: selinux@tycho.nsa.gov Subject: [PATCH] Revert "libselinux: support new python3 functions" Date: Wed, 2 Nov 2016 16:24:31 +0100 Message-Id: <20161102152431.30464-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 With the reverted commit applied, some functions were returning arrays of bytes instead of python strings under python3 this was causing issues with string manipulation functions like split(). Swig (checked with 3.0.7) is adding compatibility macros that take care of the differences between python2 and python3. This reverts commit 63df0f7ef12844b9b86cc293299671da772fcf84. Signed-off-by: Laurent Bigonville --- libselinux/src/selinuxswig_python.i | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i index 8cea18d..43df291 100644 --- a/libselinux/src/selinuxswig_python.i +++ b/libselinux/src/selinuxswig_python.i @@ -64,7 +64,7 @@ def install(src, dest): PyObject* list = PyList_New(*$2); int i; for (i = 0; i < *$2; i++) { - PyList_SetItem(list, i, PyBytes_FromString((*$1)[i])); + PyList_SetItem(list, i, PyString_FromString((*$1)[i])); } $result = SWIG_Python_AppendOutput($result, list); } @@ -97,9 +97,7 @@ def install(src, dest): len++; plist = PyList_New(len); for (i = 0; i < len; i++) { - PyList_SetItem(plist, i, - PyBytes_FromString((*$1)[i]) - ); + PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); } } else { plist = PyList_New(0); @@ -116,9 +114,7 @@ def install(src, dest): if (*$1) { plist = PyList_New(result); for (i = 0; i < result; i++) { - PyList_SetItem(plist, i, - PyBytes_FromString((*$1)[i]) - ); + PyList_SetItem(plist, i, PyString_FromString((*$1)[i])); } } else { plist = PyList_New(0); @@ -171,20 +167,16 @@ def install(src, dest): $1 = (char**) malloc(size + 1); for(i = 0; i < size; i++) { - if (!PyBytes_Check(PySequence_GetItem($input, i))) { - PyErr_SetString(PyExc_ValueError, "Sequence must contain only bytes"); - + if (!PyString_Check(PySequence_GetItem($input, i))) { + PyErr_SetString(PyExc_ValueError, "Sequence must contain only strings"); return NULL; } - } for(i = 0; i < size; i++) { s = PySequence_GetItem($input, i); - - $1[i] = (char*) malloc(PyBytes_Size(s) + 1); - strcpy($1[i], PyBytes_AsString(s)); - + $1[i] = (char*) malloc(PyString_Size(s) + 1); + strcpy($1[i], PyString_AsString(s)); } $1[size] = NULL; }