policycoreutils: improve sepolicy command line interface
PATCH 1/1 policycoreutils: improve sepolicy command line interface
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 <module>
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'
--- policycoreutils/sepolicy/sepolicy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
policycoreutils/sepolicy/sepolicy.py +5 -2
@@ -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:
Signature · 1 line
2.6.2
James Carter
AppliedQuoted 5 lines · Petr Lautrbach
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.
Quoted 7 lines
Fixes:
Traceback (most recent call last):File "/usr/bin/sepolicy", line 647, in <module> args.func(args)AttributeError: 'Namespace' object has no attribute 'func'
Signed-off-by Petr Lautrbach <[email protected]>
Applied.
Thanks,
Jim
Quoted 24 lines
--- policycoreutils/sepolicy/sepolicy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)policycoreutils/sepolicy/sepolicy.py +5
-2@@ -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:
Signature · 2 lines
James Carter <[email protected]> National Security Agency