From patchwork Mon Nov 30 13:57:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 7725881 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 10A0CBEEE1 for ; Mon, 30 Nov 2015 14:02:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61BF220524 for ; Mon, 30 Nov 2015 14:02:23 +0000 (UTC) Received: from emvm-gh1-uea08.nsa.gov (emvm-gh1-uea08.nsa.gov [63.239.67.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38CA520520 for ; Mon, 30 Nov 2015 14:02:22 +0000 (UTC) X-TM-IMSS-Message-ID: <18ac3ec500020eef@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1) id 18ac3ec500020eef ; Mon, 30 Nov 2015 09:00:11 -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 tAUDwFi1016134; Mon, 30 Nov 2015 08:58:32 -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 tAUDwBfP114634 for ; Mon, 30 Nov 2015 08:58:11 -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 tAUDw8vq016125 for ; Mon, 30 Nov 2015 08:58:11 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BfAACTVFxWnBy3hNFeGQEBAg8BAQKEJyaudwGNHIQOhg+BfQEBAQEBARIBAQEBAQgLCQkhhWKBHjOILroehlSGUINVhBIFlleNOI5sjXWCLV2BXj00hXEBAQE X-IPAS-Result: A1BfAACTVFxWnBy3hNFeGQEBAg8BAQKEJyaudwGNHIQOhg+BfQEBAQEBARIBAQEBAQgLCQkhhWKBHjOILroehlSGUINVhBIFlleNOI5sjXWCLV2BXj00hXEBAQE X-IronPort-AV: E=Sophos;i="5.20,364,1444708800"; d="scan'208";a="4976498" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 30 Nov 2015 08:57:56 -0500 X-TM-IMSS-Message-ID: <18aa5f5f00020e4b@nsa.gov> Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 ADH-AES256-SHA (256/256)) id 18aa5f5f00020e4b ; Mon, 30 Nov 2015 08:58:08 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 021CF552E7 for ; Mon, 30 Nov 2015 13:57:53 +0000 (UTC) Received: from hulk.com (dhcp-10-40-3-171.brq.redhat.com [10.40.3.171]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAUDvqDf004802; Mon, 30 Nov 2015 08:57:53 -0500 From: Petr Lautrbach To: selinux@tycho.nsa.gov Subject: [PATCH] policycoreutils: fix 'semanage permissive -l' subcommand Date: Mon, 30 Nov 2015 14:57:47 +0100 Message-Id: <1448891867-10905-1-git-send-email-plautrba@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 This reverts the commit 97d06737 which introduced a regression on '-l' which started to require at least one argument and fixes the original problem other way. A args.parser value is set now and handlePermissive function uses it to print an usage message when args.type is not set. Fixes: semanage permissive -l usage: semanage permissive [-h] (-a | -d | -l) [-n] [-N] [-S STORE] type [type ...] semanage permissive: error: the following arguments are required: type Signed-off-by: Petr Lautrbach --- policycoreutils/semanage/semanage | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/policycoreutils/semanage/semanage b/policycoreutils/semanage/semanage index ed48c11..7489955 100644 --- a/policycoreutils/semanage/semanage +++ b/policycoreutils/semanage/semanage @@ -700,12 +700,17 @@ def handlePermissive(args): OBJECT = object_dict['permissive']() OBJECT.set_reload(args.noreload) - if args.action is "add": - OBJECT.add(args.type) if args.action is "list": OBJECT.list(args.noheading) - if args.action is "delete": - OBJECT.delete(args.type) + elif args.type != None: + if args.action is "add": + OBJECT.add(args.type) + if args.action is "delete": + OBJECT.delete(args.type) + else: + args.parser.print_usage(sys.stderr) + sys.stderr.write(_('semanage permissive: error: the following argument is required: type\n')) + sys.exit(1) def setupPermissiveParser(subparsers): @@ -721,8 +726,9 @@ def setupPermissiveParser(subparsers): parser_add_noheading(permissiveParser, "permissive") parser_add_noreload(permissiveParser, "permissive") parser_add_store(permissiveParser, "permissive") - permissiveParser.add_argument('type', nargs='+', default=None, help=_('type')) + permissiveParser.add_argument('type', nargs='?', default=None, help=_('type')) permissiveParser.set_defaults(func=handlePermissive) + permissiveParser.set_defaults(parser=permissiveParser) def handleDontaudit(args):