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

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