1
0
forked from rpms/sos
sos/SOURCES/sos-bz1998521-unpackaged-recursive-symlink.patch

43 lines
1.5 KiB
Diff
Raw Normal View History

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