/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: 2011-12-31 23:00:36 UTC
  • Revision ID: teddy@recompile.se-20111231230036-dokyri4qljllv7ro
* mandos: Break some long lines.
  (ClientDBus.Timeout_dbus_property): If changed, only reschedule
                                      timeout if enabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
475
475
            # Reformat values from string types to Python types
476
476
            client["approved_by_default"] = config.getboolean(
477
477
                client_name, "approved_by_default")
478
 
            client["enabled"] = config.getboolean(client_name, "enabled")
 
478
            client["enabled"] = config.getboolean(client_name,
 
479
                                                  "enabled")
479
480
            
480
481
            client["fingerprint"] = (section["fingerprint"].upper()
481
482
                                     .replace(" ", ""))
529
530
        # comparison purposes with return value from the fingerprint()
530
531
        # function
531
532
        logger.debug("  Fingerprint: %s", self.fingerprint)
532
 
        self.created = settings.get("created", datetime.datetime.utcnow())
 
533
        self.created = settings.get("created",
 
534
                                    datetime.datetime.utcnow())
533
535
 
534
536
        # attributes specific for this server instance
535
537
        self.checker = None
1365
1367
        if value is None:       # get
1366
1368
            return dbus.UInt64(self.timeout_milliseconds())
1367
1369
        self.timeout = datetime.timedelta(0, 0, 0, value)
1368
 
        if getattr(self, "disable_initiator_tag", None) is None:
1369
 
            return
1370
1370
        # Reschedule timeout
1371
 
        gobject.source_remove(self.disable_initiator_tag)
1372
 
        self.disable_initiator_tag = None
1373
 
        self.expires = None
1374
 
        time_to_die = timedelta_to_milliseconds((self
1375
 
                                                 .last_checked_ok
1376
 
                                                 + self.timeout)
1377
 
                                                - datetime.datetime
1378
 
                                                .utcnow())
1379
 
        if time_to_die <= 0:
1380
 
            # The timeout has passed
1381
 
            self.disable()
1382
 
        else:
1383
 
            self.expires = (datetime.datetime.utcnow()
1384
 
                            + datetime.timedelta(milliseconds =
1385
 
                                                 time_to_die))
1386
 
            self.disable_initiator_tag = (gobject.timeout_add
1387
 
                                          (time_to_die, self.disable))
 
1371
        if self.enabled:
 
1372
            now = datetime.datetime.utcnow()
 
1373
            time_to_die = timedelta_to_milliseconds(
 
1374
                (self.last_checked_ok + self.timeout) - now)
 
1375
            if time_to_die <= 0:
 
1376
                # The timeout has passed
 
1377
                self.disable()
 
1378
            else:
 
1379
                self.expires = (now +
 
1380
                                datetime.timedelta(milliseconds =
 
1381
                                                   time_to_die))
 
1382
                if (getattr(self, "disable_initiator_tag", None)
 
1383
                    is None):
 
1384
                    return
 
1385
                gobject.source_remove(self.disable_initiator_tag)
 
1386
                self.disable_initiator_tag = (gobject.timeout_add
 
1387
                                              (time_to_die,
 
1388
                                               self.disable))
1388
1389
    
1389
1390
    # ExtendedTimeout - property
1390
1391
    @dbus_service_property(_interface, signature="t",
2101
2102
                                % server_settings["servicename"]))
2102
2103
    
2103
2104
    # Parse config file with clients
2104
 
    client_config = configparser.SafeConfigParser(Client.client_defaults)
 
2105
    client_config = configparser.SafeConfigParser(Client
 
2106
                                                  .client_defaults)
2105
2107
    client_config.read(os.path.join(server_settings["configdir"],
2106
2108
                                    "clients.conf"))
2107
2109
    
2286
2288
 
2287
2289
    
2288
2290
    # Add/remove clients based on new changes made to config
2289
 
    for client_name in set(old_client_settings) - set(client_settings):
 
2291
    for client_name in (set(old_client_settings)
 
2292
                        - set(client_settings)):
2290
2293
        del clients_data[client_name]
2291
 
    for client_name in set(client_settings) - set(old_client_settings):
 
2294
    for client_name in (set(client_settings)
 
2295
                        - set(old_client_settings)):
2292
2296
        clients_data[client_name] = client_settings[client_name]
2293
2297
 
2294
2298
    # Create clients all clients