/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-monitor

  • Committer: Teddy Hogeborn
  • Date: 2009-12-25 23:13:47 UTC
  • Revision ID: teddy@fukt.bsnet.se-20091225231347-gg9u9ru0wj0f24hh
More consistent terminology: Clients are no longer "invalid" - they
are "disabled".  All code and documentation changed to reflect this.

D=Bus API change: The "properties" argument was removed from the
"ClientAdded" signal on interface "se.bsnet.fukt.Mandos".  All code in
both "mandos" and "mandos-monitor" changed to reflect this.

* mandos: Replaced "with closing(F)" with simply "with F" in all
          places where F is a file object.
  (Client.still_valid): Removed.  All callers changed to look at
                        "Client.enabled" instead.
  (dbus_service_property): Check for unsupported signatures with the
                           "byte_arrays" option.
  (DBusObjectWithProperties.Set): - '' -
  (ClientHandler.handle): Use the reverse pipe to receive the
                          "Client.enabled" attribute instead of the
                          now-removed "Client.still_valid()" method.
  (ForkingMixInWithPipe): Renamed to "ForkingMixInWithPipes" (all
                          users changed).  Now also create a reverse
                          pipe for sending data to the child process.
  (ForkingMixInWithPipes.add_pipe): Now takes two pipe fd's as
                                    arguments.  All callers changed.
  (IPv6_TCPServer.handle_ipc): Take an additional "reply_fd" argument
                               (all callers changed).  Close the reply
                               pipe when the child data pipe is
                               closed.  New "GETATTR" IPC method; will
                               pickle client attribute and send it
                               over the reply pipe FD.
  (MandosDBusService.ClientAdded): Removed "properties" argument.  All
                                   emitters changed.
* mandos-clients.conf.xml (DESCRIPTION, OPTIONS): Use
                                                  "enabled/disabled"
                                                  terminology.
* mandos-ctl: Option "--is-valid" renamed to "--is-enabled".
* mandos-monitor: Enable user locale.  Try to log exceptions.
  (MandosClientPropertyCache.__init__): Removed "properties" argument.
                                        All callers changed.
  (UserInterface.add_new_client): Remove "properties" argument.  All
                                  callers changed.  Supply "logger"
                                  argument to MandosClientWidget().
  (UserInterface.add_client): New "logger" argument.  All callers
                              changed.
* mandos.xml (BUGS, SECURITY/CLIENTS): Use "enabled/disabled"
                                       terminology.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import UserList
21
21
 
 
22
import locale
 
23
 
 
24
locale.setlocale(locale.LC_ALL, u'')
 
25
 
22
26
# Some useful constants
23
27
domain = 'se.bsnet.fukt'
24
28
server_interface = domain + '.Mandos'
38
42
    properties and calls a hook function when any of them are
39
43
    changed.
40
44
    """
41
 
    def __init__(self, proxy_object=None, properties=None, *args,
42
 
                 **kwargs):
 
45
    def __init__(self, proxy_object=None, *args, **kwargs):
43
46
        self.proxy = proxy_object # Mandos Client proxy object
44
47
        
45
 
        if properties is None:
46
 
            self.properties = dict()
47
 
        else:
48
 
            self.properties = properties
 
48
        self.properties = dict()
49
49
        self.proxy.connect_to_signal(u"PropertyChanged",
50
50
                                     self.property_changed,
51
51
                                     client_interface,
52
52
                                     byte_arrays=True)
53
 
        
54
 
        if properties is None:
55
 
            self.properties.update(self.proxy.GetAll(client_interface,
56
 
                                                     dbus_interface =
57
 
                                                     dbus.PROPERTIES_IFACE))
 
53
 
 
54
        self.properties.update(
 
55
            self.proxy.GetAll(client_interface,
 
56
                              dbus_interface = dbus.PROPERTIES_IFACE))
58
57
        super(MandosClientPropertyCache, self).__init__(
59
 
            proxy_object=proxy_object,
60
 
            properties=properties, *args, **kwargs)
 
58
            proxy_object=proxy_object, *args, **kwargs)
61
59
    
62
60
    def property_changed(self, property=None, value=None):
63
61
        """This is called whenever we get a PropertyChanged signal
424
422
            return
425
423
        self.remove_client(client, path)
426
424
    
427
 
    def add_new_client(self, path, properties):
 
425
    def add_new_client(self, path):
428
426
        client_proxy_object = self.bus.get_object(self.busname, path)
429
427
        self.add_client(MandosClientWidget(server_proxy_object
430
428
                                           =self.mandos_serv,
431
429
                                           proxy_object
432
430
                                           =client_proxy_object,
433
 
                                           properties=properties,
434
431
                                           update_hook
435
432
                                           =self.refresh,
436
433
                                           delete_hook
437
 
                                           =self.remove_client),
 
434
                                           =self.remove_client,
 
435
                                           logger
 
436
                                           =self.log_message),
438
437
                        path=path)
439
438
    
440
439
    def add_client(self, client, path=None):
562
561
ui = UserInterface()
563
562
try:
564
563
    ui.run()
565
 
except:
 
564
except Exception, e:
 
565
    ui.log_message(unicode(e))
566
566
    ui.screen.stop()
567
567
    raise