3 ܓi@s>ddlZddlmZddlmZmZmZGdddeeZdS)N)glob)PluginIndependentPlugin PluginOptc@s@eZdZdZdZdZeddd d gZd d Zd dZ ddZ dS)SshzSecure shell serviceZsshservicessecuritysystemidentity userconfsFz5Changes whether module will collect user .ssh configs)defaultZdesccCsN|jddddddg}|j||j||jdr@|j|jddS) NZ sshd_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/*r zsshd -T)Z add_file_tags add_copy_specincluded_configsZ get_optionuser_ssh_files_permissionsZadd_cmd_output)selfsshcfgsr/usr/lib/python3.6/ssh.pysetups    z Ssh.setupcCsydddd|DD}x|D]}|jdd}t|j|dddX}xP|D]H}t|jd ksN|jd rnqN|jjd rN|j}|j|d|d qNWWd QRXq WWntk rYnXd S)z Include subconfig files cSsg|]}|D]}|q qSrr).0filesfrrr ;sz(Ssh.included_configs..cSsg|]}t|ddqS)T) recursive)r)rZcopyspecrrrr<s/rzUTF-8)encodingr#include)ZtagsN)splitopen path_joinlen startswithlowerr Exception)rrZcfgfilesZsshcfgtagZcfgfilelineZconfargrrrr6s    (zSsh.included_configsc Cstj}i}yHtdddd0}x(|D] }|jdd\}}|||<q$WWdQRXWntk rr|jddSXd d d h}xR|D]J}|j|kr||j|kr|jd |jd q|j|jd} |j | qWdS)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)rrNzCouldn't read /proc/mountsZnfsZnfs4ZautofszSkipping capture in z because it's a remote directoryz.ssh) pwdZgetpwallr"r!r'Z _log_errorpw_dirZ _log_infor#Zadd_dir_listing) rZ users_dataZ fs_mount_infoZ mounts_filer)Zfs_fileZ fs_vstypeZ non_local_fsuserZhome_dirrrrrNs&     zSsh.user_ssh_files_permissionsN)rrr r ) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesrZ option_listrrrrrrrrs r)r+rZsos.report.pluginsrrrrrrrr s