11
11
# "AvahiService" class, and some lines in "main".
13
13
# Everything else is
14
# Copyright © 2008-2018 Teddy Hogeborn
15
# Copyright © 2008-2018 Björn Påhlsson
17
# This file is part of Mandos.
19
# Mandos is free software: you can redistribute it and/or modify it
20
# under the terms of the GNU General Public License as published by
14
# Copyright © 2008-2016 Teddy Hogeborn
15
# Copyright © 2008-2016 Björn Påhlsson
17
# This program is free software: you can redistribute it and/or modify
18
# it under the terms of the GNU General Public License as published by
21
19
# the Free Software Foundation, either version 3 of the License, or
22
20
# (at your option) any later version.
24
# Mandos is distributed in the hope that it will be useful, but
25
# WITHOUT ANY WARRANTY; without even the implied warranty of
22
# This program is distributed in the hope that it will be useful,
23
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
24
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
25
# GNU General Public License for more details.
29
27
# You should have received a copy of the GNU General Public License
30
# along with Mandos. If not, see <http://www.gnu.org/licenses/>.
28
# along with this program. If not, see
29
# <http://www.gnu.org/licenses/>.
32
31
# Contact the authors at <mandos@recompile.se>.
496
495
class AvahiServiceToSyslog(AvahiService):
497
496
def rename(self, *args, **kwargs):
498
497
"""Add the new name to the syslog messages"""
499
ret = super(AvahiServiceToSyslog, self).rename(*args, **kwargs)
498
ret = AvahiService.rename(self, *args, **kwargs)
500
499
syslogger.setFormatter(logging.Formatter(
501
500
'Mandos ({}) [%(process)d]: %(levelname)s: %(message)s'
502
501
.format(self.name)))
508
507
"""This isn't so much a class as it is a module-like namespace.
509
508
It is instantiated once, and simulates having a GnuTLS module."""
511
library = ctypes.util.find_library("gnutls")
513
library = ctypes.util.find_library("gnutls-deb0")
514
_library = ctypes.cdll.LoadLibrary(library)
510
_library = ctypes.cdll.LoadLibrary(
511
ctypes.util.find_library("gnutls"))
516
512
_need_version = b"3.3.0"
518
514
def __init__(self):
519
# Need to use "self" here, since this method is called before
520
# the assignment to the "gnutls" global variable happens.
521
if self.check_version(self._need_version) is None:
522
raise self.Error("Needs GnuTLS {} or later"
523
.format(self._need_version))
515
# Need to use class name "GnuTLS" here, since this method is
516
# called before the assignment to the "gnutls" global variable
518
if GnuTLS.check_version(self._need_version) is None:
519
raise GnuTLS.Error("Needs GnuTLS {} or later"
520
.format(self._need_version))
525
522
# Unless otherwise indicated, the constants and types below are
526
523
# all from the gnutls/gnutls.h C header file.
2365
2361
ctypes.byref(crtverify))
2366
2362
if crtverify.value != 0:
2367
2363
gnutls.openpgp_crt_deinit(crt)
2368
raise gnutls.CertificateSecurityError(code
2364
raise gnutls.CertificateSecurityError("Verify failed")
2370
2365
# New buffer for the fingerprint
2371
2366
buf = ctypes.create_string_buffer(20)
2372
2367
buf_len = ctypes.c_size_t()
2885
2880
# Convert the SafeConfigParser object to a dict
2886
2881
server_settings = server_config.defaults()
2887
2882
# Use the appropriate methods on the non-string config options
2888
for option in ("debug", "use_dbus", "use_ipv6", "restore",
2889
"foreground", "zeroconf"):
2883
for option in ("debug", "use_dbus", "use_ipv6", "foreground"):
2890
2884
server_settings[option] = server_config.getboolean("DEFAULT",
2892
2886
if server_settings["port"]: