Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/firewall_tables.cpython-36.opt-1.pyc

3

�fC�@s*ddlmZmZmZGdd�dee�ZdS)�)�Plugin�IndependentPlugin�SoSPredicatec@sDeZdZdZdZdZdZdZdZdd
�Z	dd�Z
dd�Zdd�ZdS)�FirewallTablesaCollects information about local firewall tables, such as iptables,
    and nf_tables (via nft). Note that this plugin does _not_ collect firewalld
    information, which is handled by a separate plugin.

    Collections from this plugin are largely gated byt the presence of relevant
    kernel modules - for example,  the plugin will not collect the nf_tables
    ruleset if both the `nf_tables` and `nfnetlink` kernel modules are not
    currently loaded (unless using the --allow-system-changes option).
    zfirewall tablesZfirewall_tables�network�system�
/etc/nftables�	ip_tables�
ip6_tables�	nf_tables�	nfnetlink�ebtablescCs2d|}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 z -nvLr)�kmods)�predN)�add_cmd_outputr)�self�	tablename�modname�cmd�r�%/usr/lib/python3.6/firewall_tables.py�collect_iptables
zFirewallTables.collect_iptablecCs2d|}d|d}|j|t||dgd�d�dS)z& Same as function above, but for ipv6 Z	ip6table_z
ip6tables -t z -nvLr)r)rN)rr)rrrrrrr�collect_ip6table*s
zFirewallTables.collect_ip6tablecCs&t|ddgddid�}|jd|dd�S)	zS Collects nftables rulesets with 'nft' commands if the modules
        are present rrr�all)rZrequiredznft -a list rulesetT)rZchanges)rZcollect_cmd_output)rZnft_predrrr�collect_nftables3s
zFirewallTables.collect_nftablesc
 Cs|j�}ggd�}|ddkr&|dnd}xZ|j�D]N}|j�dd�}t|�dkr4|ddkr4|d|kr4||dj|d	�q4Wd
}y*d}t|dd
d��}|j�}	WdQRXWntk
r�|}	YnXx2|	j�D]&}
|ddkr�|
|dkr�|j|
�q�Wy*d}t|dd
d��}|j�}	WdQRXWntk
�rF|}	YnXx8|	j�D],}
|ddk�rR|
|dk�rR|j	|
��qRW|ddk�s�d|dk�r�|j
dt|ddgd�d�|ddk�s�d|dk�r�|j
dt|ddgd�d�|jdddg�dS)N)�ip�ip6Zstatusr�output���table��zmangle
filter
nat
z/proc/net/ip_tables_names�rzUTF-8)�encodingrz/proc/net/ip6_tables_namesr�filterziptables -vnxLZiptable_filterr)r)rzip6tables -vnxLZip6table_filterz
/etc/nftablesz/etc/sysconfig/nftables.confz/etc/nftables.conf)
r�
splitlines�split�len�append�open�read�IOErrorrrrrZ
add_copy_spec)
rZnft_listZ
nft_ip_tablesZ	nft_lines�lineZwordsZdefault_ip_tablesZproc_net_ip_tablesZifileZip_tables_namesr Zproc_net_ip6_tablesZipfilerrr�setup>sN


zFirewallTables.setupN)rr)r)r	r
rrr
)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofiles�filesZkernel_modsrrrr.rrrrrs		rN)Zsos.report.pluginsrrrrrrrr�<module>	s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists