From 71b3211d3d64cae19daf7e940516f47bc284450c Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 8 Aug 2024 13:37:28 +0200 Subject: postinstall: remove shell=True Remove the use of shell=True. --- src/utils/postinstall.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/postinstall.py b/src/utils/postinstall.py index 65434af..6d6e60e 100644 --- a/src/utils/postinstall.py +++ b/src/utils/postinstall.py @@ -10,6 +10,7 @@ import subprocess import shutil import logging import hivex +import shlex from src.log import OgError from src.utils.bcd import update_bcd from src.utils.probe import * @@ -90,19 +91,19 @@ def set_linux_hostname(disk, partition, name): def configure_os_custom(disk, partition): - if not shutil.which('configureOsCustom'): + command_path = shutil.which('configureOsCustom') + if not command_path: raise OgError('configureOsCustom not found') logging.info(f'Found configureOsCustom script, invoking it...') - cmd_configure = f"configureOsCustom {disk} {partition}" + cmd_configure = f"{command_path} {disk} {partition}" try: - proc = subprocess.run(cmd_configure, + proc = subprocess.run(shlex.split(cmd_configure), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, encoding='utf-8', - shell=True, check=True) out = proc.stdout except OSError as e: -- cgit v1.2.3-18-g5258