From patchwork Mon Nov 16 21:10:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 7630791 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ACF3CBF90C for ; Mon, 16 Nov 2015 21:14:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DF62205AA for ; Mon, 16 Nov 2015 21:14:17 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [63.239.67.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A50D2053D for ; Mon, 16 Nov 2015 21:14:16 +0000 (UTC) X-TM-IMSS-Message-ID: <2dfd74460004942f@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([63.239.67.10]) with ESMTP (TREND IMSS SMTP Service 7.1) id 2dfd74460004942f ; Mon, 16 Nov 2015 16:13:45 -0500 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 tAGLB6ZV023326; Mon, 16 Nov 2015 16:11:20 -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 tAGLB2Rn004223 for ; Mon, 16 Nov 2015 16:11:02 -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 tAGLB2ia023324 for ; Mon, 16 Nov 2015 16:11:02 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BIAABeREpWnBy3hNFdGQQPAQEBAYNeb684AY0NhA0ZhXeBSUwBAQEBAQESAQEBAQEICwkJIYVigR4ziC67NYZUiiWEEgWWSIUdiAqCJIxDjV6CLQFcgV5xhQoBAQE X-IPAS-Result: A1BIAABeREpWnBy3hNFdGQQPAQEBAYNeb684AY0NhA0ZhXeBSUwBAQEBAQESAQEBAQEICwkJIYVigR4ziC67NYZUiiWEEgWWSIUdiAqCJIxDjV6CLQFcgV5xhQoBAQE X-IronPort-AV: E=Sophos;i="5.20,304,1444708800"; d="scan'208";a="4937365" Received: from emvm-gh1-uea08.nsa.gov ([63.239.67.9]) by goalie.tycho.ncsc.mil with ESMTP; 16 Nov 2015 16:10:53 -0500 X-TM-IMSS-Message-ID: <2e02d5980004bb2e@nsa.gov> Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by nsa.gov ([63.239.67.9]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 ADH-AES256-SHA (256/256)) id 2e02d5980004bb2e ; Mon, 16 Nov 2015 16:10:52 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 324B41308 for ; Mon, 16 Nov 2015 21:10:51 +0000 (UTC) Received: from hulk.com (ovpn-204-19.brq.redhat.com [10.40.204.19]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAGLAnYY005921; Mon, 16 Nov 2015 16:10:50 -0500 From: Petr Lautrbach To: selinux@tycho.nsa.gov Subject: [PATCH] policycoreutils: improve sepolicy command line interface Date: Mon, 16 Nov 2015 22:10:43 +0100 Message-Id: <1447708243-11610-1-git-send-email-plautrba@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-TM-AS-MML: disable 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-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, when sepolicy was run without any argument, the usage message with the error "too few arguments" was shown. Using Python 3 it threw a traceback. This patch unifies behavior on Py2 and Py3 so that sepolicy shows the help message in this case. Fixes: Traceback (most recent call last): File "/usr/bin/sepolicy", line 647, in args.func(args) AttributeError: 'Namespace' object has no attribute 'func' Signed-off-by: Petr Lautrbach --- policycoreutils/sepolicy/sepolicy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/policycoreutils/sepolicy/sepolicy.py b/policycoreutils/sepolicy/sepolicy.py index 08a5c2f..7d57f6e 100755 --- a/policycoreutils/sepolicy/sepolicy.py +++ b/policycoreutils/sepolicy/sepolicy.py @@ -685,9 +685,12 @@ if __name__ == '__main__': try: if os.path.basename(sys.argv[0]) == "sepolgen": - args = parser.parse_args(["generate"] + sys.argv[1:]) + parser_args = [ "generate" ] + sys.argv[1:] + elif len(sys.argv) > 1: + parser_args = sys.argv[1:] else: - args = parser.parse_args() + parser_args = ["-h"] + args = parser.parse_args(args=parser_args) args.func(args) sys.exit(0) except ValueError, e: