From patchwork Fri Apr 24 14:59:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11508049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83E7B1575 for ; Fri, 24 Apr 2020 15:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56F9C2075A for ; Fri, 24 Apr 2020 15:00:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iyczyRR5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgDXPAC (ORCPT ); Fri, 24 Apr 2020 11:00:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48630 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726698AbgDXPAB (ORCPT ); Fri, 24 Apr 2020 11:00:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587740400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QsvBuJwLQJPmIsoNh+Io/aBqZwx7NQPXeB6r8rMwETI=; b=iyczyRR5WkiTcUfMuZo68WBo/c7p04qFkpAWQ0203bX0Upzw644HGOtTczq4tB5Khhct74 q5vQFHGaaZ7nz9aFciMe+UwmVMUQimZIm0sycAk7Gx21Wjr+iIUqE8IfjFem8xeQU2oxiS bhoSVTa7Nr4R8TKtwkJi3xloCd0ZA8k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-lN4WRPNXNxulv6vRgYI4JQ-1; Fri, 24 Apr 2020 10:59:48 -0400 X-MC-Unique: lN4WRPNXNxulv6vRgYI4JQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D0768018A4 for ; Fri, 24 Apr 2020 14:59:47 +0000 (UTC) Received: from workstation.redhat.com (unknown [10.40.195.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6570A600E8; Fri, 24 Apr 2020 14:59:46 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH] python/semanage: Use ipaddress module instead of IPy Date: Fri, 24 Apr 2020 16:59:41 +0200 Message-Id: <20200424145941.242949-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org ipaddress python module was added to standard library in Python 3.3 - https://docs.python.org/3/library/ipaddress.html seobject.py was the only consumer of IPy module so this dependency is not needed anymore. Signed-off-by: Petr Lautrbach --- python/semanage/seobject.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py index f2a139c970bd..c89c67e491b6 100644 --- a/python/semanage/seobject.py +++ b/python/semanage/seobject.py @@ -32,7 +32,7 @@ from semanage import * PROGNAME = "policycoreutils" import sepolicy import setools -from IPy import IP +import ipaddress try: import gettext @@ -1860,13 +1860,13 @@ class nodeRecords(semanageRecords): # verify valid combination if len(mask) == 0 or mask[0] == "/": - i = IP(addr + mask) - newaddr = i.strNormal(0) - newmask = str(i.netmask()) - if newmask == "0.0.0.0" and i.version() == 6: + i = ipaddress.ip_network(addr + mask) + newaddr = str(i.network_address) + newmask = str(i.netmask) + if newmask == "0.0.0.0" and i.version == 6: newmask = "::" - protocol = "ipv%d" % i.version() + protocol = "ipv%d" % i.version try: newprotocol = self.protocol.index(protocol)