diff options
author | Kevin C Myers <kevin.myers@redhat.com> | 2021-05-08 11:17:06 +0000 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-05-10 11:53:14 -0400 |
commit | 8ef60a08430a35785f0af61ab0fcf241f5d3b54d (patch) | |
tree | a2b0a7dfe0cfaf8c659a162907cabd172366f836 | |
parent | 85feb327f9ef5aa43bac9b7a5fe16edd3aea4e58 (diff) | |
download | sos-8ef60a08430a35785f0af61ab0fcf241f5d3b54d.tar.gz |
[ssh] SSH and SSHD configurations may be fragmented
The SSH configurations may have an include directive. This
adjustment to the plugin will copy in the main configs and
then read those for any include keywords and attempt to
copy those as well.
Resolves: #2528
Signed-off-by: Kevin C Myers kemyers at redhat dot com
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | sos/report/plugins/ssh.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sos/report/plugins/ssh.py b/sos/report/plugins/ssh.py index 2e756c2c..55c9068c 100644 --- a/sos/report/plugins/ssh.py +++ b/sos/report/plugins/ssh.py @@ -19,9 +19,28 @@ class Ssh(Plugin, IndependentPlugin): profiles = ('services', 'security', 'system', 'identity') def setup(self): - self.add_copy_spec([ + sshcfgs = [ "/etc/ssh/ssh_config", "/etc/ssh/sshd_config" - ]) + ] + + # Include main config files + self.add_copy_spec(sshcfgs) + + # Read configs for any includes and copy those + try: + for sshcfg in sshcfgs: + with open(sshcfg, 'r') as cfgfile: + for line in cfgfile: + # skip empty lines and comments + if len(line.split()) == 0 or line.startswith('#'): + continue + # ssh_config keywords are allowed as case-insensitive + if line.lower().startswith('include'): + confarg = line.split() + self.add_copy_spec(confarg[1]) + except Exception: + pass + # vim: set et ts=4 sw=4 : |