From d063f452f69cbefb749602de9a2d4731f95739c7 Mon Sep 17 00:00:00 2001 From: Vadim Troshchinskiy Date: Thu, 17 Oct 2024 20:02:08 +0200 Subject: [PATCH] Deduplicate key extraction --- installer/opengnsys_git_installer.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/installer/opengnsys_git_installer.py b/installer/opengnsys_git_installer.py index f18e0e3..9be596d 100755 --- a/installer/opengnsys_git_installer.py +++ b/installer/opengnsys_git_installer.py @@ -352,31 +352,7 @@ class OpengnsysGitInstaller: if not self.ignoresshkey: - public_key="" - if self.usesshkey: - with open(self.usesshkey, 'r') as f: - public_key = f.read().strip() - - else: - if os.path.isfile(client_initrd_path): - #os.makedirs(temp_dir, exist_ok=True) - os.chdir(self.temp_dir.name) - self.__logger.debug("Descomprimiendo %s", client_initrd_path) - public_key = None - with libarchive.file_reader(client_initrd_path) as initrd: - for file in initrd: - self.__logger.debug("Archivo: %s", file) - - if file.pathname in self.key_paths_dict: - data = bytearray() - for block in file.get_blocks(): - data = data + block - public_key = data.decode('utf-8').strip() - - break - else: - print(f"No se encuentra la imagen de initrd {client_initrd_path}") - exit(2) + public_key = self._extract_ssh_key() # Si la clave publica no existe me salgo con error if not public_key: