From bcd87a23395c71efbb293001701942a30291fc97 Mon Sep 17 00:00:00 2001 From: Dmitriy Fofanov Date: Thu, 30 Oct 2025 07:56:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20wrapper=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D1=8B?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=85=D1=83=D0=BA=D0=BE=D0=B2=20auth?= =?UTF-8?q?=20=D0=B8=20cleanup=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D0=B5=20LetsEncryptManager.=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D1=8B=20certbot=20=D0=B4=D0=BB=D1=8F=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=8D=D1=82=D0=B8=D1=85=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D0=BB=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- letsencrypt_regru_api.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/letsencrypt_regru_api.py b/letsencrypt_regru_api.py index 463ddfe..6d8dad9 100644 --- a/letsencrypt_regru_api.py +++ b/letsencrypt_regru_api.py @@ -1099,13 +1099,30 @@ class LetsEncryptManager: for d in domains: domain_args.extend(["-d", d]) + # Создаём временные wrapper скрипты для hooks + import tempfile + + # Auth hook wrapper + auth_hook_script = tempfile.NamedTemporaryFile(mode='w', suffix='.sh', delete=False) + auth_hook_script.write('#!/bin/bash\n') + auth_hook_script.write(f'{sys.executable} {os.path.abspath(__file__)} --auth-hook\n') + auth_hook_script.close() + os.chmod(auth_hook_script.name, 0o755) + + # Cleanup hook wrapper + cleanup_hook_script = tempfile.NamedTemporaryFile(mode='w', suffix='.sh', delete=False) + cleanup_hook_script.write('#!/bin/bash\n') + cleanup_hook_script.write(f'{sys.executable} {os.path.abspath(__file__)} --cleanup-hook\n') + cleanup_hook_script.close() + os.chmod(cleanup_hook_script.name, 0o755) + # Команда certbot cmd = [ "certbot", "certonly", "--manual", "--preferred-challenges", "dns", - "--manual-auth-hook", f"{sys.executable} {os.path.abspath(__file__)} --auth-hook", - "--manual-cleanup-hook", f"{sys.executable} {os.path.abspath(__file__)} --cleanup-hook", + "--manual-auth-hook", auth_hook_script.name, + "--manual-cleanup-hook", cleanup_hook_script.name, "--email", self.email, "--agree-tos", "--non-interactive", @@ -1138,6 +1155,13 @@ class LetsEncryptManager: self.logger.error(f"Ошибка при получении сертификата: {e}") self.logger.error(e.stderr) return False + finally: + # Удаляем временные wrapper скрипты + try: + os.unlink(auth_hook_script.name) + os.unlink(cleanup_hook_script.name) + except: + pass def renew_certificate(self) -> bool: """