From 5d8b0134eab3c6fb6f5ce8664846ae000e0cbb82 Mon Sep 17 00:00:00 2001 From: Kishi85 Date: Wed, 20 Feb 2019 11:49:30 +0100 Subject: [PATCH] fix broken references from move and add legacy run script --- acertmgr.py | 11 +++++++++++ acertmgr/__init__.py | 9 ++++----- acertmgr/authority/v1.py | 6 +++--- acertmgr/configuration.py | 2 +- acertmgr/modes/dns/abstract.py | 4 ++-- acertmgr/modes/dns/nsupdate.py | 2 +- acertmgr/modes/standalone.py | 2 +- acertmgr/modes/webdir.py | 2 +- 8 files changed, 24 insertions(+), 14 deletions(-) create mode 100755 acertmgr.py diff --git a/acertmgr.py b/acertmgr.py new file mode 100755 index 0000000..0bfec87 --- /dev/null +++ b/acertmgr.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# acertmgr compatibility script for legacy installations +# Copyright (c) Rudolf Mayerhofer, 2019. +# available under the ISC license, see LICENSE + +import acertmgr + +if __name__ == "__main__": + acertmgr.main() diff --git a/acertmgr/__init__.py b/acertmgr/__init__.py index a7ad307..b18829e 100755 --- a/acertmgr/__init__.py +++ b/acertmgr/__init__.py @@ -16,8 +16,7 @@ import stat import subprocess import tempfile -import configuration -import tools +from acertmgr import configuration, tools # @brief check whether existing target file is still valid or source crt has been updated @@ -46,7 +45,7 @@ def create_authority(settings): tools.new_rsa_key(acc_file) acc_key = tools.read_key(acc_file) - authority_module = importlib.import_module("authority.{0}".format(api)) + authority_module = importlib.import_module("acertmgr.authority.{0}".format(api)) authority_class = getattr(authority_module, "ACMEAuthority") return authority_class(settings.get('authority'), acc_key) @@ -59,7 +58,7 @@ def create_challenge_handler(settings): else: mode = "standalone" - handler_module = importlib.import_module("modes.{0}".format(mode)) + handler_module = importlib.import_module("acertmgr.modes.{0}".format(mode)) handler_class = getattr(handler_module, "ChallengeHandler") return handler_class(settings) @@ -162,7 +161,7 @@ def cert_put(settings): return crt_action -if __name__ == "__main__": +def main(): # load config configs = configuration.load() diff --git a/acertmgr/authority/v1.py b/acertmgr/authority/v1.py index 063a04d..6f803d2 100644 --- a/acertmgr/authority/v1.py +++ b/acertmgr/authority/v1.py @@ -17,15 +17,15 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import padding -import tools -from tools import byte_string_format +from acertmgr import tools +from acertmgr.tools import byte_string_format try: from urllib.request import urlopen # Python 3 except ImportError: from urllib2 import urlopen # Python 2 -from authority.acme import ACMEAuthority as AbstractACMEAuthority +from acertmgr.authority.acme import ACMEAuthority as AbstractACMEAuthority class ACMEAuthority(AbstractACMEAuthority): diff --git a/acertmgr/configuration.py b/acertmgr/configuration.py index 551e44b..343fdc2 100644 --- a/acertmgr/configuration.py +++ b/acertmgr/configuration.py @@ -10,7 +10,7 @@ import copy import io import os -import tools +from acertmgr import tools ACME_DIR = "/etc/acme" ACME_CONF = os.path.join(ACME_DIR, "acme.conf") diff --git a/acertmgr/modes/dns/abstract.py b/acertmgr/modes/dns/abstract.py index 835a84f..37539e3 100644 --- a/acertmgr/modes/dns/abstract.py +++ b/acertmgr/modes/dns/abstract.py @@ -12,8 +12,8 @@ import dns.update from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes -import tools -from modes.abstract import AbstractChallengeHandler +from acertmgr import tools +from acertmgr.modes.abstract import AbstractChallengeHandler class DNSChallengeHandler(AbstractChallengeHandler): diff --git a/acertmgr/modes/dns/nsupdate.py b/acertmgr/modes/dns/nsupdate.py index 7997566..e180302 100644 --- a/acertmgr/modes/dns/nsupdate.py +++ b/acertmgr/modes/dns/nsupdate.py @@ -17,7 +17,7 @@ import dns.resolver import dns.tsigkeyring import dns.update -from modes.dns.abstract import DNSChallengeHandler +from acertmgr.modes.dns.abstract import DNSChallengeHandler DEFAULT_KEY_ALGORITHM = "HMAC-MD5.SIG-ALG.REG.INT" diff --git a/acertmgr/modes/standalone.py b/acertmgr/modes/standalone.py index 51c2357..3cd76d4 100644 --- a/acertmgr/modes/standalone.py +++ b/acertmgr/modes/standalone.py @@ -19,7 +19,7 @@ except ImportError: import os import threading -from modes.webdir import ChallengeHandler as WebChallengeHandler +from acertmgr.modes.webdir import ChallengeHandler as WebChallengeHandler # @brief custom request handler for ACME challenges diff --git a/acertmgr/modes/webdir.py b/acertmgr/modes/webdir.py index f3cc1c0..5888f6b 100644 --- a/acertmgr/modes/webdir.py +++ b/acertmgr/modes/webdir.py @@ -8,7 +8,7 @@ import datetime import os -from modes.abstract import AbstractChallengeHandler +from acertmgr.modes.abstract import AbstractChallengeHandler try: from urllib.request import urlopen # Python 3