/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-04-16 22:51:36 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090416225136-wz8p0nsuteiasxn2
Code cleanup.

* mandos (ForkingMixInWithPipe.process_request): Call "self.add_pipe".
  (ForkingMixInWithPipe.handle_ipc): Removed.
  (ForkingMixInWithPipe.add_pipe): New.
  (MandosServer.add_pipe): New.

Show diffs side-by-side

added added

removed removed

Lines of Context:
312
312
    
313
313
    def enable(self):
314
314
        """Start this client's checker and timeout hooks"""
315
 
        if getattr(self, u"enabled", False):
316
 
            # Already enabled
317
 
            return
318
315
        self.last_enabled = datetime.datetime.utcnow()
319
316
        # Schedule a new checker to be started an 'interval' from now,
320
317
        # and every interval from then on.
993
990
                 gnutls_priority=None, use_dbus=True):
994
991
        self.enabled = False
995
992
        self.clients = clients
996
 
        if self.clients is None:
997
 
            self.clients = set()
998
993
        self.use_dbus = use_dbus
999
994
        self.gnutls_priority = gnutls_priority
1000
995
        IPv6_TCPServer.__init__(self, server_address,
1279
1274
    global mandos_dbus_service
1280
1275
    mandos_dbus_service = None
1281
1276
    
 
1277
    clients = set()
1282
1278
    tcp_server = MandosServer((server_settings[u"address"],
1283
1279
                               server_settings[u"port"]),
1284
1280
                              ClientHandler,
1285
1281
                              interface=server_settings[u"interface"],
1286
1282
                              use_ipv6=use_ipv6,
 
1283
                              clients=clients,
1287
1284
                              gnutls_priority=
1288
1285
                              server_settings[u"priority"],
1289
1286
                              use_dbus=use_dbus)
1346
1343
    client_class = Client
1347
1344
    if use_dbus:
1348
1345
        client_class = functools.partial(ClientDBus, bus = bus)
1349
 
    tcp_server.clients.update(set(
 
1346
    clients.update(set(
1350
1347
            client_class(name = section,
1351
1348
                         config= dict(client_config.items(section)))
1352
1349
            for section in client_config.sections()))
1353
 
    if not tcp_server.clients:
 
1350
    if not clients:
1354
1351
        logger.warning(u"No clients defined")
1355
1352
    
1356
1353
    if debug:
1382
1379
        "Cleanup function; run on exit"
1383
1380
        service.cleanup()
1384
1381
        
1385
 
        while tcp_server.clients:
1386
 
            client = tcp_server.clients.pop()
 
1382
        while clients:
 
1383
            client = clients.pop()
1387
1384
            client.disable_hook = None
1388
1385
            client.disable()
1389
1386
    
1419
1416
            @dbus.service.method(_interface, out_signature=u"ao")
1420
1417
            def GetAllClients(self):
1421
1418
                "D-Bus method"
1422
 
                return dbus.Array(c.dbus_object_path
1423
 
                                  for c in tcp_server.clients)
 
1419
                return dbus.Array(c.dbus_object_path for c in clients)
1424
1420
            
1425
1421
            @dbus.service.method(_interface,
1426
1422
                                 out_signature=u"a{oa{sv}}")
1428
1424
                "D-Bus method"
1429
1425
                return dbus.Dictionary(
1430
1426
                    ((c.dbus_object_path, c.GetAllProperties())
1431
 
                     for c in tcp_server.clients),
 
1427
                     for c in clients),
1432
1428
                    signature=u"oa{sv}")
1433
1429
            
1434
1430
            @dbus.service.method(_interface, in_signature=u"o")
1435
1431
            def RemoveClient(self, object_path):
1436
1432
                "D-Bus method"
1437
 
                for c in tcp_server.clients:
 
1433
                for c in clients:
1438
1434
                    if c.dbus_object_path == object_path:
1439
 
                        tcp_server.clients.remove(c)
 
1435
                        clients.remove(c)
1440
1436
                        c.remove_from_connection()
1441
1437
                        # Don't signal anything except ClientRemoved
1442
1438
                        c.disable(signal=False)
1449
1445
        
1450
1446
        mandos_dbus_service = MandosDBusService()
1451
1447
    
1452
 
    for client in tcp_server.clients:
 
1448
    for client in clients:
1453
1449
        if use_dbus:
1454
1450
            # Emit D-Bus signal
1455
1451
            mandos_dbus_service.ClientAdded(client.dbus_object_path,