Skip to content

Commit

Permalink
[NetworkManager] Get system-connections files from other locations
Browse files Browse the repository at this point in the history
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 <jcastillo@redhat.com>
  • Loading branch information
jcastill authored and arif-ali committed Dec 13, 2024
1 parent 5f06a1b commit 2bdf051
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions sos/report/plugins/networkmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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")
Expand Down Expand Up @@ -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 :

0 comments on commit 2bdf051

Please sign in to comment.