File fix-regression-with-depending-client.ssh-on-psutil-b.patch of Package salt

From 6d2928390ab9f9e6e80b7e7cd234eac3dacff2dc Mon Sep 17 00:00:00 2001
From: Victor Zhestkov <vzhestkov@suse.com>
Date: Tue, 12 Apr 2022 10:08:05 +0300
Subject: [PATCH] Fix regression with depending client.ssh on psutil
 (bsc#1197533)

---
 salt/client/ssh/__init__.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py
index 26248588e1..624ed33fa6 100644
--- a/salt/client/ssh/__init__.py
+++ b/salt/client/ssh/__init__.py
@@ -12,7 +12,6 @@ import hashlib
 import logging
 import multiprocessing
 import os
-import psutil
 import re
 import shlex
 import subprocess
@@ -406,6 +405,16 @@ class SSH:
                             self.__parsed_rosters[self.ROSTER_UPDATE_FLAG] = False
                             return
 
+    def _pid_exists(self, pid):
+        """
+        Check if specified pid is alive
+        """
+        try:
+            os.kill(pid, 0)
+        except OSError:
+            return False
+        return True
+
     def _update_roster(self, hostname=None, user=None):
         """
         Update default flat roster with the passed in information.
@@ -628,7 +637,8 @@ class SSH:
                             pid_running = (
                                 False
                                 if cached_session["pid"] == 0
-                                else cached_session.get("running", False) or psutil.pid_exists(cached_session["pid"])
+                                else cached_session.get("running", False)
+                                or self._pid_exists(cached_session["pid"])
                             )
                             if (
                                 pid_running and prev_session_running < self.max_pid_wait
-- 
2.35.1


openSUSE Build Service is sponsored by