/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: 2012-05-03 20:16:22 UTC
  • Revision ID: teddy@recompile.se-20120503201622-d9yezi9t17i00lio
* mandos-ctl: Use new string format method.  Bug fix: --version now
              shows the program name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
279
279
    else:
280
280
        # Process each client in the list by all selected options
281
281
        for client in clients:
282
 
            def set_client_prop(prop, value):
283
 
                """Set a Client D-Bus property"""
284
 
                client.Set(client_interface, prop, value,
285
 
                           dbus_interface=dbus.PROPERTIES_IFACE)
286
 
            def set_client_prop_ms(prop, value):
287
 
                """Set a Client D-Bus property, converted
288
 
                from a string to milliseconds."""
289
 
                set_client_prop(prop,
290
 
                                timedelta_to_milliseconds
291
 
                                (string_to_delta(value)))
292
282
            if options.remove:
293
283
                mandos_serv.RemoveClient(client.__dbus_object_path__)
294
284
            if options.enable:
295
 
                set_client_prop("Enabled", dbus.Boolean(True))
 
285
                client.Enable(dbus_interface=client_interface)
296
286
            if options.disable:
297
 
                set_client_prop("Enabled", dbus.Boolean(False))
 
287
                client.Disable(dbus_interface=client_interface)
298
288
            if options.bump_timeout:
299
 
                set_client_prop("LastCheckedOK", "")
 
289
                client.CheckedOK(dbus_interface=client_interface)
300
290
            if options.start_checker:
301
 
                set_client_prop("CheckerRunning", dbus.Boolean(True))
 
291
                client.StartChecker(dbus_interface=client_interface)
302
292
            if options.stop_checker:
303
 
                set_client_prop("CheckerRunning", dbus.Boolean(False))
 
293
                client.StopChecker(dbus_interface=client_interface)
304
294
            if options.is_enabled:
305
295
                sys.exit(0 if client.Get(client_interface,
306
296
                                         "Enabled",
308
298
                                         dbus.PROPERTIES_IFACE)
309
299
                         else 1)
310
300
            if options.checker is not None:
311
 
                set_client_prop("Checker", options.checker)
 
301
                client.Set(client_interface, "Checker",
 
302
                           options.checker,
 
303
                           dbus_interface=dbus.PROPERTIES_IFACE)
312
304
            if options.host is not None:
313
 
                set_client_prop("Host", options.host)
 
305
                client.Set(client_interface, "Host", options.host,
 
306
                           dbus_interface=dbus.PROPERTIES_IFACE)
314
307
            if options.interval is not None:
315
 
                set_client_prop_ms("Interval", options.interval)
 
308
                client.Set(client_interface, "Interval",
 
309
                           timedelta_to_milliseconds
 
310
                           (string_to_delta(options.interval)),
 
311
                           dbus_interface=dbus.PROPERTIES_IFACE)
316
312
            if options.approval_delay is not None:
317
 
                set_client_prop_ms("ApprovalDelay",
318
 
                                   options.approval_delay)
 
313
                client.Set(client_interface, "ApprovalDelay",
 
314
                           timedelta_to_milliseconds
 
315
                           (string_to_delta(options.
 
316
                                            approval_delay)),
 
317
                           dbus_interface=dbus.PROPERTIES_IFACE)
319
318
            if options.approval_duration is not None:
320
 
                set_client_prop_ms("ApprovalDuration",
321
 
                                   options.approval_duration)
 
319
                client.Set(client_interface, "ApprovalDuration",
 
320
                           timedelta_to_milliseconds
 
321
                           (string_to_delta(options.
 
322
                                            approval_duration)),
 
323
                           dbus_interface=dbus.PROPERTIES_IFACE)
322
324
            if options.timeout is not None:
323
 
                set_client_prop_ms("Timeout", options.timeout)
 
325
                client.Set(client_interface, "Timeout",
 
326
                           timedelta_to_milliseconds
 
327
                           (string_to_delta(options.timeout)),
 
328
                           dbus_interface=dbus.PROPERTIES_IFACE)
324
329
            if options.extended_timeout is not None:
325
 
                set_client_prop_ms("ExtendedTimeout",
326
 
                                   options.extended_timeout)
 
330
                client.Set(client_interface, "ExtendedTimeout",
 
331
                           timedelta_to_milliseconds
 
332
                           (string_to_delta(options.extended_timeout)),
 
333
                           dbus_interface=dbus.PROPERTIES_IFACE)
327
334
            if options.secret is not None:
328
 
                set_client_prop("Secret",
329
 
                                dbus.ByteArray(options.secret.read()))
 
335
                client.Set(client_interface, "Secret",
 
336
                           dbus.ByteArray(options.secret.read()),
 
337
                           dbus_interface=dbus.PROPERTIES_IFACE)
330
338
            if options.approved_by_default is not None:
331
 
                set_client_prop("ApprovedByDefault",
332
 
                                dbus.Boolean(options
333
 
                                             .approved_by_default))
 
339
                client.Set(client_interface, "ApprovedByDefault",
 
340
                           dbus.Boolean(options
 
341
                                        .approved_by_default),
 
342
                           dbus_interface=dbus.PROPERTIES_IFACE)
334
343
            if options.approve:
335
344
                client.Approve(dbus.Boolean(True),
336
345
                               dbus_interface=client_interface)