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

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