/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-11-26 23:08:17 UTC
  • mto: (518.1.8 mandos-persistent)
  • mto: This revision was merged to the branch mainline in revision 524.
  • Revision ID: teddy@recompile.se-20111126230817-tv08v831s2yltbkd
Make "enabled" a client config option.

* DBUS-API: Fix wording on "Expires" option.
* clients.conf (enabled): New.
* mandos (Client): "last_enabled" can now be None.
  (Client.__init__): Get "enabled" from config.  Only set
                     "last_enabled" and "expires" if enabled.
  (ClientDBus.Created_dbus_property): Removed redundant dbus.String().
  (ClientDBus.Interval_dbus_property): If changed, only reschedule
                                       checker if enabled.
  (main/special_settings): Added "enabled".
* mandos-clients.conf (OPTIONS): Added "enabled".

Show diffs side-by-side

added added

removed removed

Lines of Context:
415
415
    last_checker_status: integer between 0 and 255 reflecting exit
416
416
                         status of last checker. -1 reflects crashed
417
417
                         checker, or None.
418
 
    last_enabled: datetime.datetime(); (UTC)
 
418
    last_enabled: datetime.datetime(); (UTC) or None
419
419
    name:       string; from the config file, used in log messages and
420
420
                        D-Bus identifiers
421
421
    secret:     bytestring; sent verbatim (over TLS) to client
473
473
                            % self.name)
474
474
        self.host = config.get("host", "")
475
475
        self.created = datetime.datetime.utcnow()
476
 
        self.enabled = True
 
476
        self.enabled = config.get("enabled", True)
477
477
        self.last_approval_request = None
478
 
        self.last_enabled = datetime.datetime.utcnow()
 
478
        if self.enabled:
 
479
            self.last_enabled = datetime.datetime.utcnow()
 
480
        else:
 
481
            self.last_enabled = None
479
482
        self.last_checked_ok = None
480
483
        self.last_checker_status = None
481
484
        self.timeout = string_to_delta(config["timeout"])
485
488
        self.checker = None
486
489
        self.checker_initiator_tag = None
487
490
        self.disable_initiator_tag = None
488
 
        self.expires = datetime.datetime.utcnow() + self.timeout
 
491
        if self.enabled:
 
492
            self.expires = datetime.datetime.utcnow() + self.timeout
 
493
        else:
 
494
            self.expires = None
489
495
        self.checker_callback_tag = None
490
496
        self.checker_command = config["checker"]
491
497
        self.current_checker_command = None
1278
1284
    # Created - property
1279
1285
    @dbus_service_property(_interface, signature="s", access="read")
1280
1286
    def Created_dbus_property(self):
1281
 
        return dbus.String(datetime_to_dbus(self.created))
 
1287
        return datetime_to_dbus(self.created)
1282
1288
    
1283
1289
    # LastEnabled - property
1284
1290
    @dbus_service_property(_interface, signature="s", access="read")
1360
1366
        self.interval = datetime.timedelta(0, 0, 0, value)
1361
1367
        if getattr(self, "checker_initiator_tag", None) is None:
1362
1368
            return
1363
 
        # Reschedule checker run
1364
 
        gobject.source_remove(self.checker_initiator_tag)
1365
 
        self.checker_initiator_tag = (gobject.timeout_add
1366
 
                                      (value, self.start_checker))
1367
 
        self.start_checker()    # Start one now, too
 
1369
        if self.enabled:
 
1370
            # Reschedule checker run
 
1371
            gobject.source_remove(self.checker_initiator_tag)
 
1372
            self.checker_initiator_tag = (gobject.timeout_add
 
1373
                                          (value, self.start_checker))
 
1374
            self.start_checker()    # Start one now, too
1368
1375
    
1369
1376
    # Checker - property
1370
1377
    @dbus_service_property(_interface, signature="s",
2177
2184
        "approved_by_default":
2178
2185
            lambda section:
2179
2186
            client_config.getboolean(section, "approved_by_default"),
 
2187
        "enabled":
 
2188
            lambda section:
 
2189
            client_config.getboolean(section, "enabled"),
2180
2190
        }
2181
2191
    # Construct a new dict of client settings of this form:
2182
2192
    # { client_name: {setting_name: value, ...}, ...}