Make sure to catch all DNS exceptions.

This commit is contained in:
Antoine Nguyen
2024-08-01 12:44:11 +02:00
parent d35bc3dcc2
commit 82d9d5ff08
3 changed files with 15 additions and 9 deletions
+5 -5
View File
@@ -254,6 +254,8 @@ For debian and derivative, you need to install sqlite connector for dovecot::
Replace values between ``<>`` with yours.
.. _dovecot_oauth2:
OAuth 2 authentication
======================
@@ -264,9 +266,7 @@ application with the following commands:
.. sourcecode:: bash
> cd <modoboa_instance_path>
> python manage.py createapplication --name=Dovecot --algorithm=RS256 --skip-authorization --redirect-uris=http://localhost --client-secret=<client_secret> public authorization-code
Choose a value for ``<client_secret>`` (you can generate a random one).
> python manage.py createapplication --name=Dovecot --skip-authorization --client-id=dovecot confidential client-credentials
On success, you should see an output similar to::
@@ -291,13 +291,13 @@ Finally, create a file named :file:`conf.d/dovecot-oauth2.conf.ext` with the
following content::
introspection_mode = post
introspection_url = http://<client_id>:<client_secret>@localhost/api/o/introspect/
introspection_url = http://dovecot:<client_secret>@localhost/api/o/introspect/
username_attribute = username
tls_ca_cert_file = /etc/ssl/certs/ca-certificates.crt
active_attribute = active
active_value = true
Replace ``<client_id>`` and ``<client_secret>`` with the values you obtained earlier.
Replace ``<client_secret>`` with the value you obtained earlier.
LDAP
====
+6
View File
@@ -331,6 +331,12 @@ by default.
# If CORS fail, you might want to try to set it to True
#CORS_ORIGIN_ALLOW_ALL = False
Docevot configuration changes
-----------------------------
You must enable oauth2 authentication in Dovecot to make the filters
editor work in the new UI. Follow this :ref:`guide <dovecot_oauth2>`.
Post update
-----------
+4 -4
View File
@@ -192,13 +192,13 @@ def get_dns_resolver():
def get_authoritative_server(domain, resolver=None):
if not resolver:
resolver = get_dns_resolver()
resolver = get_dns_resolver()
dnsname = dns.name.from_text(domain)
while True:
try:
answers = dns.resolver.resolve(dnsname, 'NS')
answers = dns.resolver.resolve(dnsname, "NS")
if answers:
first_answer = answers[0]
if hasattr(first_answer, "target"):
@@ -214,7 +214,7 @@ def get_authoritative_server(domain, resolver=None):
def get_authoritative_ip(domain, resolver=None):
dnsserver_name = get_authoritative_server(domain, resolver=resolver)
if not resolver:
resolver = get_dns_resolver()
resolver = get_dns_resolver()
answer = resolver.resolve(dnsserver_name)
if answer:
return answer[0].address
@@ -235,8 +235,8 @@ def get_dns_records(name, typ, resolver=None):
"""Retrieve DNS records for given name and type."""
logger = logging.getLogger("modoboa.admin")
resolver = get_authoritative_resolver(name, resolver=resolver)
try:
resolver = get_authoritative_resolver(name, resolver=resolver)
dns_answers = resolver.resolve(name, typ, search=True)
except dns.resolver.NXDOMAIN as e:
logger.error(_("No DNS record found for %s") % name, exc_info=e)