Blame SOURCES/sos-bz1998521-unpackaged-recursive-symlink.patch

003633
From e2ca3d02f36c0db4efaacfb2c1b7d502f38e371c Mon Sep 17 00:00:00 2001
003633
From: Pavel Moravec <pmoravec@redhat.com>
003633
Date: Mon, 30 Aug 2021 10:18:29 +0200
003633
Subject: [PATCH] [unpackaged] deal with recursive loop of symlinks properly
003633
003633
When the plugin processes a recursive loop of symlinks, it currently
003633
hangs in an infinite loop trying to follow the symlinks. Use
003633
pathlib.Path.resolve() method to return the target directly.
003633
003633
Resolves: #2664
003633
003633
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
003633
---
003633
 sos/report/plugins/unpackaged.py | 5 +++--
003633
 1 file changed, 3 insertions(+), 2 deletions(-)
003633
003633
diff --git a/sos/report/plugins/unpackaged.py b/sos/report/plugins/unpackaged.py
003633
index e5cc6191..9d68077c 100644
003633
--- a/sos/report/plugins/unpackaged.py
003633
+++ b/sos/report/plugins/unpackaged.py
003633
@@ -10,6 +10,7 @@ from sos.report.plugins import Plugin, RedHatPlugin
003633
 
003633
 import os
003633
 import stat
003633
+from pathlib import Path
003633
 
003633
 
003633
 class Unpackaged(Plugin, RedHatPlugin):
003633
@@ -41,8 +42,8 @@ class Unpackaged(Plugin, RedHatPlugin):
003633
                 for name in files:
003633
                     path = os.path.join(root, name)
003633
                     try:
003633
-                        while stat.S_ISLNK(os.lstat(path).st_mode):
003633
-                            path = os.path.abspath(os.readlink(path))
003633
+                        if stat.S_ISLNK(os.lstat(path).st_mode):
003633
+                            path = Path(path).resolve()
003633
                     except Exception:
003633
                         continue
003633
                     file_list.append(os.path.realpath(path))
003633
-- 
003633
2.31.1
003633