=== modified file 'TODO' --- TODO 2016-06-03 16:42:05 +0000 +++ TODO 2016-06-27 20:21:50 +0000 @@ -78,7 +78,6 @@ * mandos-ctl *** Handle "no D-Bus server" and/or "no Mandos server found" better -*** [#B] --dump option ** TODO Remove old string_to_delta format :2: * TODO mandos-dispatch === modified file 'mandos-ctl' --- mandos-ctl 2016-06-23 20:10:40 +0000 +++ mandos-ctl 2016-06-27 20:21:50 +0000 @@ -39,6 +39,7 @@ import os import collections import doctest +import json import dbus @@ -280,6 +281,8 @@ help="Select all clients") parser.add_argument("-v", "--verbose", action="store_true", help="Print all fields") + parser.add_argument("-j", "--dump-json", action="store_true", + help="Dump client data in JSON format") parser.add_argument("-e", "--enable", action="store_true", help="Enable client") parser.add_argument("-d", "--disable", action="store_true", @@ -328,11 +331,12 @@ if has_actions(options) and not (options.client or options.all): parser.error("Options require clients names or --all.") if options.verbose and has_actions(options): - parser.error("--verbose can only be used alone or with" - " --all.") + parser.error("--verbose can only be used alone.") + if options.dump_json and (options.verbose or has_actions(options)): + parser.error("--dump-json can only be used alone.") if options.all and not has_actions(options): parser.error("--all requires an action.") - + if options.check: fail_count, test_count = doctest.testmod() sys.exit(os.EX_OK if fail_count == 0 else 1) @@ -389,7 +393,7 @@ sys.exit(1) if not has_actions(options) and clients: - if options.verbose: + if options.verbose or options.dump_json: keywords = ("Name", "Enabled", "Timeout", "LastCheckedOK", "Created", "Interval", "Host", "Fingerprint", "CheckerRunning", "LastEnabled", @@ -400,7 +404,15 @@ else: keywords = defaultkeywords - print_clients(clients.values(), keywords) + if options.dump_json: + json.dump({client["Name"]: {key: client[key] + for key in keywords } + for client in clients.values() }, + fp = sys.stdout, indent = 4, + separators = (',', ': ')) + print() + else: + print_clients(clients.values(), keywords) else: # Process each client in the list by all selected options for client in clients: === modified file 'mandos-ctl.xml' --- mandos-ctl.xml 2016-03-05 21:42:56 +0000 +++ mandos-ctl.xml 2016-06-27 20:21:50 +0000 @@ -2,7 +2,7 @@ - + %common; ]> @@ -52,109 +52,111 @@ &COMMANDNAME; - Control the operation of the Mandos server + Control or query the operation of the Mandos server &COMMANDNAME; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -168,8 +170,11 @@ &COMMANDNAME; - - + + + + + @@ -208,9 +213,10 @@ DESCRIPTION - &COMMANDNAME; is a program to control the - operation of the Mandos server mandos8. + &COMMANDNAME; is a program to control or + query the operation of the Mandos server + mandos8. This program can be used to change client settings, approve or @@ -474,6 +480,16 @@ + + + + + Dump client settings as JSON to standard output. + + + + +