/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

merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
                        ('Mandos: %(levelname)s: %(message)s'))
72
72
logger.addHandler(syslogger)
73
73
 
74
 
console = logging.StreamHandler()
75
 
console.setFormatter(logging.Formatter('%(name)s: %(levelname)s:'
76
 
                                       ' %(message)s'))
77
 
logger.addHandler(console)
78
74
 
79
75
class AvahiError(Exception):
80
76
    def __init__(self, value):
119
115
        self.domain = domain
120
116
        self.host = host
121
117
        self.rename_count = 0
122
 
        self.max_renames = max_renames
123
118
    def rename(self):
124
119
        """Derived from the Avahi example code"""
125
120
        if self.rename_count >= self.max_renames:
126
121
            logger.critical(u"No suitable service name found after %i"
127
122
                            u" retries, exiting.", rename_count)
128
123
            raise AvahiServiceError("Too many renames")
129
 
        self.name = server.GetAlternativeServiceName(self.name)
130
 
        logger.info(u"Changing name to %r ...", str(self.name))
 
124
        name = server.GetAlternativeServiceName(name)
 
125
        logger.error(u"Changing name to %r ...", name)
131
126
        syslogger.setFormatter(logging.Formatter\
132
127
                               ('Mandos (%s): %%(levelname)s:'
133
 
                               ' %%(message)s' % self.name))
 
128
                               ' %%(message)s' % name))
134
129
        self.remove()
135
130
        self.add()
136
131
        self.rename_count += 1
659
654
    global main_loop_started
660
655
    main_loop_started = False
661
656
    
662
 
    parser = OptionParser(version = "%%prog %s" % version)
 
657
    parser = OptionParser(version = "Mandos server %s" % version)
663
658
    parser.add_option("-i", "--interface", type="string",
664
659
                      metavar="IF", help="Bind to interface IF")
665
660
    parser.add_option("-a", "--address", type="string",
722
717
    
723
718
    if not debug:
724
719
        syslogger.setLevel(logging.WARNING)
725
 
        console.setLevel(logging.WARNING)
726
720
    
727
721
    if server_settings["servicename"] != "Mandos":
728
722
        syslogger.setFormatter(logging.Formatter\
757
751
            avahi.DBUS_INTERFACE_SERVER )
758
752
    # End of Avahi example code
759
753
    
 
754
    if debug:
 
755
        console = logging.StreamHandler()
 
756
        # console.setLevel(logging.DEBUG)
 
757
        console.setFormatter(logging.Formatter\
 
758
                             ('%(levelname)s: %(message)s'))
 
759
        logger.addHandler(console)
 
760
        del console
 
761
    
760
762
    clients = Set()
761
763
    def remove_from_clients(client):
762
764
        clients.remove(client)
774
776
        sys.exit(1)
775
777
    
776
778
    if not debug:
777
 
        logger.removeHandler(console)
778
779
        daemon()
779
780
    
780
781
    pidfilename = "/var/run/mandos/mandos.pid"