Your IP : 216.73.217.13


Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/firewall_tables.cpython-38.pyc

U

���b��@s*ddlmZmZmZGdd�dee�ZdS)�)�Plugin�IndependentPlugin�SoSPredicatec@s8eZdZdZdZdZdd�Zdd�Zdd�Zd	d
�Z	dS)�firewall_tableszfirewall tables)Znetwork�systemcCs2d|}d|d}|j|t||dgd�d�dS)z� Collecting iptables rules for a table loads either kernel module
        of the table name (for kernel <= 3), or nf_tables (for kernel >= 4).
        If neither module is present, the rules must be empty.Ziptable_ziptables -t � -nvL�	nf_tables��kmods��predN��add_cmd_outputr��selfZ	tablename�modname�cmd�r�D/usr/lib/python3/dist-packages/sos/report/plugins/firewall_tables.py�collect_iptables�zfirewall_tables.collect_iptablecCs2d|}d|d}|j|t||dgd�d�dS)z& Same as function above, but for ipv6 Z	ip6table_z
ip6tables -t rrr	rNr
rrrr�collect_ip6tables�z firewall_tables.collect_ip6tablecCs&t|ddgddid�}|jd|dd�S)	zS Collects nftables rulesets with 'nft' commands if the modules
        are present rZ	nfnetlinkr
�all)r
Zrequiredznft list rulesetT)rZchanges)rZcollect_cmd_output)rZnft_predrrr�collect_nftables's��z firewall_tables.collect_nftablesc	Cs�|��}ggd�}|ddkr&|dnd}|��D]R}|��dd�}t|�dkr2|ddkr2|d|��kr2||d�|d	�q2d
}ztd���}Wntk
r�|}YnX|��D]&}|ddkr�||dkr�|�	|�q�ztd
���}Wntk
�r|}YnX|��D],}|ddk�r||dk�r|�
|��q|ddk�sbd|dk�r||jdt|ddgd�d�|ddk�s�d|dk�r�|jdt|ddgd�d�|�
dddg�dS)N)�ip�ip6Zstatusr�output���table��zmangle
filter
z/proc/net/ip_tables_namesrz/proc/net/ip6_tables_namesr�filterziptables -vnxLZiptable_filterrr	rzip6tables -vnxLZip6table_filterz
/etc/nftablesz/etc/sysconfig/nftables.confz/etc/nftables.conf)r�
splitlines�split�len�keys�append�open�read�IOErrorrrrrZ
add_copy_spec)	rZnft_listZ
nft_ip_tablesZ	nft_lines�lineZwordsZdefault_ip_tablesZip_tables_namesrrrr�setup2sN
�

���zfirewall_tables.setupN)
�__name__�
__module__�__qualname__Z
short_descZplugin_nameZprofilesrrrr+rrrrrs	rN)Zsos.report.pluginsrrrrrrrr�<module>	s