Skip to content

Commit

Permalink
[ssh] Stop collecting 'ls' information from non-local home dirs
Browse files Browse the repository at this point in the history
Commands like 'ls -laZ' can take some time to run in remote filesystems,
for example NFS. When you have hundreds of them, sos can take a long
time to walk through it, and could be even worse if we use the option
'recursive'.
For ssh home dirs, we don't need the listing, so in this patch we detect
the type of filesystem and run the command only on local ones.

Related: RHEL-22389, SUPDEV-156

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Oct 11, 2024
1 parent 5cafeee commit 9e1e09d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sos/report/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,21 @@ def user_ssh_files_permissions(self):
"""
users_data = pwd.getpwall()

fs_mount_info = {}
try:
with open('/proc/mounts', "r", encoding='UTF-8') as mounts_file:
for line in mounts_file:
(fs_file, fs_vstype) = line.split()[1:3]
fs_mount_info[fs_file] = fs_vstype
except Exception:
self._log_error("Couldn't read /proc/mounts")
return
non_local_fs = {'nfs', 'nfs4', 'autofs'}
# Read the home paths of users in the system and check the ~/.ssh dirs
for user in users_data:
if user.pw_dir in fs_mount_info and \
fs_mount_info[user.pw_dir] in non_local_fs:
continue
home_dir = self.path_join(user.pw_dir, '.ssh')
self.add_dir_listing(home_dir)

Expand Down

0 comments on commit 9e1e09d

Please sign in to comment.