/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

  • Committer: Teddy Hogeborn
  • Date: 2009-01-19 13:13:47 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090119131347-buuzm5lbv9ba8oqc
* mandos (Client.__init__): Disable D-Bus during init to avoid
                            emitting any D-Bus signals before the
                            object is initialized.  Do the
                            dbus.service.Object initialization last.
  (Client): Changed D-Bus interface name to
            "se.bsnet.fukt.Mandos.Client".
  (main): Changed D-Bus bus name to "se.bsnet.fukt.Mandos".
  (main/MandosServer): Changed D-Bus object path to "/", and changed
                       interface name to "se.bsnet.fukt.Mandos".
                       Removed methods "RemoveClientByName" and
                       "Quit".

Show diffs side-by-side

added added

removed removed

Lines of Context:
226
226
        if config is None:
227
227
            config = {}
228
228
        logger.debug(u"Creating client %r", self.name)
229
 
        self.use_dbus = use_dbus
230
 
        if self.use_dbus:
231
 
            self.dbus_object_path = (dbus.ObjectPath
232
 
                                     ("/Mandos/clients/"
233
 
                                      + self.name.replace(".", "_")))
234
 
            dbus.service.Object.__init__(self, bus,
235
 
                                         self.dbus_object_path)
 
229
        self.use_dbus = False   # During __init__
236
230
        # Uppercase and remove spaces from fingerprint for later
237
231
        # comparison purposes with return value from the fingerprint()
238
232
        # function
262
256
        self.disable_initiator_tag = None
263
257
        self.checker_callback_tag = None
264
258
        self.checker_command = config["checker"]
 
259
        self.last_connect = None
 
260
        # Only now, when this client is initialized, can it show up on
 
261
        # the D-Bus
 
262
        self.use_dbus = use_dbus
 
263
        if self.use_dbus:
 
264
            self.dbus_object_path = (dbus.ObjectPath
 
265
                                     ("/clients/"
 
266
                                      + self.name.replace(".", "_")))
 
267
            dbus.service.Object.__init__(self, bus,
 
268
                                         self.dbus_object_path)
265
269
    
266
270
    def enable(self):
267
271
        """Start this client's checker and timeout hooks"""
449
453
            return now < (self.last_checked_ok + self.timeout)
450
454
    
451
455
    ## D-Bus methods & signals
452
 
    _interface = u"org.mandos_system.Mandos.Client"
 
456
    _interface = u"se.bsnet.fukt.Mandos.Client"
453
457
    
454
458
    # BumpTimeout - method
455
459
    BumpTimeout = dbus.service.method(_interface)(bump_timeout)
1035
1039
                            avahi.DBUS_INTERFACE_SERVER)
1036
1040
    # End of Avahi example code
1037
1041
    if use_dbus:
1038
 
        bus_name = dbus.service.BusName(u"org.mandos-system.Mandos",
1039
 
                                        bus)
 
1042
        bus_name = dbus.service.BusName(u"se.bsnet.fukt.Mandos", bus)
1040
1043
    
1041
1044
    clients.update(Set(Client(name = section,
1042
1045
                              config
1096
1099
        class MandosServer(dbus.service.Object):
1097
1100
            """A D-Bus proxy object"""
1098
1101
            def __init__(self):
1099
 
                dbus.service.Object.__init__(self, bus,
1100
 
                                             "/Mandos")
1101
 
            _interface = u"org.mandos_system.Mandos"
 
1102
                dbus.service.Object.__init__(self, bus, "/")
 
1103
            _interface = u"se.bsnet.fukt.Mandos"
1102
1104
            
1103
1105
            @dbus.service.signal(_interface, signature="oa{sv}")
1104
1106
            def ClientAdded(self, objpath, properties):
1134
1136
                        return
1135
1137
                raise KeyError
1136
1138
            
1137
 
            @dbus.service.method(_interface, in_signature="s")
1138
 
            def RemoveClientByName(self, name):
1139
 
                for c in clients:
1140
 
                    if c.name == name:
1141
 
                        clients.remove(c)
1142
 
                        # Don't signal anything except ClientRemoved
1143
 
                        c.use_dbus = False
1144
 
                        c.disable()
1145
 
                        # Emit D-Bus signal
1146
 
                        self.ClientRemoved(c.dbus_object_path, name)
1147
 
                        return
1148
 
                raise KeyError
1149
 
            
1150
 
            @dbus.service.method(_interface)
1151
 
            def Quit(self):
1152
 
                main_loop.quit()
1153
 
            
1154
1139
            del _interface
1155
1140
        
1156
1141
        mandos_server = MandosServer()