/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2016-03-19 03:48:56 UTC
  • Revision ID: teddy@recompile.se-20160319034856-d8rox0kdxekgr03g
Server: Make persistent state directory mode u=rwx,go=

The Makefile target "install-server" creates the server persistent
state directory /var/lib/mandos as mode u=rwx,go= (0700).  Make this
also the case for the Debian package (unless overridden by
dpkg-statoverride).

* debian/mandos.postinst (configure): Fix state directory permissions,
  but only if not listed by "dpkg-statoverride".

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
import os
40
40
import collections
41
41
import doctest
42
 
import json
43
42
 
44
43
import dbus
45
44
 
65
64
    "ApprovalDelay": "Approval Delay",
66
65
    "ApprovalDuration": "Approval Duration",
67
66
    "Checker": "Checker",
68
 
    "ExtendedTimeout": "Extended Timeout",
69
 
    "Expires": "Expires",
70
 
    "LastCheckerStatus": "Last Checker Status",
 
67
    "ExtendedTimeout": "Extended Timeout"
71
68
}
72
69
defaultkeywords = ("Name", "Enabled", "Timeout", "LastCheckedOK")
73
70
domain = "se.recompile"
75
72
server_path = "/"
76
73
server_interface = domain + ".Mandos"
77
74
client_interface = domain + ".Mandos.Client"
78
 
version = "1.7.10"
 
75
version = "1.7.6"
79
76
 
80
77
 
81
78
try:
283
280
                        help="Select all clients")
284
281
    parser.add_argument("-v", "--verbose", action="store_true",
285
282
                        help="Print all fields")
286
 
    parser.add_argument("-j", "--dump-json", action="store_true",
287
 
                        help="Dump client data in JSON format")
288
283
    parser.add_argument("-e", "--enable", action="store_true",
289
284
                        help="Enable client")
290
285
    parser.add_argument("-d", "--disable", action="store_true",
333
328
    if has_actions(options) and not (options.client or options.all):
334
329
        parser.error("Options require clients names or --all.")
335
330
    if options.verbose and has_actions(options):
336
 
        parser.error("--verbose can only be used alone.")
337
 
    if options.dump_json and (options.verbose or has_actions(options)):
338
 
        parser.error("--dump-json can only be used alone.")
 
331
        parser.error("--verbose can only be used alone or with"
 
332
                     " --all.")
339
333
    if options.all and not has_actions(options):
340
334
        parser.error("--all requires an action.")
341
 
    
 
335
 
342
336
    if options.check:
343
337
        fail_count, test_count = doctest.testmod()
344
338
        sys.exit(os.EX_OK if fail_count == 0 else 1)
395
389
                sys.exit(1)
396
390
    
397
391
    if not has_actions(options) and clients:
398
 
        if options.verbose or options.dump_json:
 
392
        if options.verbose:
399
393
            keywords = ("Name", "Enabled", "Timeout", "LastCheckedOK",
400
394
                        "Created", "Interval", "Host", "Fingerprint",
401
395
                        "CheckerRunning", "LastEnabled",
402
396
                        "ApprovalPending", "ApprovedByDefault",
403
397
                        "LastApprovalRequest", "ApprovalDelay",
404
398
                        "ApprovalDuration", "Checker",
405
 
                        "ExtendedTimeout", "Expires",
406
 
                        "LastCheckerStatus")
 
399
                        "ExtendedTimeout")
407
400
        else:
408
401
            keywords = defaultkeywords
409
402
        
410
 
        if options.dump_json:
411
 
            json.dump({client["Name"]: {key:
412
 
                                        bool(client[key])
413
 
                                        if isinstance(client[key],
414
 
                                                      dbus.Boolean)
415
 
                                        else client[key]
416
 
                                        for key in keywords }
417
 
                       for client in clients.values() },
418
 
                      fp = sys.stdout, indent = 4,
419
 
                      separators = (',', ': '))
420
 
            print()
421
 
        else:
422
 
            print_clients(clients.values(), keywords)
 
403
        print_clients(clients.values(), keywords)
423
404
    else:
424
405
        # Process each client in the list by all selected options
425
406
        for client in clients: