/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: 2008-08-09 01:39:09 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080809013909-n3i3ll1voycmmw7l
* clients.conf: Better comments.
  (foo): Commented out and changed into a better example client.
  (braxen_client): Removed.
  (bar): New commented-out example client.

* mandos: Changed all log messages to be unicode strings.
  (Client.fqdn): Renamed to "host".  All users and documentation
                 changed.
  (main): Exit immediately if no clients are defined.

* mandos.conf: Better comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
    fingerprint: string (40 or 32 hexadecimal digits); used to
164
164
                 uniquely identify the client
165
165
    secret:    bytestring; sent verbatim (over TLS) to client
166
 
    fqdn:      string (FQDN); available for use by the checker command
 
166
    host:      string; available for use by the checker command
167
167
    created:   datetime.datetime(); object creation, not client host
168
168
    last_checked_ok: datetime.datetime() or None if not yet checked OK
169
169
    timeout:   datetime.timedelta(); How long from last_checked_ok
230
230
        else:
231
231
            raise TypeError(u"No secret or secfile for client %s"
232
232
                            % self.name)
233
 
        self.fqdn = config.get("fqdn", "")
 
233
        self.host = config.get("host", "")
234
234
        self.created = datetime.datetime.now()
235
235
        self.last_checked_ok = None
236
236
        self.timeout = string_to_delta(config["timeout"])
259
259
        The possibility that a client might be restarted is left open,
260
260
        but not currently used."""
261
261
        # If this client doesn't have a secret, it is already stopped.
262
 
        if self.secret:
 
262
        if hasattr(self, "secret") and self.secret:
263
263
            logger.info(u"Stopping client %s", self.name)
264
264
            self.secret = None
265
265
        else:
313
313
        if self.checker is None:
314
314
            try:
315
315
                # In case check_command has exactly one % operator
316
 
                command = self.check_command % self.fqdn
 
316
                command = self.check_command % self.host
317
317
            except TypeError:
318
318
                # Escape attributes for the shell
319
319
                escaped_attrs = dict((key, re.escape(str(val)))
346
346
            self.checker_callback_tag = None
347
347
        if getattr(self, "checker", None) is None:
348
348
            return
349
 
        logger.debug("Stopping checker for %(name)s", vars(self))
 
349
        logger.debug(u"Stopping checker for %(name)s", vars(self))
350
350
        try:
351
351
            os.kill(self.checker.pid, signal.SIGTERM)
352
352
            #os.sleep(0.5)
712
712
    # Parse config file with clients
713
713
    client_defaults = { "timeout": "1h",
714
714
                        "interval": "5m",
715
 
                        "checker": "fping -q -- %%(fqdn)s",
 
715
                        "checker": "fping -q -- %%(host)s",
716
716
                        }
717
717
    client_config = ConfigParser.SafeConfigParser(client_defaults)
718
718
    client_config.read(os.path.join(server_settings["configdir"],
758
758
                              config
759
759
                              = dict(client_config.items(section)))
760
760
                       for section in client_config.sections()))
 
761
    if not clients:
 
762
        logger.critical(u"No clients defined")
 
763
        sys.exit(1)
761
764
    
762
765
    if not debug:
763
766
        daemon()
764
 
 
 
767
    
765
768
    pidfilename = "/var/run/mandos/mandos.pid"
766
769
    pid = os.getpid()
767
770
    try:
770
773
        pidfile.close()
771
774
        del pidfile
772
775
    except IOError, err:
773
 
        logger.error("Could not write %s file with PID %d",
 
776
        logger.error(u"Could not write %s file with PID %d",
774
777
                     pidfilename, os.getpid())
775
778
    
776
779
    def cleanup():
824
827
                             tcp_server.handle_request\
825
828
                             (*args[2:], **kwargs) or True)
826
829
        
827
 
        logger.debug("Starting main loop")
 
830
        logger.debug(u"Starting main loop")
828
831
        main_loop_started = True
829
832
        main_loop.run()
830
833
    except AvahiError, error: