diff --git a/debian/changelog b/debian/changelog index a6ed39311..6a3691b4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +yunohost (4.1.6) stable; urgency=low + + - [fix] Make dyndns update more resilient to ns0.yunohost.org being down ([#1140](https://github.com/yunohost/yunohost/pull/1140)) + - [fix] Stupid yolopatch for not-normalized app path settings ([#1141](https://github.com/yunohost/yunohost/pull/1141)) + - [i18n] Update translations for German + + Thanks to all contributors <3 ! (Christian W., Daniel, penguin321) + + -- Alexandre Aubin Wed, 20 Jan 2021 01:46:02 +0100 + yunohost (4.1.5) stable; urgency=low - [fix] Update helpers ([#1136](https://github.com/yunohost/yunohost/pull/11346)) @@ -9,7 +19,6 @@ yunohost (4.1.5) stable; urgency=low Thanks to all contributors <3 ! (Aleks, Kay0u, Omnia89, jorge-vitrubio, YohannEpitech, xaloc33) - -- Kayou Thu, 14 Jan 2021 21:23:39 +0100 yunohost (4.1.4.4) stable; urgency=low diff --git a/src/yunohost/app.py b/src/yunohost/app.py index ae3051ac4..fea9b75a8 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1873,6 +1873,18 @@ def _get_app_settings(app_id): # If label contains unicode char, this may later trigger issues when building strings... # FIXME: this should be propagated to read_yaml so that this fix applies everywhere I think... settings = {k: v for k, v in settings.items()} + + # Stupid fix for legacy bullshit + # In the past, some setups did not have proper normalization for app domain/path + # Meaning some setups (as of January 2021) still have path=/foobar/ (with a trailing slash) + # resulting in stupid issue unless apps using ynh_app_normalize_path_stuff + # So we yolofix the settings if such an issue is found >_> + # A simple call to `yunohost app list` (which happens quite often) should be enough + # to migrate all app settings ... so this can probably be removed once we're past Bullseye... + if settings.get("path") != "/" and (settings.get("path", "").endswith("/") or not settings.get("path", "/").startswith("/")): + settings["path"] = "/" + settings["path"].strip("/") + _set_app_settings(app_id, settings) + if app_id == settings['id']: return settings except (IOError, TypeError, KeyError): @@ -2394,7 +2406,7 @@ class YunoHostArgumentFormatParser(object): if parsed_question.ask is None: parsed_question.ask = "Enter value for '%s':" % parsed_question.name - + # Empty value is parsed as empty string if parsed_question.default == "": parsed_question.default = None diff --git a/src/yunohost/dyndns.py b/src/yunohost/dyndns.py index e43c180ad..44bdb0706 100644 --- a/src/yunohost/dyndns.py +++ b/src/yunohost/dyndns.py @@ -35,11 +35,10 @@ from moulinette.core import MoulinetteError from moulinette.utils.log import getActionLogger from moulinette.utils.filesystem import write_to_file, read_file from moulinette.utils.network import download_json -from moulinette.utils.process import check_output from yunohost.utils.error import YunohostError from yunohost.domain import _get_maindomain, _build_dns_conf -from yunohost.utils.network import get_public_ip +from yunohost.utils.network import get_public_ip, dig from yunohost.log import is_unit_operation logger = getActionLogger('yunohost.dyndns') @@ -216,8 +215,36 @@ def dyndns_update(operation_logger, dyn_host="dyndns.yunohost.org", domain=None, 'zone %s' % host, ] - old_ipv4 = check_output("dig @%s +short %s" % (dyn_host, domain)) or None - old_ipv6 = check_output("dig @%s +short aaaa %s" % (dyn_host, domain)) or None + + def resolve_domain(domain, rdtype): + + # FIXME make this work for IPv6-only hosts too.. + ok, result = dig(dyn_host, "A") + dyn_host_ip = result[0] if ok == "ok" and len(result) else None + if not dyn_host_ip: + raise YunohostError("Failed to resolve %s" % dyn_host) + + ok, result = dig(domain, rdtype, resolvers=[dyn_host_ip]) + if ok == "ok": + return result[0] if len(result) else None + elif result[0] == "Timeout": + logger.debug("Timed-out while trying to resolve %s record for %s using %s" % (rdtype, domain, dyn_host)) + else: + return None + + logger.debug("Falling back to external resolvers") + ok, result = dig(domain, rdtype, resolvers="force_external") + if ok == "ok": + return result[0] if len(result) else None + elif result[0] == "Timeout": + logger.debug("Timed-out while trying to resolve %s record for %s using external resolvers : %s" % (rdtype, domain, result)) + else: + return None + + raise YunohostError("Failed to resolve %s for %s" % (rdtype, domain), raw_msg=True) + + old_ipv4 = resolve_domain(domain, "A") + old_ipv6 = resolve_domain(domain, "AAAA") # Get current IPv4 and IPv6 ipv4_ = get_public_ip()