All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@tycho.nsa.gov
Subject: [PATCH] policycoreutils: fix 'semanage permissive -l' subcommand
Date: Mon, 30 Nov 2015 14:57:47 +0100	[thread overview]
Message-ID: <1448891867-10905-1-git-send-email-plautrba@redhat.com> (raw)

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 <plautrba@redhat.com>
---
 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):
-- 
2.6.3

             reply	other threads:[~2015-11-30 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30 13:57 Petr Lautrbach [this message]
2015-12-01 20:38 ` [PATCH] policycoreutils: fix 'semanage permissive -l' subcommand Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448891867-10905-1-git-send-email-plautrba@redhat.com \
    --to=plautrba@redhat.com \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.