/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-07 21:45:41 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080807214541-pyg8itw6kphz1dy5
* plugbasedclient.c: Renamed to "mandos-client.c".  All users changed.

* plugins.d/mandosclient.c: Renamed to "plugins.d/password-request.c".
                            All users changed.

* plugins.d/passprompt.c: Renamed to "plugins.d/password-prompt.c".
                          All users changed.

* server.conf: Renamed to "mandos.conf".  All users changed.

* server.py: Renamed to "mandos".
  (daemon): Have default values for arguments. Caller changed.

* Makefile (distclean, mostlyclean, maintainer-clean): New aliases for
                                                       "clean".
  (check, run-client, run-server): New.

* network-protocol.txt: New.

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)
528
528
                in6addr_any = "::"
529
529
                self.server_address = (in6addr_any,
530
530
                                       self.server_address[1])
531
 
            elif not self.server_address[1]:
 
531
            elif self.server_address[1] is None:
532
532
                self.server_address = (self.server_address[0],
533
533
                                       0)
534
 
#                 if self.settings["interface"]:
535
 
#                     self.server_address = (self.server_address[0],
536
 
#                                            0, # port
537
 
#                                            0, # flowinfo
538
 
#                                            if_nametoindex
539
 
#                                            (self.settings
540
 
#                                             ["interface"]))
541
534
            return super(type(self), self).server_bind()
542
535
 
543
536
 
659
652
                      help="Port number to receive requests on")
660
653
    parser.add_option("--check", action="store_true", default=False,
661
654
                      help="Run self-test")
662
 
    parser.add_option("--debug", action="store_true",
 
655
    parser.add_option("--debug", action="store_true", default=False,
663
656
                      help="Debug mode; run in foreground and log to"
664
657
                      " terminal")
665
658
    parser.add_option("--priority", type="string", help="GnuTLS"
712
705
    # Parse config file with clients
713
706
    client_defaults = { "timeout": "1h",
714
707
                        "interval": "5m",
715
 
                        "checker": "fping -q -- %%(host)s",
 
708
                        "checker": "fping -q -- %%(fqdn)s",
716
709
                        }
717
710
    client_config = ConfigParser.SafeConfigParser(client_defaults)
718
711
    client_config.read(os.path.join(server_settings["configdir"],
758
751
                              config
759
752
                              = dict(client_config.items(section)))
760
753
                       for section in client_config.sections()))
761
 
    if not clients:
762
 
        logger.critical(u"No clients defined")
763
 
        sys.exit(1)
764
754
    
765
755
    if not debug:
766
756
        daemon()
767
757
    
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
758
    def cleanup():
780
759
        "Cleanup function; run on exit"
781
760
        global group
827
806
                             tcp_server.handle_request\
828
807
                             (*args[2:], **kwargs) or True)
829
808
        
830
 
        logger.debug(u"Starting main loop")
 
809
        logger.debug("Starting main loop")
831
810
        main_loop_started = True
832
811
        main_loop.run()
833
812
    except AvahiError, error: