/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: Teddy Hogeborn
  • Date: 2015-08-10 07:34:37 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 325.
  • Revision ID: teddy@recompile.se-20150810073437-3m8jgt13nqric6vf
Revert change to D-Bus API.

The D-Bus API signal CheckerCompleted is documented to provide a
wait(2) status value.  Since the server switched to using subprocess
to run checkers, it no longer has access to a wait(2) status value.  A
previous change to work around this made the D-Bus API incompatible.
Revert this change by constructing a fake wait(2) status value; this
keeps the D-Bus API stable.

* DBUS-API (CheckerCompleted): Revert incompatible change.
* mandos (ClientDBus.checker_callback): Construct fake wait(2) status.
* mandos-monitor (MandosClientWidget.checker_completed): Revert to
                                                         using
                                                         original API
                                                         with wait(2)
                                                         condition
                                                         value.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
4
4
# Mandos Monitor - Control and monitor the Mandos server
5
5
6
 
# Copyright © 2009-2014 Teddy Hogeborn
7
 
# Copyright © 2009-2014 Björn Påhlsson
 
6
# Copyright © 2009-2015 Teddy Hogeborn
 
7
# Copyright © 2009-2015 Björn Påhlsson
8
8
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
60
60
domain = 'se.recompile'
61
61
server_interface = domain + '.Mandos'
62
62
client_interface = domain + '.Mandos.Client'
63
 
version = "1.6.7"
 
63
version = "1.6.9"
64
64
 
65
65
def isoformat_to_datetime(iso):
66
66
    "Parse an ISO 8601 date string to a datetime.datetime()"
87
87
        self.proxy = proxy_object # Mandos Client proxy object
88
88
        self.properties = dict() if properties is None else properties
89
89
        self.property_changed_match = (
90
 
            self.proxy.connect_to_signal("PropertyChanged",
91
 
                                         self._property_changed,
92
 
                                         client_interface,
 
90
            self.proxy.connect_to_signal("PropertiesChanged",
 
91
                                         self.properties_changed,
 
92
                                         dbus.PROPERTIES_IFACE,
93
93
                                         byte_arrays=True))
94
94
        
95
95
        if properties is None:
100
100
        
101
101
        super(MandosClientPropertyCache, self).__init__(**kwargs)
102
102
    
103
 
    def _property_changed(self, property, value):
104
 
        """Helper which takes positional arguments"""
105
 
        return self.property_changed(property=property, value=value)
106
 
    
107
 
    def property_changed(self, property=None, value=None):
108
 
        """This is called whenever we get a PropertyChanged signal
109
 
        It updates the changed property in the "properties" dict.
 
103
    def properties_changed(self, interface, properties, invalidated):
 
104
        """This is called whenever we get a PropertiesChanged signal
 
105
        It updates the changed properties in the "properties" dict.
110
106
        """
111
107
        # Update properties dict with new value
112
 
        self.properties[property] = value
 
108
        self.properties.update(properties)
113
109
    
114
110
    def delete(self):
115
111
        self.property_changed_match.remove()
195
191
                        ' killed by signal {}'
196
192
                        .format(self.properties["Name"], command,
197
193
                                os.WTERMSIG(condition)))
198
 
        elif os.WCOREDUMP(condition):
199
 
            self.logger('Checker for client {} (command "{}") dumped'
200
 
                        ' core'.format(self.properties["Name"],
201
 
                                       command))
202
 
        else:
203
 
            self.logger('Checker for client {} completed'
204
 
                        ' mysteriously'
205
 
                        .format(self.properties["Name"]))
206
194
        self.update()
207
195
    
208
196
    def checker_started(self, command):
341
329
        """Handle keys.
342
330
        This overrides the method from urwid.FlowWidget"""
343
331
        if key == "+":
344
 
            self.proxy.Enable(dbus_interface = client_interface,
345
 
                              ignore_reply=True)
 
332
            self.proxy.Set(client_interface, "Enabled",
 
333
                           dbus.Boolean(True), ignore_reply = True,
 
334
                           dbus_interface = dbus.PROPERTIES_IFACE)
346
335
        elif key == "-":
347
 
            self.proxy.Disable(dbus_interface = client_interface,
348
 
                               ignore_reply=True)
 
336
            self.proxy.Set(client_interface, "Enabled", False,
 
337
                           ignore_reply = True,
 
338
                           dbus_interface = dbus.PROPERTIES_IFACE)
349
339
        elif key == "a":
350
340
            self.proxy.Approve(dbus.Boolean(True, variant_level=1),
351
341
                               dbus_interface = client_interface,
359
349
                                                  .object_path,
360
350
                                                  ignore_reply=True)
361
351
        elif key == "s":
362
 
            self.proxy.StartChecker(dbus_interface = client_interface,
363
 
                                    ignore_reply=True)
 
352
            self.proxy.Set(client_interface, "CheckerRunning",
 
353
                           dbus.Boolean(True), ignore_reply = True,
 
354
                           dbus_interface = dbus.PROPERTIES_IFACE)
364
355
        elif key == "S":
365
 
            self.proxy.StopChecker(dbus_interface = client_interface,
366
 
                                   ignore_reply=True)
 
356
            self.proxy.Set(client_interface, "CheckerRunning",
 
357
                           dbus.Boolean(False), ignore_reply = True,
 
358
                           dbus_interface = dbus.PROPERTIES_IFACE)
367
359
        elif key == "C":
368
360
            self.proxy.CheckedOK(dbus_interface = client_interface,
369
361
                                 ignore_reply=True)
377
369
        else:
378
370
            return key
379
371
    
380
 
    def property_changed(self, property=None, **kwargs):
381
 
        """Call self.update() if old value is not new value.
 
372
    def properties_changed(self, interface, properties, invalidated):
 
373
        """Call self.update() if any properties changed.
382
374
        This overrides the method from MandosClientPropertyCache"""
383
 
        property_name = str(property)
384
 
        old_value = self.properties.get(property_name)
385
 
        super(MandosClientWidget, self).property_changed(
386
 
            property=property, **kwargs)
387
 
        if self.properties.get(property_name) != old_value:
 
375
        old_values = { key: self.properties.get(key)
 
376
                       for key in properties.keys() }
 
377
        super(MandosClientWidget, self).properties_changed(
 
378
            interface, properties, invalidated)
 
379
        if any(old_values[key] != self.properties.get(key)
 
380
               for key in old_values):
388
381
            self.update()
389
382
 
390
383