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.Enable(dbus_interface=client_interface)
299
286
if options.disable:
300
set_client_prop("Enabled", dbus.Boolean(False))
287
client.Disable(dbus_interface=client_interface)
301
288
if options.bump_timeout:
302
set_client_prop("LastCheckedOK", "")
289
client.CheckedOK(dbus_interface=client_interface)
303
290
if options.start_checker:
304
set_client_prop("CheckerRunning", dbus.Boolean(True))
291
client.StartChecker(dbus_interface=client_interface)
305
292
if options.stop_checker:
306
set_client_prop("CheckerRunning", dbus.Boolean(False))
293
client.StopChecker(dbus_interface=client_interface)
307
294
if options.is_enabled:
308
295
sys.exit(0 if client.Get(client_interface,
311
298
dbus.PROPERTIES_IFACE)
313
300
if options.checker is not None:
314
set_client_prop("Checker", options.checker)
301
client.Set(client_interface, "Checker",
303
dbus_interface=dbus.PROPERTIES_IFACE)
315
304
if options.host is not None:
316
set_client_prop("Host", options.host)
305
client.Set(client_interface, "Host", options.host,
306
dbus_interface=dbus.PROPERTIES_IFACE)
317
307
if options.interval is not None:
318
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)
319
312
if options.approval_delay is not None:
320
set_client_prop_ms("ApprovalDelay",
321
options.approval_delay)
313
client.Set(client_interface, "ApprovalDelay",
314
timedelta_to_milliseconds
315
(string_to_delta(options.
317
dbus_interface=dbus.PROPERTIES_IFACE)
322
318
if options.approval_duration is not None:
323
set_client_prop_ms("ApprovalDuration",
324
options.approval_duration)
319
client.Set(client_interface, "ApprovalDuration",
320
timedelta_to_milliseconds
321
(string_to_delta(options.
323
dbus_interface=dbus.PROPERTIES_IFACE)
325
324
if options.timeout is not None:
326
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)
327
329
if options.extended_timeout is not None:
328
set_client_prop_ms("ExtendedTimeout",
329
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)
330
334
if options.secret is not None:
331
set_client_prop("Secret",
332
dbus.ByteArray(options.secret.read()))
335
client.Set(client_interface, "Secret",
336
dbus.ByteArray(options.secret.read()),
337
dbus_interface=dbus.PROPERTIES_IFACE)
333
338
if options.approved_by_default is not None:
334
set_client_prop("ApprovedByDefault",
336
.approved_by_default))
339
client.Set(client_interface, "ApprovedByDefault",
341
.approved_by_default),
342
dbus_interface=dbus.PROPERTIES_IFACE)
337
343
if options.approve:
338
344
client.Approve(dbus.Boolean(True),
339
345
dbus_interface=client_interface)