%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/gp/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/gp/__pycache__/gp_firewalld_ext.cpython-312.pyc

�

�I�d���v�ddlZddlmZmZddlmZddlmZddlZddl	m
Z
ddlmZd�Z
d�ZGd	�d
e
�Zy)�N)�Popen�PIPE)�blake2b)�which)�
gp_pol_ext)�logc���td�}|�T|g}|jt|��t|tt��}|j�\}}|j|fSy)Nzfirewall-cmd)�stdout�stderr)���zfirewall-cmd not found)r�extend�listrr�communicate�
returncode)�args�fw_cmd�cmd�p�
stdoutdata�_s      �;/usr/lib/python3/dist-packages/samba/gp/gp_firewalld_ext.py�firewall_cmdrsX��
�>�
"�F�
���h���
�
�4��:���#�d�4�0���
�
��
�
�A��|�|�Z�'�'�+�c��t|t�r
|�d|��dzS|�ddj|j�D��cgc]\}}|�d|����c}}��d�Scc}}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�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�gp_firewalld_extc��y)NzSecurity/Firewalld�)�selfs r�__str__zgp_firewalld_ext.__str__-s��#rc���tdd|z�d}|dk7rtjd|�n)|jj	t|�d|z|�td�\}}|dk7rtjd|�|j
�j�D]?}tdd|zd	|j�z�}|dk7s�*tjd|��Ay)
N�--permanentz
--new-zone=%srzFailed to add new zonezzone:%sz--list-interfacesz!Failed to set interfaces for zone�	--zone=%sz--add-interface=%s)	rr�error�gp_db�storer�strip�split�decode)r*�zone�ret�out�	interfaces     r�
apply_zonezgp_firewalld_ext.apply_zone0s����=�/�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�		Erc
�L�|j�D�]�\}}|D�]}d|vrtd|d�}nd}dD]J}|j�D�cgc]}|j|�s�|��}}|D]}	|t|	||	�z
}��Lt	gd��}
t	|j��}|
j|�}t
|�dk(r+|tt|�d|t|�d�z
}ntjd�tdd	|zd
|j��d}
|
dk7rtjd|���-t|j��j�}|jj!t#|�d|�d
|��|�������ycc}w)N�rulezrule )�source�destination�service�port�protocolz
icmp-block�
masqueradez	icmp-typezforward-portzsource-portr�audit)�accept�reject�drop�mark�rzInvalid firewall rule syntaxr-r.z--add-rich-rulezFailed to add firewall rulezrule:�:)r r%�keys�
startswith�set�intersection�lenrrr/rr2r�encode�	hexdigestr0r1r)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\}}|jj|�t|�|v�r|t|�j�D]�\}}|j	d�rTtdd|z�d}|dk7rt
jd|��E|jjt|�|��k|j	d�s�}|jd�\}}	}tdd|	zd	|�d}|dk7rt
jd
|���|jjt|�|���|jj���Q|D�]O}
|
js�d}|jj|
j�d}tjj|
j|�}
|j!|
�}|s�x|j"D]�}|j$j	|�s�|j$j'd
�r/|j)t+j,|j.���i|j$j'd�s��|j0dk(r��|j3|j.���|jj���Ry)Nr5r-z--delete-zone=%srzFailed to remove zoner;rHr.z--remove-rich-rulezFailed to remove firewall rule�/Software\Policies\Samba\Unix Settings\Firewalld�MACHINE/Registry.pol�Rules�Zones�
**delvals.)r0�set_guidrr rJrrr/�deleter3�commit�
file_sys_pathr!�os�pathr�parse�entries�keyname�endswithrZ�json�loads�data�	valuenamer9)r*�deleted_gpo_list�changed_gpo_list�guid�settings�	attribute�valuer6rr5�gpo�section�pol_filerf�pol_conf�es                r�process_group_policyz%gp_firewalld_ext.process_group_policy_s8��.�	 �N�D�(��J�J����%��4�y�H�$�(0��T��(;�(A�(A�(C�D�$�I�u� �+�+�F�3�*�=�+=��+E�G�GH�J���!�8��I�I�&=�u�E� �J�J�-�-�c�$�i��C�"�-�-�f�5�%.�_�_�S�%9�
��4��*�=�+��:L�+?��H�HI�K���!�8��I�I�&F��N� �J�J�-�-�c�$�i��C�D� 
�J�J����'	 �*$�	$�C�� � �O���
�
�#�#�C�H�H�-�1���w�w�|�|�C�$5�$5�x�@���:�:�d�+����!�)�)�4�A��y�y�+�+�G�4��9�9�-�-�g�6� �,�,�T�Z�Z����-?�@��Y�Y�/�/��8� �{�{�l�:� (� �O�O�A�F�F�3�4��
�
�!�!�#�#	$rc��i}d}d}|j�r1tjj|j|�}|j	|�}|s|S|j
D]�}|jj|�s�|jjd�rF|jdk(r�Jd|j�vrg|d<|dj|j���|jjd�s��d|j�vrg|d<|djtj|j����|S)Nr]r\r_r`r^)rdrerfrrgrhrirJrjrnrI�appendrmrkrl)r*ru�outputrwrvrfrxrys        r�rsopzgp_firewalld_ext.rsop�s����)��G������7�7�<�<�� 1� 1�8�<�D��z�z�$�'�H���
��%�%�
C���9�9�'�'��0��y�y�)�)�'�2��;�;�,�6�$�"�&�+�+�-�7�.0�F�7�O��w��.�.�q�v�v�6����+�+�G�4�"�&�+�+�-�7�.0�F�7�O��w��.�.�t�z�z�!�&�&�/A�B�
C��
rN)�__name__�
__module__�__qualname__r+r9rZrzr~r)rrr'r',s��$�E� 2�>'$�Rrr')re�
subprocessrr�hashlibr�shutilrrk�samba.gp.gpclassr�samba.gp.util.loggingrrr%r'r)rr�<module>r�s5��"
�"����'�%�
,�K�q�z�qr

Zerion Mini Shell 1.0