U
    -Ø_gí  ã                   @   s&   d dl mZmZ G dd„ deeƒZdS )é    )ÚPluginÚIndependentPluginc                   @   s,   e Zd ZdZdZdZdZdd„ Zdd„ Zd	S )
ÚSudozSudo command executionÚsudo)ZidentityÚsystem)r   c              
   C   sÂ   |   d¡ d}ddg}zDt|ddd,}|D ] }| d¡r,| | ¡ d	 ¡ q,W 5 Q R X W n8 tk
r’ } z|  d
|› d|› ¡ W 5 d }~X Y nX |  d¡sª|   |¡ n|   dd„ |D ƒ¡ d S )Nz
/etc/sudo*z/etc/sudo.confz/var/log/sudo_debugz/var/log/sudoers_debugÚrzUTF-8)ÚencodingZDebugé   zCould not open conf file z: Zall_logsc                 S   s   g | ]}|› d ‘qS )Ú*© )Ú.0Úlogr   r   ú9/usr/lib/python3/dist-packages/sos/report/plugins/sudo.pyÚ
<listcomp>&   s     zSudo.setup.<locals>.<listcomp>)Zadd_copy_specÚopenÚ
startswithÚappendÚsplitÚIOErrorZ
_log_errorZ
get_option)ÚselfZconfig_fileZ	log_filesÚcfileÚlineÚerrorr   r   r   Úsetup   s    

"(
z
Sudo.setupc                 C   s   d}|   d|d¡ d S )Nz(\s*bindpw\s*)\S+z/etc/sudo-ldap.confz
\1********)Zdo_file_sub)r   Zregexpr   r   r   Úpostproc(   s    zSudo.postprocN)	Ú__name__Ú
__module__Ú__qualname__Z
short_descZplugin_nameZprofilesZpackagesr   r   r   r   r   r   r      s   r   N)Zsos.report.pluginsr   r   r   r   r   r   r   Ú<module>   s   