From cd7ba2f39da5382c7d610a22a9cd366a95b635df 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 | 31 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/sos/report/plugins/networkmanager.py b/sos/report/plugins/networkmanager.py index b9b1b83e3e..0de01cbcf3 100644 --- a/sos/report/plugins/networkmanager.py +++ b/sos/report/plugins/networkmanager.py @@ -19,14 +19,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") @@ -110,16 +117,18 @@ def test_nm_status(version=1): "nmcli dev show .*": "nmcli_dev_show_sos" }) + def postproc_system_connections(self, sc_path): + + 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=***", + ) + 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_file in self.system_connection_files: + self.postproc_system_connections(sc_file) # vim: set et ts=4 sw=4 :