From b300d3d43aecfd008c46e17693cf5e19d7f2ba0e Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mon, 30 Nov 2015 14:57:47 +0100 Subject: [PATCH] policycoreutils: fix 'semanage permissive -l' subcommand 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 ed48c110..74899551 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):