From 0cbc4e8f8ed5c8366ed6864216d70d58f5ae0a82 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Tue, 18 Jan 2022 12:57:21 +0100 Subject: [PATCH] Add environment variable to know if yum is invoked from Salt(bsc#1057635) --- salt/modules/yumpkg.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 3f855d255f..08dccafceb 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -965,7 +965,9 @@ def list_repo_pkgs(*args, **kwargs): None if _yum() != "yum" else _LooseVersion( - __salt__["cmd.run"](["yum", "--version"], python_shell=False) + __salt__["cmd.run"]( + ["yum", "--version"], python_shell=False, env={"SALT_RUNNING": "1"} + ) .splitlines()[0] .strip() ) @@ -2433,7 +2435,9 @@ def list_holds(pattern=__HOLD_PATTERN, full=True): """ _check_versionlock() - out = __salt__["cmd.run"]([_yum(), "versionlock", "list"], python_shell=False) + out = __salt__["cmd.run"]( + [_yum(), "versionlock", "list"], python_shell=False, env={"SALT_RUNNING": "1"} + ) ret = [] for line in salt.utils.itertools.split(out, "\n"): match = _get_hold(line, pattern=pattern, full=full) @@ -2501,7 +2505,10 @@ def group_list(): } out = __salt__["cmd.run_stdout"]( - [_yum(), "grouplist", "hidden"], output_loglevel="trace", python_shell=False + [_yum(), "grouplist", "hidden"], + output_loglevel="trace", + python_shell=False, + env={"SALT_RUNNING": "1"}, ) key = None for line in salt.utils.itertools.split(out, "\n"): @@ -2572,7 +2579,9 @@ def group_info(name, expand=False, ignore_groups=None): ret[pkgtype] = set() cmd = [_yum(), "--quiet", "groupinfo", name] - out = __salt__["cmd.run_stdout"](cmd, output_loglevel="trace", python_shell=False) + out = __salt__["cmd.run_stdout"]( + cmd, output_loglevel="trace", python_shell=False, env={"SALT_RUNNING": "1"} + ) g_info = {} for line in salt.utils.itertools.split(out, "\n"): @@ -3301,7 +3310,9 @@ def download(*packages, **kwargs): cmd = ["yumdownloader", "-q", "--destdir={}".format(CACHE_DIR)] cmd.extend(packages) - __salt__["cmd.run"](cmd, output_loglevel="trace", python_shell=False) + __salt__["cmd.run"]( + cmd, output_loglevel="trace", python_shell=False, env={"SALT_RUNNING": "1"} + ) ret = {} for dld_result in os.listdir(CACHE_DIR): if not dld_result.endswith(".rpm"): @@ -3377,7 +3388,7 @@ def _get_patches(installed_only=False): patches = {} cmd = [_yum(), "--quiet", "updateinfo", "list", "all"] - ret = __salt__["cmd.run_stdout"](cmd, python_shell=False) + ret = __salt__["cmd.run_stdout"](cmd, python_shell=False, env={"SALT_RUNNING": "1"}) parsing_errors = False for line in salt.utils.itertools.split(ret, os.linesep): -- 2.37.3