File: //usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/ssh.cpython-36.pyc
3
3��d
� @ s* d dl mZmZmZ G dd� dee�ZdS )� )�Plugin�IndependentPlugin� PluginOptc @ sB e Zd ZdZdZdZedded d
�gZdd� Z d
d� Z
dd� ZdS )�SshzSecure shell serviceZssh�services�security�system�identity� userconfsTz5Changes whether module will collect user .ssh configs)�defaultZval_typeZdescc C sB | j ddd�� ddg}| j|� | j|� | jd�r>| j� d S )NZsshd_configZ
ssh_config)z/etc/ssh/sshd_config$z/etc/ssh/ssh_config$z/etc/ssh/ssh_configz/etc/ssh/sshd_configr
)Z
add_file_tags�
add_copy_spec�included_configsZ
get_option�user_ssh_files_permissions)�self�sshcfgs� r �/usr/lib/python3.6/ssh.py�setup s
z Ssh.setupc C s� y�x�|D ]�}|j d�d }t| j|�d��X}xP|D ]H}t|j � �dks2|jd�rRq2|j� jd�r2|j � }| j|d |d� q2W W d Q R X qW W n tk
r� Y nX d S ) N�/� �rr �#�include)Ztags���)�split�open� path_join�len�
startswith�lowerr � Exception)r r Zsshcfg�tagZcfgfile�lineZconfargr r r r
0 s
(zSsh.included_configsc C s� | j d�}|d rZy&t| jd���}|j� }W dQ R X W qf tk
rV | jd� dS X n|d j� }xV|D ]N}y4| j|jd�d d �}| j|�r�| j d
j
|�� W ql tk
r� Y qlX qlW dS )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 passwdZstatusz/etc/passwdNzCouldn't read /etc/passwd�output�:� z.sshz
ls -laZ {})Zexec_cmdr r � readlinesr Z
_log_error�
splitlinesr Z
path_isdirZadd_cmd_output�format�
IndexError)r Z
users_dataZpasswd_fileZusers_data_linesZusr_lineZhome_dirr r r r A s
zSsh.user_ssh_files_permissionsN)r r r r )�__name__�
__module__�__qualname__Z
short_descZplugin_nameZprofilesr �strZoption_listr r
r r r r r r s
r N)Zsos.report.pluginsr r r r r r r r �<module> s