ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/clconfpars.cpython-311.pyc

�

I/�f�(��V�ddlZddlZddlZddlZddlZddlmZGd�de��ZGd�de��Z	dZ
dd	�Zd
Zde
de
fd
�Zd d�ZiZd!d�Zd"d�Zejdejejzejz��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedgd���Zd�Z de
de
fd�Z!dS)#�N)�
namedtuplec��eZdZd�ZdS)�WebConfigParsingErrorc��||_dS�N��message��selfr	s  ��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.11-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/clconfpars.py�__init__zWebConfigParsingError.__init__�
�������N��__name__�
__module__�__qualname__r
�rrrr�#����������rrc��eZdZd�ZdS)�WebConfigMissingc��||_dSrrr
s  rr
zWebConfigMissing.__init__rrNrrrrrrrrr�asectionFc�&�tjddd���}|rt|_|rbt	|d��5}|����tj��d��}ddd��n#1swxYwYn>t	|dd���5}|���}ddd��n#1swxYwY|�	d	t�d
�|z|���t|�t�����S)
NTF)�allow_no_value�
interpolation�strict�rb�replace�r�utf-8��encoding�[z]
)�source)�section)
�configparser�ConfigParser�str�optionxform�open�read�decode�locale�getpreferredencoding�read_string�SECHEAD�dict�items)�path�case_sensitive�ignore_bad_encoding�config�f�raws      r�loadr:s���
�
&�d�59�.3�5�5�5�F��!� �����
�$��
�
�	L���&�&�(�(�/�/�&�"=�"?�"?��K�K�C�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L����	L�	L�	L�	L���$��g�
.�
.�
.�	�!��&�&�(�(�C�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
���'�7�'�'�'�#�-�d��;�;�;�����W��-�-�.�.�.s#�:A>�>B�B�B=�=C�C)�'�"�val�returnc��|�t��r$|�t��r
|dd�S|S)zW
    Strips single or double quote char only if the quote present from both sides.
    ����)�
startswith�_QUOTES�endswith)r=s r�$_strip_escape_quotes_of_config_valuerE0s>���~�~�g����3�<�<��#8�#8���1�R�4�y���Jr�=c�f�i}t|ddd���5}|���D]m}|�|d��}	|\}}n#t$rY�+wxYw|���}|rt|��n|}|||���<�n	ddd��n#1swxYwY|S)Nr r!�surrogateescape)r#�errorsr@)r+�	readlines�split�
ValueError�striprE)	r4�	delimiter�strip_quotes�datar8�line�parts�key�values	         r�	load_fastrU9s��
�D�	
�d�C�'�2C�	D�	D�	D�&���K�K�M�M�	&�	&�D��J�J�y�!�,�,�E�
�"�
��U�U���
�
�
���
�����K�K�M�M�E� ��4�U�;�;�;��
�
!&�D��������	&�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&� �Ks6�-B&�A
�	B&�

A�B&�A�AB&�&B*�-B*c���	t|}nV#t$rI	t|��x}t|<n+#ttjf$r|s�ix}t|<YnwxYwYnwxYw|S)zD
    Read ini file once (cached) and return its content as dict
    )�cache�KeyErrorr:�IOErrorr'�Error)r4�
ignore_errors�ress   r�	load_oncer]Ps���#��D�k�����#�#�#�	#�!%�d���+�C�5��;�;����+�,�	#�	#�	#� �
�� "�"�C�%��+�+�+�	#������#�����Js/�
�
A#�5�A#�%A�A#�A�A#�"A#c	���|s|dz}g}t|dd���5}t|dd���5}|D]�}|���}|r}|�d��sh|�dd��\}}	|���}||vr7|�|�d||�d	���|�|����|�|����	ddd��n#1swxYwYddd��n#1swxYwYt|d
d���5}|D]'}||vr!|�|�d||�d	����(	ddd��n#1swxYwYt
j||��dS)Nz.tmpr r!r"�w�#rFr@�
�a)r+rMrBrK�write�append�os�rename)
�
settings_dictr4�tmp_path�	used_keys�fin�foutrQ�
stripped_linerS�_s
          r�change_settingsrn`su���!��&�=���I�
�t�S�7�
+�
+�
+��s�
�x��w�
/�
/�
/��37��		�		�D� �J�J�L�L�M��
�]�%=�%=�c�%B�%B�
�&�,�,�S�!�4�4���Q��i�i�k�k���-�'�'��J�J�#�>�>�
�c�(:�>�>�>�?�?�?��$�$�S�)�)�)���J�J�t�����		�������������������������������������
�h��g�	.�	.�	.�<�$� �	<�	<�C��)�#�#��
�
�c�:�:�M�#�$6�:�:�:�;�;�;��	<�<�<�<�<�<�<�<�<�<�<�<����<�<�<�<�
�I�h������sG�D�B.C*�D�*C.	�.D�1C.	�2D�D�D�+E�E�Ea
    (
      # Comments
      (:? \# .* $ )

      # Single-, double-quoted strings and bare strings without whitespaces
      | (:? "[^"\n]*?" )
      | (:? '[^'\n]*?' )
      | (:? [^"';\s\{\}]+ )

      # Structural characters
      | ;
      | \{
      | \}
      | \n
    )
    c�b�d�t�|��D��}d�|D��S)Nc3�nK�|]0}|�|�d���|�d��V��1dS)rN)�group)�.0�matchs  r�	<genexpr>z _ngx_tokenize.<locals>.<genexpr>�sZ����������[�[��^�^��
���A��������rc3�DK�|]}|�d���|V��dS)r`N)rB)rr�toks  rrtz _ngx_tokenize.<locals>.<genexpr>�s3����=�=�C�����)<�)<�=�C�=�=�=�=�=�=r)�_NGINX_TOKENS_RE�finditer)rP�tokenss  r�
_ngx_tokenizerz�sD����%�.�.�t�4�4����F�>�=�6�=�=�=�=rc#�*K�|D]
}||vrdS|V��dSrr)�itr=rvs   r�_ngx_take_untilr}�s:���������#�:�:��F�F��	�	�	�	�	�rc#�`K�d}|D]&}|dkr|dz
}n|dkr|dz}|dkrdS|V��'dS)Nr@�{�}r)r|�lvl�ts   r�_ngx_take_until_block_endr��se����
�C�
������8�8��1�H�C�C�
�#�X�X��1�H�C���7�7��F�F�������rc��i}|D]@}|dkrt|��D]}�||vr"t|d��}t|��||<�A|S)z5Scan a block for required fields, skips nested blocksrz;
)r�r}�list)�block_tokens�need_fields�inforvrm�value_tokenss      r�_ngx_scan_block_infor��sj��
�D��+�+���#�:�:�.�|�<�<�
�
����+���*�<��?�?�L��\�*�*�D��I���Krc#�zK�t|��}|D]�}|dkr�	t|d��D]}�t|��}t|d��}	|d}|d}n#t$rY�YwxYw|s|s�bt|d��t|d��d|�dg��vd	�V���d
S)aq
    Parse content of NGINX configuration in a manner tolerant to minor mistakes
    and extract relevant fields from all `server` directives.

    Relevant fields are:
    - `server_name`
    - `root` - returned as `document_root`
    - `ssl` - if `listen` field contains "ssl" word

    Doesn't handle interpolated values (ex. `${val}`) outside of quoted strings
    �serverr)�server_name�root�listenr�r�r�sslr�)r��
document_rootr�N)rzr}r�r�rXrE�get)rPryrvrmr�r�r�r�s        r�nginx_conf_loose_parserr��s�����4�
 �
 �F��
�
���(�?�?��
!���-�-�	�	�A��1��8�8��$�L�2S�T�T��	��}�-�K���<�D�D���	�	�	��H�	�����	�4�	��@��A��O�O�A�$�q�'�J�J��D�H�H�X�r�2�2�2�
�
�	
�	
�	
�	
�/
�
s�A!�!
A.�-A.c��tj�|��std|�����t	|��}tt
|����S)zGParse NGINX config file, see `nginx_conf_loose_parser` for more details�File does not exists )rer4�isfiler�&read_unicode_file_with_decode_fallbackr�r�)�	conf_file�
dirty_datas  r�nginx_conf_parserr��sT��
�7�>�>�)�$�$�D��B�y�B�B�C�C�C�7�	�B�B�J��'�
�3�3�4�4�4rc	��tj�|��std|�����g}t	|�����}d�|D��}d}d}i}g}t
|��dkr�|�d��}d|vr�|���d}	d}
	|	�d��\}}
|
�	d	d
��}
n#t$r|	}YnwxYw|�|��|�|
��d}��d|vr|||<|dz
}d}g}��|r|�|����t
|��dk��|���D�]�}dd
d
dt|d��dd
�}|D�]O}
d|
vrD|
���d����	dd
��|d<�Kd|
vrC|
���d����d��|d<��d|
vr=d�d�|
���dd�D����|d<��d|
vr/|
���d���|d<d|
vrE|
���d������dk|d<��Q|�|�����|S)Nr�c�<�g|]}tjd|���|��S)z^((?!#).)*$)�re�search)rr�is  r�
<listcomp>z&apache_conf_parser.<locals>.<listcomp>�s)��?�?�?�!�2�9�]�A�#>�#>�?�A�?�?�?rrFz<VirtualHostr@�0�:�>�Tz</VirtualHost>)�userr�r��server_alias�portr��
ServerNamezwww.r��DocumentRootr<r��ServerAlias�,c3�4K�|]}t|��V��dSr)r))rr�ns  rrtz%apache_conf_parser.<locals>.<genexpr>.s(����/Q�/Q�1��A���/Q�/Q�/Q�/Q�/Q�/Qrr��SuexecUserGroupr��	SSLEngine�onr�)rer4r�rr��
splitlines�len�poprKrrLrd�values�intrM�join�lower)r��	conf_data�data_allrP�ID�enable�result�vhost�out�ip_portr��iprTrQs              r�apache_conf_parserr��s*��
�7�>�>�)�$�$�D��B�y�B�B�C�C�C��I�5�i�@�@�K�K�M�M�H�?�?�x�?�?�?�D�	
�B�
�F�
�F��E�

�d�)�)�a�-�-��h�h�q�k�k���S� � ��i�i�k�k�!�n�G��D�
�"�=�=��-�-���D��|�|�C��,�,�����
�
�
�����
�����L�L������L�L������F���s�"�"��F�2�J���E�B��F��E���	��L�L������1�d�)�)�a�-�-�4��������� "�"$�!%��U�1�X����
����	F�	F�D��t�#�#�&*�j�j�l�l�1�o�&;�&;�&=�&=�&E�&E�f�b�&Q�&Q��]�#����%�%�(,�
�
���Q��(=�(=�(?�(?�(E�(E�c�(J�(J��_�%����$�$�'*�x�x�/Q�/Q��
�
���Q�R�R�@P�/Q�/Q�/Q�'Q�'Q��^�$�� �D�(�(�#�z�z�|�|�A��4�4�6�6��V���d�"�"�"�j�j�l�l�1�o�3�3�5�5�;�;�=�=��E��U������������s�2.C!�!C0�/C0�	PamLVECfg)�min_uid�cagefs_enabled�groupsc�Z�t|dd���5}|D]�}|�d��r�|���}t|��dkr�|ddkr�t|��dkrt	|d��nd	}t|��d
kr"tt	|d����nd}t|��dkr|d
�d
��ndg}t
|||��ccddd��S��	ddd��n#1swxYwYdS)aD
    Parse string like:
    "session      required      pam_lve.so      500      1     group1,group2"
    :param configfile: path to config file to parse
    :type configfile: str
    :return: PamLVECfg instance when pam_lve configuratiom is found, None otherwise
    :rtype: namedtuple
    :raises: IOError, ValueError
    r r!r"r`��z
pam_lve.so�i��F�r��wheelN)r+rBrKr�r��boolr�)�
configfiler8rQ�sr�r�r�s       r�parse_pam_lve_configr�<s���
�j�#��	0�	0�	0�
B�A��		B�		B�D����s�#�#�
���
�
���A��1�v�v��{�{�q��t�|�3�3�'*�1�v�v��{�{�#�a��d�)�)�)���47��F�F�a�K�K��c�!�A�$�i�i����U��,/��F�F�a�K�K��1����C����g�Y�� ��.�&�A�A�A�A�
B�
B�
B�
B�
B�
B�
B�
B��		B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B����
B�
B�
B�
B��4s�C2D �D � D$�'D$�	file_pathc�6�t|d��5}|���}ddd��n#1swxYwY	|���S#t$r<t	jtjd|�d���|�d���cYSwxYw)NrzFailed to decode "zL" content as utf-8 - loading with placeholders for invalid unicode sequencesr)rI)r+r,r-�UnicodeDecodeError�syslog�LOG_WARNING)r�r8�raw_datas   rr�r�Us���	
�i��	�	��!��6�6�8�8��������������������1���� � � ���1�1�1��
���x��x�x�x�	
�	
�	
����i��0�0�0�0�0�1���s�2�6�6�A�AB�B)FF)rFF)Fr)"r'r.rer�r��collectionsr�	Exceptionrrr1r:rCr)rErUrWr]rn�compile�
IGNORECASE�	MULTILINE�VERBOSErwrzr}r�r�r�r�r�r�r�r�rrr�<module>r�s������
�
�
�
�	�	�	�	�	�	�	�	�
�
�
�
�"�"�"�"�"�"������I����
�����y����
��
/�
/�
/�
/� ���c��c���������*	��
�
�
�
� ����6�2�:��"�M�B�L� �2�:�-�%���,>�>�>����	�	�	�
�
�
� (
�(
�(
�V5�5�5�F�F�F�R
�J�{�$K�$K�$K�L�L�	����2
1�c�
1�c�
1�
1�
1�
1�
1�
1r

Zerion Mini Shell 1.0