Current File : //usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/ssh.cpython-36.pyc
3

\��h��@s>ddlZddlmZddlmZmZmZGdd�dee�ZdS)�N)�glob)�Plugin�IndependentPlugin�	PluginOptc@s@eZdZdZdZdZeddd	d
�gZdd�Zd
d�Z	dd�Z
dS)�SshzSecure shell serviceZssh�services�security�system�identity�	userconfsFz5Changes whether module will collect user .ssh configs)�defaultZdesccCsN|jddd��dddg}|j|�|j|�|jd�r@|j�|jd�dS)	NZsshd_configZ
ssh_config)z/etc/ssh/sshd_config$z/etc/ssh/ssh_config$z/etc/ssh/ssh_configz/etc/ssh/sshd_configz/etc/ssh/sshd_config.d/*rzsshd -T)Z
add_file_tags�
add_copy_spec�included_configsZ
get_option�user_ssh_files_permissionsZadd_cmd_output)�self�sshcfgs�r�/usr/lib/python3.6/ssh.py�setups



z	Ssh.setupcCs�y�dd�dd�|D�D�}x�|D]�}|jd�d}t|j|�ddd��X}xP|D]H}t|j��d	ksN|jd
�rnqN|j�jd�rN|j�}|j|d|d�qNWWd
QRXq WWntk
r�YnXd
S)z Include subconfig files cSsg|]}|D]}|�qqSrr)�.0�files�frrr�
<listcomp>;sz(Ssh.included_configs.<locals>.<listcomp>cSsg|]}t|dd��qS)T)�	recursive)r)rZcopyspecrrrr<s�/��rzUTF-8)�encodingr�#�include)ZtagsN���)�split�open�	path_join�len�
startswith�lowerr
�	Exception)rrZcfgfilesZsshcfg�tagZcfgfile�lineZconfargrrrr6s


(zSsh.included_configsc
Cs�tj�}i}yHtdddd��0}x(|D] }|j�dd�\}}|||<q$WWdQRXWntk
rr|jd�dSXd	d
dh}xR|D]J}|j|kr�||j|kr�|jd|j�d
��q�|j|jd�}	|j	|	�q�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/proc/mountsrzUTF-8)rr�NzCouldn't read /proc/mountsZnfsZnfs4ZautofszSkipping capture in z  because it's a remote directoryz.ssh)
�pwdZgetpwallr"r!r'Z
_log_error�pw_dirZ	_log_infor#Zadd_dir_listing)
rZ
users_dataZ
fs_mount_infoZmounts_filer)Zfs_fileZ	fs_vstypeZnon_local_fs�userZhome_dirrrrrNs&




zSsh.user_ssh_files_permissionsN)rrr	r
)�__name__�
__module__�__qualname__Z
short_descZplugin_nameZprofilesrZoption_listrrrrrrrrs
r)r+rZsos.report.pluginsrrrrrrrr�<module>s