/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: 2010-09-12 02:51:19 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100912025119-7vvpqofpnbxf7i22
Rename all D-Bus properties to conform to D-Bus naming conventions;
all programs changed.

Also rename client setting "approved_delay" to "approval_delay", and
"approved_duration" to "approval_duration"; all programs changed.

* mandos (ClientDBus.NeedApproval): Bug fix: send an UInt64, not a
                                    float.
  (ClientDBus.ApprovedByDefault_dbus_property,
  ClientDBus.ApprovalDelay_dbus_property,
  ClientDBus.ApprovalDuration_dbus_property): Bug fix: send
                                              PropertyChanged signal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
locale.setlocale(locale.LC_ALL, u'')
13
13
 
14
14
tablewords = {
15
 
    'name': u'Name',
16
 
    'enabled': u'Enabled',
17
 
    'timeout': u'Timeout',
18
 
    'last_checked_ok': u'Last Successful Check',
19
 
    'created': u'Created',
20
 
    'interval': u'Interval',
21
 
    'host': u'Host',
22
 
    'fingerprint': u'Fingerprint',
23
 
    'checker_running': u'Check Is Running',
24
 
    'last_enabled': u'Last Enabled',
25
 
    'checker': u'Checker',
 
15
    'Name': u'Name',
 
16
    'Enabled': u'Enabled',
 
17
    'Timeout': u'Timeout',
 
18
    'LastCheckedOK': u'Last Successful Check',
 
19
    'Created': u'Created',
 
20
    'Interval': u'Interval',
 
21
    'Host': u'Host',
 
22
    'Fingerprint': u'Fingerprint',
 
23
    'CheckerRunning': u'Check Is Running',
 
24
    'LastEnabled': u'Last Enabled',
 
25
    'Checker': u'Checker',
26
26
    }
27
 
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok')
 
27
defaultkeywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK')
28
28
domain = 'se.bsnet.fukt'
29
29
busname = domain + '.Mandos'
30
30
server_path = '/'
108
108
    # Create format string to print table rows
109
109
    format_string = u' '.join(u'%%-%ds' %
110
110
                              max(len(tablewords[key]),
111
 
                                  max(len(valuetostring(client[key], key))
 
111
                                  max(len(valuetostring(client[key],
 
112
                                                        key))
112
113
                                      for client in
113
114
                                      clients))
114
115
                              for key in keywords)
166
167
if not clients and mandos_clients.values():
167
168
    keywords = defaultkeywords
168
169
    if options.all:
169
 
        keywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
170
 
                    'created', 'interval', 'host', 'fingerprint',
171
 
                    'checker_running', 'last_enabled', 'checker')
 
170
        keywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK',
 
171
                    'Created', 'Interval', 'Host', 'Fingerprint',
 
172
                    'CheckerRunning', 'LastEnabled', 'Checker')
172
173
    print_clients(mandos_clients.values())
173
174
 
174
175
# Process each client in the list by all selected options
187
188
        client.StopChecker(dbus_interface=client_interface)
188
189
    if options.is_enabled:
189
190
        sys.exit(0 if client.Get(client_interface,
190
 
                                 u"enabled",
 
191
                                 u"Enabled",
191
192
                                 dbus_interface=dbus.PROPERTIES_IFACE)
192
193
                 else 1)
193
194
    if options.checker:
194
 
        client.Set(client_interface, u"checker", options.checker,
 
195
        client.Set(client_interface, u"Checker", options.checker,
195
196
                   dbus_interface=dbus.PROPERTIES_IFACE)
196
197
    if options.host:
197
 
        client.Set(client_interface, u"host", options.host,
 
198
        client.Set(client_interface, u"Host", options.host,
198
199
                   dbus_interface=dbus.PROPERTIES_IFACE)
199
200
    if options.interval:
200
 
        client.Set(client_interface, u"interval",
 
201
        client.Set(client_interface, u"Interval",
201
202
                   timedelta_to_milliseconds
202
203
                   (string_to_delta(options.interval)),
203
204
                   dbus_interface=dbus.PROPERTIES_IFACE)
204
205
    if options.timeout:
205
 
        client.Set(client_interface, u"timeout",
 
206
        client.Set(client_interface, u"Timeout",
206
207
                   timedelta_to_milliseconds(string_to_delta
207
208
                                             (options.timeout)),
208
209
                   dbus_interface=dbus.PROPERTIES_IFACE)
209
210
    if options.secret:
210
 
        client.Set(client_interface, u"secret",
 
211
        client.Set(client_interface, u"Secret",
211
212
                   dbus.ByteArray(open(options.secret, u'rb').read()),
212
213
                   dbus_interface=dbus.PROPERTIES_IFACE)
213
214
    if options.approve:
214
 
        client.Approve(dbus.Boolean(True), dbus_interface=client_interface)
 
215
        client.Approve(dbus.Boolean(True),
 
216
                       dbus_interface=client_interface)
215
217
    if options.deny:
216
 
        client.Approve(dbus.Boolean(False), dbus_interface=client_interface)
 
218
        client.Approve(dbus.Boolean(False),
 
219
                       dbus_interface=client_interface)