/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Björn Påhlsson
  • Date: 2011-10-15 16:48:03 UTC
  • Revision ID: belorn@fukt.bsnet.se-20111015164803-61q3hzrv91d042mb
Tags: version-1.4.1-1
* Makefile (version): Changed to "1.4.1".
* NEWS (Version 1.4.1): New entry.
* debian/changelog (1.4.1-1): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
 
86
86
version = "1.4.1"
87
87
 
88
 
logger = logging.getLogger()
 
88
#logger = logging.getLogger('mandos')
 
89
logger = logging.Logger('mandos')
89
90
syslogger = (logging.handlers.SysLogHandler
90
91
             (facility = logging.handlers.SysLogHandler.LOG_DAEMON,
91
92
              address = str("/dev/log")))
95
96
logger.addHandler(syslogger)
96
97
 
97
98
console = logging.StreamHandler()
98
 
console.setFormatter(logging.Formatter('%(asctime)s %(name)s'
99
 
                                       ' [%(process)d]:'
 
99
console.setFormatter(logging.Formatter('%(name)s [%(process)d]:'
100
100
                                       ' %(levelname)s:'
101
101
                                       ' %(message)s'))
102
102
logger.addHandler(console)
103
103
 
104
 
 
105
104
class AvahiError(Exception):
106
105
    def __init__(self, value, *args, **kwargs):
107
106
        self.value = value
165
164
                            .GetAlternativeServiceName(self.name))
166
165
        logger.info("Changing Zeroconf service name to %r ...",
167
166
                    self.name)
 
167
        syslogger.setFormatter(logging.Formatter
 
168
                               ('Mandos (%s) [%%(process)d]:'
 
169
                                ' %%(levelname)s: %%(message)s'
 
170
                                % self.name))
168
171
        self.remove()
169
172
        try:
170
173
            self.add()
190
193
                avahi.DBUS_INTERFACE_ENTRY_GROUP)
191
194
        self.entry_group_state_changed_match = (
192
195
            self.group.connect_to_signal(
193
 
                'StateChanged', self.entry_group_state_changed))
 
196
                'StateChanged', self .entry_group_state_changed))
194
197
        logger.debug("Adding Zeroconf service '%s' of type '%s' ...",
195
198
                     self.name, self.type)
196
199
        self.group.AddService(
262
265
                                 self.server_state_changed)
263
266
        self.server_state_changed(self.server.GetState())
264
267
 
265
 
class AvahiServiceToSyslog(AvahiService):
266
 
    def rename(self):
267
 
        """Add the new name to the syslog messages"""
268
 
        ret = AvahiService.rename(self)
269
 
        syslogger.setFormatter(logging.Formatter
270
 
                               ('Mandos (%s) [%%(process)d]:'
271
 
                                ' %%(levelname)s: %%(message)s'
272
 
                                % self.name))
273
 
        return ret
274
268
 
275
269
def _timedelta_to_milliseconds(td):
276
270
    "Convert a datetime.timedelta() to milliseconds"
1976
1970
            raise error
1977
1971
    
1978
1972
    if not debug and not debuglevel:
1979
 
        logger.setLevel(logging.WARNING)
 
1973
        syslogger.setLevel(logging.WARNING)
 
1974
        console.setLevel(logging.WARNING)
1980
1975
    if debuglevel:
1981
1976
        level = getattr(logging, debuglevel.upper())
1982
 
        logger.setLevel(level)
 
1977
        syslogger.setLevel(level)
 
1978
        console.setLevel(level)
1983
1979
    
1984
1980
    if debug:
1985
 
        logger.setLevel(logging.DEBUG)
1986
1981
        # Enable all possible GnuTLS debugging
1987
1982
        
1988
1983
        # "Use a log level over 10 to enable all debugging options."
2029
2024
            server_settings["use_dbus"] = False
2030
2025
            tcp_server.use_dbus = False
2031
2026
    protocol = avahi.PROTO_INET6 if use_ipv6 else avahi.PROTO_INET
2032
 
    service = AvahiServiceToSyslog(name =
2033
 
                                   server_settings["servicename"],
2034
 
                                   servicetype = "_mandos._tcp",
2035
 
                                   protocol = protocol, bus = bus)
 
2027
    service = AvahiService(name = server_settings["servicename"],
 
2028
                           servicetype = "_mandos._tcp",
 
2029
                           protocol = protocol, bus = bus)
2036
2030
    if server_settings["interface"]:
2037
2031
        service.interface = (if_nametoindex
2038
2032
                             (str(server_settings["interface"])))