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