4
4
# Mandos Monitor - Control and monitor the Mandos server
 
6
 
# Copyright © 2008-2010 Teddy Hogeborn
 
7
 
# Copyright © 2008-2010 Björn Påhlsson
 
 
6
# Copyright © 2008-2011 Teddy Hogeborn
 
 
7
# Copyright © 2008-2011 Björn Påhlsson
 
9
9
# This program is free software: you can redistribute it and/or modify
 
10
10
# it under the terms of the GNU General Public License as published by
 
 
19
19
# You should have received a copy of the GNU General Public License
 
20
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
22
 
# Contact the authors at <mandos@fukt.bsnet.se>.
 
 
22
# Contact the authors at <mandos@recompile.se>.
 
25
25
from __future__ import (division, absolute_import, print_function,
 
 
52
52
    "ApprovalDelay": "Approval Delay",
 
53
53
    "ApprovalDuration": "Approval Duration",
 
54
54
    "Checker": "Checker",
 
 
55
    "ExtendedTimeout" : "Extended Timeout"
 
56
57
defaultkeywords = ("Name", "Enabled", "Timeout", "LastCheckedOK")
 
57
 
domain = "se.bsnet.fukt"
 
 
58
domain = "se.recompile"
 
58
59
busname = domain + ".Mandos"
 
60
61
server_interface = domain + ".Mandos"
 
61
62
client_interface = domain + ".Mandos.Client"
 
64
65
def timedelta_to_milliseconds(td):
 
65
66
    """Convert a datetime.timedelta object to milliseconds"""
 
 
150
151
                options.checker is not None,
 
151
152
                options.timeout is not None,
 
 
153
                options.extended_timeout is not None,
 
152
154
                options.interval is not None,
 
153
155
                options.approved_by_default is not None,
 
154
156
                options.approval_delay is not None,
 
 
185
187
                        help="Set checker command for client")
 
186
188
    parser.add_argument("-t", "--timeout",
 
187
189
                        help="Set timeout for client")
 
 
190
    parser.add_argument("--extended-timeout",
 
 
191
                        help="Set extended timeout for client")
 
188
192
    parser.add_argument("-i", "--interval",
 
189
193
                        help="Set checker interval for client")
 
190
194
    parser.add_argument("--approve-by-default", action="store_true",
 
 
270
274
                        "LastEnabled", "ApprovalPending",
 
271
275
                        "ApprovedByDefault",
 
272
276
                        "LastApprovalRequest", "ApprovalDelay",
 
273
 
                        "ApprovalDuration", "Checker")
 
 
277
                        "ApprovalDuration", "Checker",
 
275
280
            keywords = defaultkeywords
 
 
297
302
                                         dbus.PROPERTIES_IFACE)
 
 
304
            if options.checker is not None:
 
300
305
                client.Set(client_interface, "Checker",
 
302
307
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
 
308
            if options.host is not None:
 
304
309
                client.Set(client_interface, "Host", options.host,
 
305
310
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
 
311
            if options.interval is not None:
 
307
312
                client.Set(client_interface, "Interval",
 
308
313
                           timedelta_to_milliseconds
 
309
314
                           (string_to_delta(options.interval)),
 
310
315
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
311
 
            if options.approval_delay:
 
 
316
            if options.approval_delay is not None:
 
312
317
                client.Set(client_interface, "ApprovalDelay",
 
313
318
                           timedelta_to_milliseconds
 
314
319
                           (string_to_delta(options.
 
315
320
                                            approval_delay)),
 
316
321
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
317
 
            if options.approval_duration:
 
 
322
            if options.approval_duration is not None:
 
318
323
                client.Set(client_interface, "ApprovalDuration",
 
319
324
                           timedelta_to_milliseconds
 
320
325
                           (string_to_delta(options.
 
321
326
                                            approval_duration)),
 
322
327
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
 
328
            if options.timeout is not None:
 
324
329
                client.Set(client_interface, "Timeout",
 
325
330
                           timedelta_to_milliseconds
 
326
331
                           (string_to_delta(options.timeout)),
 
327
332
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
 
333
            if options.extended_timeout is not None:
 
 
334
                client.Set(client_interface, "ExtendedTimeout",
 
 
335
                           timedelta_to_milliseconds
 
 
336
                           (string_to_delta(options.extended_timeout)),
 
 
337
                           dbus_interface=dbus.PROPERTIES_IFACE)
 
 
338
            if options.secret is not None:
 
329
339
                client.Set(client_interface, "Secret",
 
330
340
                           dbus.ByteArray(open(options.secret,