From 27c130d789e95e06ab1e3a52ae4b38d686cab559 Mon Sep 17 00:00:00 2001 From: maddes-b Date: Thu, 19 Sep 2024 15:05:39 +0200 Subject: [PATCH] 0.10.4: small fixes * ensure domain accounts file is read/written as UTF-8 and with LF EOL * use more specific name for env var to pass script path * enhance/fix some texts --- acme-dns-client-2.py | 8 ++++---- acme-dns-client-2.sh | 4 ++-- acmednsclient2.py | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/acme-dns-client-2.py b/acme-dns-client-2.py index ffc823f..7a78e81 100644 --- a/acme-dns-client-2.py +++ b/acme-dns-client-2.py @@ -20,7 +20,7 @@ """ -__version__ = "0.10.3" +__version__ = "0.10.4" __author__ = "Matthias \"Maddes\" Bücher" __license__ = "GPLv2" __copyright__ = "Copyright (C) 2024 Matthias \"Maddes\" Bücher" @@ -36,7 +36,7 @@ ### fix script name for argparse output try: - sys.argv[0] = os.environ["SCRIPT_PATH"] + sys.argv[0] = os.environ["ADC2_PATH"] except KeyError as e: pass ### allow local imports from script directory @@ -101,8 +101,8 @@ def createArgParser() -> argparse.ArgumentParser: Client for acme-dns servers. Client can be used with certbot and acme.sh.".format(version=__version__, version2=acmednsclient2.__version__, copyright=__copyright__, homepage=__homepage__) epilog = "\ First register the domain on the acme-dns server via the `register` command. \ -Existing registrations can also be imported into the config via the `add` command.\n\ -Then setup the DNS records and verify the setup with the `check` command.\n\ +Existing registrations can also be imported via the `add` command.\n\ +Then set the DNS records up and verify the setup with the `check` command.\n\ Finally use this script as a certbot plugin via `--manual --preferred-challenges dns --manual-auth-hook '/path/to/{script:s} certbot'` to retrieve a certificate with certbot's `certonly` command.\n\ For acme.sh copy the wrapper script 'dns_acmednsclient2.sh' to '/path/to/acme.sh/dnsapi/' and use it via `--dns dns_acmednsclient2`.".format(script=os.path.basename(sys.argv[0]).replace(".py", ".sh")) diff --git a/acme-dns-client-2.sh b/acme-dns-client-2.sh index 6885814..7bb7265 100644 --- a/acme-dns-client-2.sh +++ b/acme-dns-client-2.sh @@ -43,7 +43,7 @@ if [ ! -d "${VENV_PATH}" ]; then printf -- '%s\n' "--- Initializing Python Virtual Environment at ${VENV_PATH}" 1>&2 RC=0 ; "python${PYTHON_VERSION}" -m venv "${VENV_PATH}" || RC="${?}" if [ "${RC}" -ne 0 ]; then - printf -- '%s\n' "Failed to setup virtual environment in ${VENV_PATH}." 1>&2 + printf -- '%s\n' "Failed to set virtual environment up in ${VENV_PATH}." 1>&2 return "${RC}" 2>/dev/null || exit "${RC}" fi fi @@ -84,4 +84,4 @@ unset -v PYTHON_VERSION RC SCRIPT_NAME SCRIPT_DIR SCRIPT_PY_NAME VENV_PATH unset -v CREATE -SCRIPT_PATH="${0}" "${SCRIPT_PY_PATH}" "${@}" +ADC2_PATH="${0}" "${SCRIPT_PY_PATH}" "${@}" diff --git a/acmednsclient2.py b/acmednsclient2.py index 29da0eb..aa78f01 100644 --- a/acmednsclient2.py +++ b/acmednsclient2.py @@ -15,7 +15,7 @@ """ -__version__ = "0.10.3" +__version__ = "0.10.4" __author__ = "Matthias \"Maddes\" Bücher" __license__ = "GPLv2" __copyright__ = "Copyright (C) 2024 Matthias \"Maddes\" Bücher" @@ -165,7 +165,7 @@ def _loadFromFile(self) -> None: self._resetWithDefaults() filedata = None - with open(self._jsonpath, mode="rt") as file: + with open(self._jsonpath, mode="rt", encoding="UTF-8", newline=None) as file: filedata = json.load(file) for key, fileconfigdata in filedata.items(): @@ -257,7 +257,7 @@ def _loadFromFile(self, config:Configuration) -> None: self.domains.clear() filedata = None - with open(self._jsonpath, mode="rt") as file: + with open(self._jsonpath, mode="rt", encoding="UTF-8", newline=None) as file: filedata = json.load(file) default_server = config.settings[config.ATTR_URL_DEFAULT_SERVER] @@ -397,7 +397,7 @@ def save(self) -> None: filedata = json.dumps(filedata, indent=4, **JSON5_DUMP_KWARGS) ### write JSON string - with open(self._jsonpath, mode="wt") as file: + with open(self._jsonpath, mode="wt", encoding="UTF-8", newline="\n") as file: file.write(filedata) # --- /DomainAccounts.save() @@ -866,7 +866,7 @@ def _check_txt(cls, accdata:dict, resolve_func:typing.Callable[...,dns.resolver. ### https://dnspython.readthedocs.io/en/stable/resolver-class.html#dns.resolver.Resolver.resolve dns_answers = resolve_func(qname=accdata[cls.ATTR_DOMAIN_CHALLENGE], rdtype=dns.rdatatype.TXT) except dns.exception.DNSException as e: - return False, "TXT missing (acme-dns: either DNS (NS, A/AAAA or glue record) or setup (domain not updated once yet? deregistered?)" + return False, "TXT missing (acme-dns: either DNS issue (NS, A/AAAA or glue record) or no token record (domain not updated once yet? deregistered?))" return True, "TXT available (acme-dns)" # --- /DomainAccounts._check_txt()