283
280
# Process each client in the list by all selected options
284
281
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)))
295
282
if options.remove:
296
283
mandos_serv.RemoveClient(client.__dbus_object_path__)
297
284
if options.enable:
298
set_client_prop("Enabled", dbus.Boolean(True))
285
client.Set(client_interface, "Enabled",
287
dbus_interface=dbus.PROPERTIES_IFACE)
299
288
if options.disable:
300
set_client_prop("Enabled", dbus.Boolean(False))
289
client.Set(client_interface, "Enabled",
291
dbus_interface=dbus.PROPERTIES_IFACE)
301
292
if options.bump_timeout:
302
set_client_prop("LastCheckedOK", "")
293
client.Set(client_interface, "LastCheckedOK", "",
294
dbus_interface=dbus.PROPERTIES_IFACE)
303
295
if options.start_checker:
304
set_client_prop("CheckerRunning", dbus.Boolean(True))
296
client.Set(client_interface, "CheckerRunning",
298
dbus_interface=dbus.PROPERTIES_IFACE)
305
299
if options.stop_checker:
306
set_client_prop("CheckerRunning", dbus.Boolean(False))
300
client.Set(client_interface, "CheckerRunning",
302
dbus_interface=dbus.PROPERTIES_IFACE)
307
303
if options.is_enabled:
308
304
sys.exit(0 if client.Get(client_interface,
311
307
dbus.PROPERTIES_IFACE)
313
309
if options.checker is not None:
314
set_client_prop("Checker", options.checker)
310
client.Set(client_interface, "Checker",
312
dbus_interface=dbus.PROPERTIES_IFACE)
315
313
if options.host is not None:
316
set_client_prop("Host", options.host)
314
client.Set(client_interface, "Host", options.host,
315
dbus_interface=dbus.PROPERTIES_IFACE)
317
316
if options.interval is not None:
318
set_client_prop_ms("Interval", options.interval)
317
client.Set(client_interface, "Interval",
318
timedelta_to_milliseconds
319
(string_to_delta(options.interval)),
320
dbus_interface=dbus.PROPERTIES_IFACE)
319
321
if options.approval_delay is not None:
320
set_client_prop_ms("ApprovalDelay",
321
options.approval_delay)
322
client.Set(client_interface, "ApprovalDelay",
323
timedelta_to_milliseconds
324
(string_to_delta(options.
326
dbus_interface=dbus.PROPERTIES_IFACE)
322
327
if options.approval_duration is not None:
323
set_client_prop_ms("ApprovalDuration",
324
options.approval_duration)
328
client.Set(client_interface, "ApprovalDuration",
329
timedelta_to_milliseconds
330
(string_to_delta(options.
332
dbus_interface=dbus.PROPERTIES_IFACE)
325
333
if options.timeout is not None:
326
set_client_prop_ms("Timeout", options.timeout)
334
client.Set(client_interface, "Timeout",
335
timedelta_to_milliseconds
336
(string_to_delta(options.timeout)),
337
dbus_interface=dbus.PROPERTIES_IFACE)
327
338
if options.extended_timeout is not None:
328
set_client_prop_ms("ExtendedTimeout",
329
options.extended_timeout)
339
client.Set(client_interface, "ExtendedTimeout",
340
timedelta_to_milliseconds
341
(string_to_delta(options.extended_timeout)),
342
dbus_interface=dbus.PROPERTIES_IFACE)
330
343
if options.secret is not None:
331
set_client_prop("Secret",
332
dbus.ByteArray(options.secret.read()))
344
client.Set(client_interface, "Secret",
345
dbus.ByteArray(options.secret.read()),
346
dbus_interface=dbus.PROPERTIES_IFACE)
333
347
if options.approved_by_default is not None:
334
set_client_prop("ApprovedByDefault",
336
.approved_by_default))
348
client.Set(client_interface, "ApprovedByDefault",
350
.approved_by_default),
351
dbus_interface=dbus.PROPERTIES_IFACE)
337
352
if options.approve:
338
353
client.Approve(dbus.Boolean(True),
339
354
dbus_interface=client_interface)