o id @s*ddlmZmZmZGdddeeZdS))PluginIndependentPlugin PluginOptc@sBeZdZdZdZdZeddeddgZdd Z d d Z d d Z dS)SshzSecure shell servicessh)servicessecuritysystemidentity userconfsTz5Changes whether module will collect user .ssh configs)defaultval_typedesccCsF|dddddg}|||||dr!|dSdS)N sshd_config ssh_config)z/etc/ssh/sshd_config$z/etc/ssh/ssh_config$z/etc/ssh/ssh_configz/etc/ssh/sshd_configr ) add_file_tags add_copy_specincluded_configs get_optionuser_ssh_files_permissions)selfsshcfgsr8/usr/lib/python3/dist-packages/sos/report/plugins/ssh.pysetups    z Ssh.setupc CszN|D]H}|dd}t||d/}|D]$}t|dks&|dr'q|dr;|}|j|d|dqWdn1sFwYqWdStyXYdSw) N/rr#include)tags)splitopen path_joinlen startswithlowerr Exception)rrsshcfgtagcfgfilelineconfargrrrr0s$ zSsh.included_configsc Cs|d}|dr6zt|d }|}Wdn1s wYWnty5|dYdSw|d}|D]%}z||ddd }||rY| d |Wq>t ycYq>wdS) z Iterate over .ssh folders in user homes to see their permissions. Bad permissions can prevent SSH from allowing access to given user. z getent passwdstatusz /etc/passwdNzCouldn't read /etc/passwdoutput:z.sshz ls -laZ {}) exec_cmdr#r$ readlinesr( _log_error splitlinesr" path_isdiradd_cmd_outputformat IndexError)r users_data passwd_fileusers_data_linesusr_linehome_dirrrrrAs,       zSsh.user_ssh_files_permissionsN) __name__ __module__ __qualname__ short_desc plugin_nameprofilesrstr option_listrrrrrrrrs rN)sos.report.pluginsrrrrrrrrs