%PDF- %PDF-
| Direktori : /lib/python3/dist-packages/samba/gp/__pycache__/ |
| Current File : //lib/python3/dist-packages/samba/gp/__pycache__/gp_firewalld_ext.cpython-312.pyc |
�
�I�d� � �v � d dl Z d dlmZmZ d dlmZ d dlmZ d dlZd dl m
Z
d dlmZ d� Z
d� Z G d � d
e
� Zy)� N)�Popen�PIPE)�blake2b)�which)�
gp_pol_ext)�logc �� � t d� }|�T|g}|j t | � � t |t t �� }|j � \ }}|j |fS y)Nzfirewall-cmd)�stdout�stderr)���zfirewall-cmd not found)r �extend�listr r �communicate�
returncode)�args�fw_cmd�cmd�p�
stdoutdata�_s �;/usr/lib/python3/dist-packages/samba/gp/gp_firewalld_ext.py�firewall_cmdr sX � �
�>�
"�F�
���h���
�
�4��:���#�d�4�0���
�
��
�
�A��|�|�Z�'�'�+� c � � t |t � r
| �d|��dz S | �ddj |j � D ��cg c] \ }}|�d|���� c}}� �d�S c c}}w )N�=� )�
isinstance�str�join�items)�name�rule_segment�k�vs r �rule_segment_parser% % sW � ��,��$���.�#�5�5���H�H�<�3E�3E�3G�H�4�1�a��A�&�H�I�K� K��Hs �Ac �* � e Zd Zd� Zd� Zd� Zd� Zd� Zy)�gp_firewalld_extc � � y)NzSecurity/Firewalld� )�selfs r �__str__zgp_firewalld_ext.__str__- s � �#r c �� � t dd|z � d }|dk7 rt j d|� n)| j j t | � d|z |� t d� \ }}|dk7 rt j d|� |j
� j � D ]? }t dd|z d |j � z � }|dk7 s�*t j d|� �A y )
N�--permanentz
--new-zone=%sr zFailed to add new zonezzone:%sz--list-interfacesz!Failed to set interfaces for zone� --zone=%sz--add-interface=%s) r r �error�gp_db�storer �strip�split�decode)r* �zone�ret�out� interfaces r �
apply_zonezgp_firewalld_ext.apply_zone0 s� � ��=�/�D�*@�A�!�D���!�8��I�I�.��5��J�J���S��Y� �D�(8�$�?�� 3�4���S��!�8��I�I�9�4�@�����*�*�,� E�I��}�k�D�.@�3�i�6F�6F�6H�H�J�C��a�x�� � �=�t�D� Er c
�L � |j � D �]� \ }}|D �] }d|v rt d|d � }nd}dD ]J }|j � D �cg c] }|j |� s�|�� }}|D ] } |t | || � z
}� �L t g d�� }
t |j � � }|
j |� }t
|� dk( r+|t t |� d |t |� d � z
}nt j d� t dd |z d
|j � � d }
|
dk7 rt j d|� ��-t |j � � j � }| j j! t# | � d|�d
|��|� ��� ��� y c c}w )N�rulezrule )�source�destination�service�port�protocolz
icmp-block�
masqueradez icmp-typezforward-portzsource-portr �audit)�accept�reject�drop�mark� r zInvalid firewall rule syntaxr- r. z--add-rich-rulezFailed to add firewall rulezrule:�:)r r% �keys�
startswith�set�intersection�lenr r r/ r r2 r �encode� hexdigestr0 r1 r )r* � rule_dictr5 �rulesr; �rule_parsed�segment�s�namesr! �actions�segments�actionr6 �rhashs r �apply_ruleszgp_firewalld_ext.apply_rules@ s� � �$�?�?�,� 2�K�D�%��
2���T�>�"4�V�T�&�\�"J�K�")�K� 0� L�G� )-� � ��M�1�q�|�|�G�7L�Q�M�E�M� %� L��#�'9�$��T�
�'K�K��L�L� �B�C���t�y�y�{�+�� �-�-�h�7���v�;�!�#��#5�d�6�l�1�o�6:�4��<��?�6K�$M� M�K� �I�I�<�=�"�=�+��2D�#4�k�6G�6G�6I�K�KL�N���!�8��I�I�;�[�I�#�K�$6�$6�$8�9�C�C�E�E��J�J�$�$�S��Y��e�0L�%0�2�5
2� 2�� Ns �F!
�"F!
c �V � |D �]N \ }}| j j |� t | � |v �r|t | � j � D ]� \ }}|j d� rTt dd|z � d }|dk7 rt
j d|� �E| j j t | � |� �k|j d� s�}|j d� \ }} }t dd| z d |� d }|dk7 rt
j d
|� ��| j j t | � |� �� | j j � ��Q |D �]O }
|
j s�d}| j j |
j � d}t j j |
j |� }
| j! |
� }|s�x|j"