From 2f39d3d2872c1fd25af5f7d0b96c0b3ec283d23e Mon Sep 17 00:00:00 2001 From: Jose Castillo Date: Thu, 12 Dec 2024 15:27:24 +0000 Subject: [PATCH] [NetworkManager] Get system-connections files from other locations system-connections files can be found not only under /etc/NetworkManager, but also /usr/lib/NetworkManager and /run/NetworkManager, so we need to capture and post process these locations as well. Resolves: #3875 Signed-off-by: Jose Castillo --- sos/report/plugins/networkmanager.py | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/sos/report/plugins/networkmanager.py b/sos/report/plugins/networkmanager.py index b9b1b83e3e..f9853fcd7a 100644 --- a/sos/report/plugins/networkmanager.py +++ b/sos/report/plugins/networkmanager.py @@ -6,7 +6,6 @@ # # See the LICENSE file in the source distribution for further information. -import os from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin @@ -19,14 +18,21 @@ class NetworkManager(Plugin, RedHatPlugin, UbuntuPlugin): packages = ('NetworkManager', 'network-manager') def setup(self): + self.system_connection_files = [ + "/etc/NetworkManager/system-connections/", + "/usr/lib/NetworkManager/system-connections/", + "/run/NetworkManager/system-connections/", + ] + + self.add_copy_spec(self.system_connection_files) + self.add_copy_spec([ "/etc/NetworkManager/NetworkManager.conf", - "/etc/NetworkManager/system-connections", "/etc/NetworkManager/dispatcher.d", "/etc/NetworkManager/conf.d", "/usr/lib/NetworkManager/conf.d", "/run/NetworkManager/conf.d", - "/var/lib/NetworkManager/NetworkManager-intern.conf" + "/var/lib/NetworkManager/NetworkManager-intern.conf", ]) self.add_journal(units="NetworkManager") @@ -111,15 +117,12 @@ def test_nm_status(version=1): }) def postproc(self): - for _, _, files in os.walk( - "/etc/NetworkManager/system-connections"): - for net_conf in files: - self.do_file_sub( - "/etc/NetworkManager/system-connections/"+net_conf, - r"(password|psk|mka-cak|password-raw|pin|preshared-key" - r"|private-key|secrets|wep-key[0-9])=(.*)", - r"\1=***", - ) - + for sc_path in self.system_connection_files: + self.do_path_regex_sub( + f"{sc_path}", + r"(password|psk|mka-cak|password-raw|pin|preshared-key" + r"|private-key|secrets|wep-key[0-9])=(.*)", + r"\1=***", + ) # vim: set et ts=4 sw=4 :