From e799c860d6249793582339c8669f887e6648462b Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Wed, 20 Mar 2024 22:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=B8=E8=BD=BD=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E8=84=9A=E6=9C=AC=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=A0=A1?= =?UTF-8?q?=E9=AA=8Cpkey=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/OpenEulerMirrorISO/uninstall.sh | 2 +- tools/download_dependency/src/download_config.py | 4 ---- .../install_dependency/src/handler/base_yaml_check.py | 10 +--------- tools/install_dependency/src/machine/machine.py | 9 ++++++--- tools/install_dependency/src/utils.py | 4 ++++ 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/component/OpenEulerMirrorISO/uninstall.sh b/component/OpenEulerMirrorISO/uninstall.sh index b2e4c39..97d2efc 100644 --- a/component/OpenEulerMirrorISO/uninstall.sh +++ b/component/OpenEulerMirrorISO/uninstall.sh @@ -2,7 +2,7 @@ function resume_original_mirror() { rm -rf /etc/yum.repos.d/local.repo - mv -rf /etc/yum.repos.d/yum.repos.backup/* /etc/yum.repos.d/ + mv -f /etc/yum.repos.d/yum.repos.backup/* /etc/yum.repos.d/ rm -rf /etc/yum.repos.d/yum.repos.backup yum clean all diff --git a/tools/download_dependency/src/download_config.py b/tools/download_dependency/src/download_config.py index 9d4d3b5..1bc885d 100644 --- a/tools/download_dependency/src/download_config.py +++ b/tools/download_dependency/src/download_config.py @@ -31,10 +31,6 @@ CompatibilityTesting = { "file": "https://gitee.com/openeuler/devkit-pipeline/releases/download/v0.2/compatibility_testing.tar.gz", } -DevkitDistribute = { - "component_name": "DevkitDistribute", - "file": "https://gitee.com/openeuler/devkit-pipeline/releases/download/v0.2/devkit_distribute.tar.gz", -} OpenEuler_2003_LTS = { "component_name": "openEuler_2003_LTS", diff --git a/tools/install_dependency/src/handler/base_yaml_check.py b/tools/install_dependency/src/handler/base_yaml_check.py index 7f5ce9a..95ee725 100644 --- a/tools/install_dependency/src/handler/base_yaml_check.py +++ b/tools/install_dependency/src/handler/base_yaml_check.py @@ -46,16 +46,8 @@ class BaseCheck(Handler): if not pkey_path: LOGGER.error("Yaml file content not correct. Empty pkey.") return False - - if not BaseCheck.validate_path(pkey_path) or not os.path.isfile(pkey_path): - LOGGER.error("Yaml file content not correct. Given pkey not exists.") - return False return True - - @staticmethod - def validate_path(path: str) -> bool: - return path.startswith('/') and path.find('../') == -1 and path.find('./') == -1 - + @staticmethod def check_machine_ip(data): for machine_type in (set(KLASS_DICT.keys()) & set(data.keys())): diff --git a/tools/install_dependency/src/machine/machine.py b/tools/install_dependency/src/machine/machine.py index f8b8f7d..b25a398 100644 --- a/tools/install_dependency/src/machine/machine.py +++ b/tools/install_dependency/src/machine/machine.py @@ -8,11 +8,11 @@ import timeout_decorator import constant from command_line import CommandLine -from exception.connect_exception import CreatePkeyFailedException, ConnectRemoteException, \ - NotMatchedMachineTypeException +from exception.connect_exception import (CreatePkeyFailedException, ConnectRemoteException, + NotMatchedMachineTypeException) from download import component_collection_map from lkp_collect_map import lkp_collection_map -from utils import (base_path, MKDIR_TMP_DEVKITDEPENDENCIES_CMD, YUM_INSTALL_LKP_DEPENDENCIES_CMD, +from utils import (base_path, validate_path, MKDIR_TMP_DEVKITDEPENDENCIES_CMD, YUM_INSTALL_LKP_DEPENDENCIES_CMD, CHECK_HOME_SPACE_SUFFICIENT_FOR_MIRROR, CHECK_TMP_SPACE_SUFFICIENT_FOR_PACKAGE, CHECK_MIRROR_INSTALL_STATUS, PROMPT_MAP) @@ -56,6 +56,9 @@ class Machine: return sftp def transport_connect(self, user, pkey_path, password=None): + if not validate_path(pkey_path) or not os.path.isfile(pkey_path): + LOGGER.error("Yaml file content not correct. Given pkey not exists.") + raise ConnectRemoteException() try: # 指定本地的RSA私钥文件。如果建立密钥对时设置的有密码,password为设定的密码,如无不用指定password参数 pkey = paramiko.RSAKey.from_private_key_file(pkey_path, password=password) diff --git a/tools/install_dependency/src/utils.py b/tools/install_dependency/src/utils.py index 71278dc..d249129 100644 --- a/tools/install_dependency/src/utils.py +++ b/tools/install_dependency/src/utils.py @@ -16,6 +16,10 @@ PROMPT_MAP = { } +def validate_path(path: str) -> bool: + return path.startswith('/') and path.find('../') == -1 and path.find('./') == -1 + + def base_path(path): if getattr(sys, 'frozen', False): base_dir = sys._MEIPASS -- Gitee