File add-environment-variable-to-know-if-yum-is-invoked-f.patch of Package salt.24048

From 6ba30d3900bc328efd3480c0ff3d9e9b126fc5cb Mon Sep 17 00:00:00 2001
From: Alexander Graul <agraul@suse.com>
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 cf684e20f7..8d089c6aa4 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()
         )
@@ -2422,7 +2424,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)
@@ -2490,7 +2494,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"):
@@ -2561,7 +2568,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"):
@@ -3278,7 +3287,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"):
@@ -3354,7 +3365,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.34.1


openSUSE Build Service is sponsored by