From 5051ef1f1a2f47909cec4334601d4d86870beb69 Mon Sep 17 00:00:00 2001 From: Rafal Stefanowski Date: Thu, 4 Apr 2024 11:58:34 +0200 Subject: [PATCH] test-framework: Fix Python subprocess shell Signed-off-by: Rafal Stefanowski --- connection/local_executor.py | 3 +++ connection/ssh_executor.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/connection/local_executor.py b/connection/local_executor.py index fae9e28..924ebfb 100644 --- a/connection/local_executor.py +++ b/connection/local_executor.py @@ -1,5 +1,6 @@ # # Copyright(c) 2019-2021 Intel Corporation +# Copyright(c) 2024 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -15,6 +16,7 @@ class LocalExecutor(BaseExecutor): completed_process = subprocess.run( command, shell=True, + executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout.total_seconds()) @@ -40,6 +42,7 @@ class LocalExecutor(BaseExecutor): completed_process = subprocess.run( f'rsync -r {src} {dst} {" ".join(options)}', shell=True, + executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout.total_seconds()) diff --git a/connection/ssh_executor.py b/connection/ssh_executor.py index a05c34f..efd60a5 100644 --- a/connection/ssh_executor.py +++ b/connection/ssh_executor.py @@ -1,5 +1,6 @@ # # Copyright(c) 2019-2021 Intel Corporation +# Copyright(c) 2024 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # import os @@ -118,6 +119,7 @@ class SshExecutor(BaseExecutor): f'-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" ' + src_to_dst + f'{" ".join(options)}', shell=True, + executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout.total_seconds()) @@ -210,6 +212,7 @@ class SshExecutor(BaseExecutor): completed_process = subprocess.run( f"ssh{identity_str} -p {port}{param} {user_str}{hostname} {command}", shell=True, + executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)