/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2015-08-10 19:10:26 UTC
  • mfrom: (237.7.335 trunk)
  • Revision ID: teddy@recompile.se-20150810191026-0jss9yy8t6o6pl39
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
version = "1.6.9"
76
76
 
77
77
 
 
78
try:
 
79
    dbus.OBJECT_MANAGER_IFACE
 
80
except AttributeError:
 
81
    dbus.OBJECT_MANAGER_IFACE = "org.freedesktop.DBus.ObjectManager"
 
82
 
78
83
def milliseconds_to_string(ms):
79
84
    td = datetime.timedelta(0, 0, 0, ms)
80
85
    return ("{days}{hours:02}:{minutes:02}:{seconds:02}".format(
341
346
    
342
347
    mandos_serv = dbus.Interface(mandos_dbus_objc,
343
348
                                 dbus_interface = server_interface)
 
349
    mandos_serv_object_manager = dbus.Interface(
 
350
        mandos_dbus_objc, dbus_interface = dbus.OBJECT_MANAGER_IFACE)
344
351
    
345
352
    #block stderr since dbus library prints to stderr
346
353
    null = os.open(os.path.devnull, os.O_RDWR)
349
356
    os.close(null)
350
357
    try:
351
358
        try:
352
 
            mandos_clients = mandos_serv.GetAllClientsWithProperties()
 
359
            mandos_clients = { path: ifs_and_props[client_interface]
 
360
                               for path, ifs_and_props in
 
361
                               mandos_serv_object_manager
 
362
                               .GetManagedObjects().items()
 
363
                               if client_interface in ifs_and_props }
353
364
        finally:
354
365
            #restore stderr
355
366
            os.dup2(stderrcopy, sys.stderr.fileno())
356
367
            os.close(stderrcopy)
357
 
    except dbus.exceptions.DBusException:
358
 
        print("Access denied: Accessing mandos server through dbus.",
359
 
              file=sys.stderr)
 
368
    except dbus.exceptions.DBusException as e:
 
369
        print("Access denied: Accessing mandos server through D-Bus: {}"
 
370
              .format(e), file=sys.stderr)
360
371
        sys.exit(1)
361
372
    
362
373
    # Compile dict of (clients: properties) to process