/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

* clients.conf.xml: Renamed to "mandos-clients.conf.xml".

* Makefile (DOCBOOKTOMAN, DOCS): New
  (all): Include $(DOCS)
  (%.5: %.xml, %.8: %.xml, %.8mandos: %.xml): New.
  (clean): Also remove $(DOCS)

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
 
    host:      string; available for use by the checker command
 
166
    fqdn:      string (FQDN); 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.host = config.get("host", "")
 
233
        self.fqdn = config.get("fqdn", "")
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 hasattr(self, "secret") and self.secret:
 
262
        if 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.host
 
316
                command = self.check_command % self.fqdn
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(u"Stopping checker for %(name)s", vars(self))
 
349
        logger.debug("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 -- %%(host)s",
 
715
                        "checker": "fping -q -- %%(fqdn)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)
764
761
    
765
762
    if not debug:
766
763
        daemon()
767
764
    
768
 
    pidfilename = "/var/run/mandos/mandos.pid"
769
 
    pid = os.getpid()
770
 
    try:
771
 
        pidfile = open(pidfilename, "w")
772
 
        pidfile.write(str(pid) + "\n")
773
 
        pidfile.close()
774
 
        del pidfile
775
 
    except IOError, err:
776
 
        logger.error(u"Could not write %s file with PID %d",
777
 
                     pidfilename, os.getpid())
778
 
    
779
765
    def cleanup():
780
766
        "Cleanup function; run on exit"
781
767
        global group
827
813
                             tcp_server.handle_request\
828
814
                             (*args[2:], **kwargs) or True)
829
815
        
830
 
        logger.debug(u"Starting main loop")
 
816
        logger.debug("Starting main loop")
831
817
        main_loop_started = True
832
818
        main_loop.run()
833
819
    except AvahiError, error: