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__/utils.cpython-311.pyc

�

I/�fzx�
���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZddl
mZddlmZmZmZmZmZmZddlZddlZddlmZddlmZmZmZmZdZdZ d	Z!d
�Z"dLd�Z#d�Z$d
�Z%d�Z&d�Z'					dMd�Z(d�Z)dee*fd�Z+d�Z,de-fd�Z.dee*fd�Z/ed���dee*fd���Z0de1fd�Z2de*de-fd�Z3de-fd�Z4de-fd �Z5d!�Z6d"�Z7d#�Z8d$�Z9d%�Z:d&�Z;d'�Z<d(e*de-fd)�Z=d*e1de-fd+�Z>d,edee-fd-�Z?de1fd.�Z@d/e*dee-e-ffd0�ZAd/e*dee-e-ffd1�ZBd/e*dee-e-ffd2�ZCd3e*d4e-de-fd5�ZDd6eejejEfde*fd7�ZF	dLd8e*d9e*d:e*d;e1dee1e*ff
d<�ZGde*fd=�ZHde-fd>�ZId?e*dee1fd@�ZJd?e*fdA�ZKd?e*fdB�ZLdC�ZMdDe*de*fdE�ZNde-fdF�ZOdGe*de*fdH�ZPdeee*ee*ffdI�ZQde-fdJ�ZRde-fdK�ZSdS)N�N)�ConfigParser�Error)�	lru_cache)�Any�AnyStr�Dict�Optional�Tuple�Union)�etree)�ExternalProgramFailed�
check_command�exec_utility�run_commandz/etc/sysconfig/rhn/systemid)�Mon�Tue�Wed�Thu�Fri�Sat�Sunz /opt/cloudlinux/litespeed_statusc��d}tj�|��r&	tj|��}n#t$rYnwxYw||kr=	tj|��n#t$rYnwxYwtj||��dSdS)a
    Create symlink link_path -> link_value if it does not exist or
    points to different location
    :param link_value: path that symlink should point to (symlink value)
    :type link_value: str
    :param link_path: path where to create symlink
    :type link_path: str
    N)�os�path�islink�readlink�OSError�unlink�symlink)�
link_value�	link_path�link_tos   ��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.11-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/utils.py�create_symlinkr$/s����G�	�w�~�~�i� � ��	��k�)�,�,�G�G���	�	�	��D�	�����W���	��I�i� � � � ���	�	�	��D�	����
�
�:�y�)�)�)�)�)��s!�8�
A�A�A$�$
A1�0A1c���g}tj�|��r?t|dd|���5}|���}ddd��n#1swxYwY|S)a
    Read file and return file's lines
    errors param may be passed to define how handle
    unicode errors, errors=None is default value of open()
    :param path: path to file
    :param unicode_errors_handle: how to handle unicode errors
    :return: list of file's lines
    �r�utf-8)�encoding�errorsN)rr�isfile�open�	readlines)r�unicode_errors_handle�content�fs    r#�get_file_linesr0Fs����G�	�w�~�~�d���$�
�$��g�6K�
L�
L�
L�	$�PQ��k�k�m�m�G�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��Ns�A�A�Ac��t||d���5}|�|��ddd��dS#1swxYwYdS)z�
    Write lines to file
    :param content: list of lines for writing to file
    :param path: path to file
    :param mode: open mode
    :return: None
    r'�r(N)r+�
writelines)rr.�moder/s    r#�write_file_linesr5Ws���
�d�D�7�	+�	+�	+��q�	���W������������������������s�6�:�:c���t|��}�fd�|D��}t|��t|��k}t||d��|S)a
    Delete line from file. Return True when line(s) have been deleted, False otherwise (specified line is not found)
    :param path: path to file
    :type path: string
    :param line: line to delete without EOL ('
')
    :type line: string
    :rtype bool
    c�F��g|]}�|�d��k�|��S)�
)�rstrip)�.0�item�lines  �r#�
<listcomp>z)delete_line_from_file.<locals>.<listcomp>ns/���O�O�O�t�T�T�[�[��=N�=N�5N�5N�d�5N�5N�5N��w+)r0�lenr5)rr<�
file_lines�out_file_lines�founds `   r#�delete_line_from_filerDdsZ��� ��%�%�J�O�O�O�O�z�O�O�O�N��
�O�O�s�>�2�2�2�E��T�>�4�0�0�0��Lr>c�L�tj��}|dkr�	tjd��j}|tj��vstj��|krdSn#t$rYnwxYwtdtj
���tjd��dSdS)zH
    Check whether current user is effectively root and exit if not
    r�
clsupergidNz'Error: root privileges required. Abort.)�file���)r�geteuid�grp�getgrnam�gr_gid�	getgroups�getegid�KeyError�print�sys�stderr�exit)�euidrLs  r#�is_root_or_exitrUus����:�<�<�D��q�y�y�	��\�,�/�/�6�F������'�'�2�:�<�<�6�+A�+A���,B���	�	�	��D�	����
�7�c�j�I�I�I�I����������ys�AA#�#
A0�/A0c�@�tj�d��S)zV
    Detects is EA4 installed
    :return: True - EA4 present; False - EA4 absent
    z/etc/cpanel/ea4/is_ea4)rrr*�r>r#�is_ea4rX�s��
�7�>�>�2�3�3�3r>FTc#�pK�|�t|��}d}|s1|�d��s|sd|��}tj|��}nd}|D]`}|r6|r|�|��dkr|}n/|�|��r|}n|�|��r|}|r|�|V�n|�nd}�a|�|V�dSdS)a
    Grep pattern in file
    :param multiple_search: if True - search all match,
                            False - search first match
    :param pattern: pattern for search
    :param path: path to file
    :param data_from_file: read data from file for parsing
    :param fixed_string: if True - search only fixed string,
           False - search by regexp
    :param match_any_position: if True - search any match position,
           False - search only from string begin
    :return: Generator with matched strings
    N�^rH)r0�
startswith�re�compile�find�search)	�patternr�fixed_string�match_any_position�multiple_search�data_from_file�result�pattern_compr<s	         r#�greprg�s����*��'��-�-��
�F����!�!�#�&�&�	$�/A�	$�#�'�m�m�G��z�'�*�*������
�
���	�!�
�d�i�i��&8�&8�B�&>�&>��������)�)�
�����"�"�4�(�(�
����	�v�1��L�L�L�L�
�
��E����
���������r>c�4�tjt��S)z-
    :rtype: lxml.etree._ElementTree obj
    )r�parse�RHN_SYSTEMID_FILErWr>r#�_parse_systemid_filerk�s���;�(�)�)�)r>�returnc�(�	t��}|�d��D]B}|�d��j|kr"|�d��djcS�Cn)#tt
ttjf$rYdSwxYwdS)z`
    find a member in xml by name and return value
    :type name: str
    :rtype: str|None
    �member�name�valuerN)	rk�iterr^�text�IOError�
IndexErrorrOr�
ParseError)ro�rhn_systemid_xmlrns   r#�get_rhn_systemid_valuerw�s����/�1�1��&�+�+�H�5�5�	4�	4�F��{�{�6�"�"�'�4�/�/��{�{�7�+�+�A�.�3�3�3�3�0�	4��
�Z��5�+;�<�����t�t������4s�A$A)�'A)�)"B�Bc��dd|�d�d�}tj�|��s|S	tjd|�d�gddd�	�����}tjd
|�d�gddd�	�����}d|d<||d
<n/#tjtf$r}d|�d|�d�|d
<Yd}~nd}~wwxYw|S)aZ
    This function is written for detect file system in which file is stored on.
    E.g., the file can be stored in NFS and this can affect the normal operation of the file.
    We want to receive information about FS in emergency situations during reading or writing
    :param file_path: path to file, for which we want to detect file system
    :return: dict, which contains two keys:
            key 'success' can be equals to False if we got error or True if we got normal result
            key 'details' can contais error string if key 'success' is False or result if key 'success' is True
    FzFile "z" isn't exists)�success�detailszdf z  | tail -n 1 | awk '{print $NF}'T�	/bin/bash��shell�
executablerrzmount | grep "on z type"ryrzz#We can't get file system for file "z". Exception "�"N)rr�exists�
subprocess�check_output�strip�CalledProcessErrorr)�	file_pathre�mount_point�data�errs     r#�*get_file_system_in_which_file_is_stored_onr��s<���6�I�6�6�6���F��7�>�>�)�$�$���
�c� �-�
@�9�
@�
@�
@�A��"��	
�
�
�
�%�'�'�	��&�
4��
4�
4�
4�5��"��	
�
�
�
�%�'�'�	
�!��y�� ��y�����)�7�3�c�c�c�b�9�b�b�\_�b�b�b��y�����������c�����Ms�A(B�C�+B<�<Cc��tdd���}	|�d��|�dd��}n#t$rd}YnwxYw|S)z�
    Checks if testing is enabled in /etc/yum.repos.d/cloudlinux.repo config
    :return: bool value if testing enabled or not
    NF)�
interpolation�strictz /etc/yum.repos.d/cloudlinux.repozcloudlinux-updates-testing�enabled)r�read�
getbooleanr)�parser�ress  r#�is_testing_enabled_repor�so��
��U�
;�
;�
;�F�����6�7�7�7���� <�i�H�H�����������������Js�+?�A�
Ac��t��rdSddddddd�}tj��}|���D]\}}|r||vr|cS�t	d��}d	}|�d	}nd
|vrd}nd|vrd}n
d|vrd}nd
|vrd}|S)a
    Returns cl version taking into account release version
    E.g: release =
        2.6.32-896.16.1.lve1.4.54.el6.x86_64
        5.14.0-162.6.1.el9_1.x86_64
    el6 = cl6
    el8 = cl8
    ........
    ubuntu+cl_extesions = cl8
    :return appropriate version string
    �cl8�cl6�cl6h�cl7�cl7h�cl9)zel6.zel6h.zel7.zel7h.zel8.z.el9�
os_releaseN�6�7�8�9)�	is_ubuntu�platform�release�itemsrw)�check_vals_decoderr��	check_val�
cl_version�ret_vals     r#�get_cl_versionr�s����{�{���u�������
���&�-�/�/�G�!3�!9�!9�!;�!;����	�:��	�y�G�+�+������$�\�2�2�G��G������	�������	�������	�������	�������Nr>)�maxsizec���	tdg�����}n#tjtf$rYdSwxYw|dkr|�dd���dSdS)	a�
    Returns virtualization type on current system.
    It is reachable via virt-what utility.
    E.g.: 'kvm', 'bhyve', 'openvz', 'qemu'
    All acceptable outputs are listed here:
    https://people.redhat.com/~rjones/virt-what/virt-what.txt

    Output will be returned with at least two rows
    Sample:
        > kvm
        >
    Furthermore, there is a possibility for multiple text rows
    Sample:
        > xen
        > xen-domU
    That's why, the result will be taken from a first row.
    If the output is empty, and there were no errors, the machine
    is either non-virtual, or virt-what tool isn't familiar with it's
    hypervisor. But the list of supported hypervisors and containers
    covers all popular VMs types.

    :return: virt_type - Optional[AnyStr]
        - appropriate virtualization type string,
        - 'physical' if there is no virtualization,
        - None if there was an error
    z/usr/sbin/virt-whatN�r8�)�maxsplitr�physical)rr�r�r��FileNotFoundError�split)�virt_what_outputs r#�
get_virt_typer�9s���8�&�(=�'>�?�?�E�E�G�G�����)�+<�=�����t�t������2����%�%�d�Q�%�7�7��:�:��zs�"%�?�?�pidc�T�	tj|d��dS#t$rYdSwxYw)z�
    Checks for a process existence by os.kill command
    If os.kill will be used as os.kill(pid, 0), it will
    just check for a presence of such PID

    And if such pid can't be reached with kill method,
    there will be raised OSError
    rTF)r�killr)r�s r#�	check_pidr�`sA���
���Q�����t�������u�u����s��
'�'�
pid_file_pathc�R�tj�|��r�t|d���5}	t	t|����������cddd��S#t$rYnwxYw	ddd��n#1swxYwYdS)z�Check if process running using pid file
    Arguments:
        pid_file_path: path to the pid file of service

    Returns:
        bool: True or False
    r'r2NF)	rrr*r+r��intr�r��
ValueError)r�r/s  r#�is_process_runningr�qs���
�w�~�~�m�$�$��
�-�'�
2�
2�
2�	�a�
� ��Q�V�V�X�X�^�^�%5�%5�!6�!6�7�7�	�	�	�	�	�	�	�	���
�
�
���
�����		�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�5s.�B�?A?�?
B�	B�B�B�B �#B c�R�tj��dkrd}t|��Stj�t
��sdSt
t
d���5}|������}ddd��n#1swxYwY|dkS)a
    Detects that server works under Litespeed.
    Note: be careful when modifying this method.
    It is used in X-Ray, ask @dkavchuk or someone else from C-Projects team
    for details.
    return: True - LS working; False - LS not running (stopped or absent)
    rz/tmp/lshttpd/lshttpd.pidFr'r2N�0)	rrIr�rr��LITESPEED_STATUS_FOR_USERSr+r�r�)r�r/�statuss   r#�is_litespeed_runningr��s���
�z�|�|�q���2�
�!�-�0�0�0��w�~�~�8�9�9�	!��5��0�7�C�C�C�
*�q��������)�)��
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��S�=� s�%'B�B�Bc�$�d}t|��S)zHCheck if nginx is running

    Returns:
        Bool: True or False
    z/run/nginx.pid)r�)r�s r#�is_nginx_runningr��s��%�M��m�,�,�,r>c�&�t��rdSdS)zU
    Return proper passenger package according to apache version
    :rtype: str
    zapache24-passengerzalt-mod-passenger)rXrWr>r#�get_passenger_package_namer��s��
�x�x�$�$�#��r>c��	t��rtdd|g��ntdd|g��n#t$rYdSwxYwdS)z_
    Checks that package installed on server
    :param package_name: str
    :rtype: bool
    �dpkgz-s�rpmz-qFT)r�rr
)�package_names r#�is_package_installedr��sh����;�;�	5����|�4�5�5�5�5����l�3�4�4�4��� �����u�u������4s�36�
A�Ac�V�t��rt��St��S)z�
    Pick the package manager to check depending on the OS.
    If we're not on Ubuntu, assume a CL variant with RPM.

    :return: Error string, if any, None otherwise.
    )r��get_apt_db_errors�get_rpm_db_errorsrWr>r#�get_package_db_errorsr��s(���{�{�#� �"�"�"� �"�"�"r>c�b�	tjddgdtjtjd���5}|���\}}|jdkrd|�d|�d	�cd
d
d
��S	d
d
d
��n#1swxYwYn-#t
tf$r}t|��cYd
}~Sd
}~wwxYwd
S)z�
    Check the dpkg DB as described in https://man7.org/linux/man-pages/man1/dpkg.1.html
    See `--audit`.

    :return: Error string, if any, None otherwise.
    r�z--auditFT)r}�stdoutrRrrrzdpkg audit error: r8�.N�r��Popen�PIPE�communicate�
returncoderrs�str)�proc�std_out�std_errr�s    r#r�r��sM���
�
�
�Y����?��?��
�
�
�	B��#�/�/�1�1��G�W���!�#�#�A�G�A�A�w�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���
�W������3�x�x����������������4sF�/B�+A6�B�*B�6A:�:B�=A:�>B�B,�B'�!B,�'B,c�h�d}	tjgd�tjtjd���5}|���\}}|jdkrd|�d|�d|��cd	d	d	��S	d	d	d	��n#1swxYwYn-#t
tf$r}t|��cYd	}~Sd	}~wwxYwd	S)
zx
    Check RPM DB consistency.

    :return: None - No RPM DB errors
            string_message - Error description
    zjhttps://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library)z/bin/rpmz--dbpathz/var/lib/rpmz
--verifydbT)r�rRrrrzRPM DB check error: r8z.
See doc: Nr�)�doc_linkr�r�r�r�s     r#r�r��s[��	D�
��
�
�B�B�B��?��?��	
�
�
�		Y�
�#�/�/�1�1��G�W���!�#�#�X�g�X�X��X�X�h�X�X�		Y�		Y�		Y�		Y�		Y�		Y�		Y�		Y�$�		Y�		Y�		Y�		Y�		Y�		Y�		Y�		Y�		Y�		Y�		Y����		Y�		Y�		Y�		Y���
�W������3�x�x����������������4sF�.B�-A9�B�-B�9A=�=B�A=�B�B/�B*�$B/�*B/c�z�tj��t_tj��t_dS)a(
    Upon process exit, Sentry sometimes prints:

        Sentry is attempting to send 1 pending error messages
        Waiting up to 10 seconds
        Press Ctrl-C to quit

    This causes broken JSON in output.
    See also this issue: https://github.com/getsentry/raven-python/issues/904
    N)�io�StringIOrQr�rRrWr>r#�!silence_stdout_until_process_exitr�s"������C�J�����C�J�J�Jr>c��d|dzz
}tj|��5tj||��ddd��dS#1swxYwYdS)a
    Create directories with desired permissions

    Changed in version 3.7: The mode argument no longer affects
    the file permission bits of newly-created intermediate-level directories.
    Because it we use umask while creating dirs

    :param mod: desired permissions
    i�N)�secureio�	set_umaskr�makedirs)r�mod�inverted_mods   r#�mod_makedirsr�s����C�%�K�(�L�	�	�L�	)�	)���
��D�#������������������������s�A�A�A�usernamec�T�	tj|��n#t$rYdSwxYwdS)z,
    Check user existence in the system
    FT)�pwd�getpwnamrO)r�s r#�is_user_presentr� sA�����X�����������u�u������4���
%�%�uidc�T�	tj|��n#t$rYdSwxYwdS)z+
    Check uid existence in the system
    FT)r��getpwuidrO)r�s r#�is_uid_presentr�+sA�����S�����������u�u������4r�rc��	tj|��j}n#ttt
f$rYdSwxYwt
j|��}|S)z+
    Check that file by path is socket
    N)r�lstat�st_moder�rsr�stat�S_ISSOCK)rr4�	is_sockets   r#�is_socket_filer�6sW����x��~�~�%�����w��0�����t�t������
�d�#�#�I��s��7�7c��tjdddd���}|������d}|dkrdnt	|��}|S)z?
    Get number of system run level by command `runlevel`.
    z/sbin/runlevelTr{r|r��S)r�r�r�r�r�)�outputre�levels   r#�get_system_runlevelr�Csc��
�
$����
�	���F��\�\�^�^�
!�
!�
#�
#�A�
&�F��3���A�A�C��K�K�E��Lr>�service_namec��t��}	tjd|��ddd���}n#tjtf$rYdSwxYw|������}|dd�D]V}|����d��}|dd	k}t|d
��}||krd|fcS�WdS)z�
    Returns state of a service (present and enabled) for init.d system.
    Returns False, False if a service doesn't exist
    Returns True, False if a service exists and it's not enabled
    Returns True, True if a service exists and it's enabled
    zLANG=C /sbin/chkconfig --list Tr{r|�FFr�N�:�onr�TF)r�r�r�r�r�r�r�r�)r��runlevelr��output_list�
state_info�
state_list�	is_active�state_runlevels        r#�#_get_service_state_on_init_d_systemrVs��#�$�$�H���(�;�\�;�;��"��
�
�
����
�)�+<�>�����|�|������,�,�.�.�&�&�(�(�K�!�!�"�"�o�#�#�
��%�%�'�'�-�-�c�2�2�
��q�M�T�)�	��Z��]�+�+���~�%�%���?�"�"�"�&��;s�,�A�Ac��	tjd|�d�dd���dS#tjtf$r�	tjdd|gtjtj�	��5}|���|jd
vr	ddd��YdS	ddd��Yd
S#1swxYwYYdS#tjtf$rYYd
SwxYwwxYw)z�
    Returns state of service (present and enabled) for systemd system
    Returns False, False if a service doesn't exist
    Returns True, False if a service exists and it's not enabled
    Returns True, True if a service exists and it's enabled
    z/usr/bin/systemctl is-enabled z
 &> /dev/nullTr{)r}r~)TTz/usr/bin/systemctlr�)rRr�)r�Nrr�)r��
check_callr�r�r��DEVNULLr�r�)r�r�s  r#�$_get_service_state_on_systemd_systemr
xs��� ���
I�\�H�H�H��"�	
�	
�	
�	
��z���)�+<�>� � � �	 ��!�(�� ��
"�)�!�)����
(��� � �"�"�"��?�f�,�,�&�
(�
(�
(�
(�
(�
(�
(�
(�
(� (�!
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�
(�
(�
(��"�-�/@�B�	 �	 �	 ��<�<�<�	 ����' ���sV��C
�.B.�$B �B.�B �B.� B$	�$B.�'B$	�(B.�.C	�C
�C	�	C
c��t��}|rd|vrt|���\}}nt|���\}}||fS)zc
    Returns state of service (present and enabled)
    :param service_name: name of a service
    r�)r�)r�rr
)r��cl_ver�
is_present�
is_enableds    r#�service_is_enabled_and_presentr�si��
�
�
�F�
�
�%�6�/�/�!D�%�"
�"
�"
��
�J�J�"F�%�"
�"
�"
��
�J��z�!�!r>�process_file_path�strict_matchc�V�tj�|��std|�d����t	jdg��D]`}	|s||���vs-|r.|d�|�����krdS�L#tj$rY�]wxYwdS)a�
    Check that a file in path is running.
    You can get false-postive if parameter `strict_match` == False, process is
    not running, but someone on server open file by path `process_file_path`
    in an editor
    :param process_file_path: path to a file which is run
    :param strict_match: we use parameter `process_file_path` as full cmd line
                         with args for comparing if `strict_match` == True.
    :return: True if it's running, False - is not,
    zProcess file in path "�" does not exist�cmdline� TF)	rrr�r��psutil�process_iterr�join�
NoSuchProcess)rr�processs   r#�process_is_runningr�s����7�>�>�+�,�,�
��H�%6�H�H�H�
�
�	
��&�	�{�3�3����
	� �
�%����):�):�:�:��;�&����'�/�/�2C�2C�)D�)D�D�D��t�t����#�	�	�	��H�	�����5s�AB�B&�%B&�dtc���t|tjtjf��stdt	|�������t
|���S)z�
    Getting string representation of weekday from datetime.datetime or datetime.date.
    Returns shortened version of weekday from WEEK_DAYS.
    zFRequire object of type datetime.datetime or datetime.date, but passed )�
isinstance�datetime�date�	TypeError�type�	WEEK_DAYS�weekday)rs r#�get_weekdayr(�s\��

�r�H�-�x�}�=�>�>�
��_�UY�Z\�U]�U]�_�_�
�
�	
��R�Z�Z�\�\�"�"r>�config_path�apache_module_name�
param_name�defaultc���d|�d�}g}t|��}d}|D]@}|���}||krd}�|r|dkrn|r|�|���Att	�dd|�����}	�fd�|	D��}
|
s|�|d	fS|
s|�
d
d|�d|��fS|
d
�d��}t
|d
��}|d	fS)a
    Helper to parse httpd config for details about mpm module used
    :param config_path: path for configuration file with modules
    :param apache_module_name: expected mpm module. Can be `event`,
        `worker`, `prefork`
    :param param_name: name of parameter to find
    :param default: default value for parameter, if there won't be record
    :return: tuple with param value and text result of operation

    Example of config file content:
    <IfModule mpm_prefork_module>
    .................
        MaxRequestWorkers   450
    </IfModule>
    --
    <IfModule mpm_worker_module>
    .................
        MaxRequestWorkers      300
    </IfModule>
    --
    <IfModule mpm_event_module>
    .................
        MaxRequestWorkers     2048
    </IfModule>
    z<IfModule mpm_z_module>FTz</IfModule>)rcrardc���g|]=}|��������)|�����>SrW)r�r[)r:�	directiver+s  �r#r=z/find_module_param_in_config.<locals>.<listcomp>sQ��������?�?���'�'�
�3�3���������r>N�OKrz.MaxRequestWorkers directive not found for mpm_z_module module in rHr)r0r��append�listrgr�r�)
r)r*r+r,�if_module_line�
section_lines�	mpm_lines�is_section_foundr<�grep_result_list�mrw_list�parts�max_request_workerss
  `          r#�find_module_param_in_configr;�su���>C�&8�B�B�B�N��M��{�+�+�I����	'�	'���z�z�|�|���>�!�!�#����	��
� 5� 5��E��	'�� � ��&�&�&����� ��(�		
�	
�	
��������)����H��	
��+���}��
�
�'�/�
�
G�%�
G�
G�9D�
G�
G�
�	
�
�R�L���s�#�#�E��e�B�i�.�.����$�$r>c�^�d}tj�|��sdS	t|dd���5}|������}ddd��n#1swxYwY|�dd��\}}n#tttf$rYdSwxYw|S)	zp
    Return kmodlve module's version.
    Content of '/sys/module/kmodlve/version' looks like '2.0-30.el8'.
    z/sys/module/kmodlve/versionr�r&r'r2Nr�r�)
rrr*r+r�r��rsplitrrsr�)�kmodlve_module_file_pathr/�module�module_version�_s     r#�get_kmodlve_module_versionrB(s���
 =��
�7�>�>�2�3�3���r��
�*�C�'�
B�
B�
B�	&�a��V�V�X�X�^�^�%�%�F�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�"�M�M�#�q�1�1�������W�j�)�����r�r������s4�B�'A*�B�*A.�.B�1A.�2B�B*�)B*c�r�ddi}t��}||vrdS||}t��}||krdSdS)a
    Find out if system has version of the kernel
    (according to kmodlve module's version)
    where fs.proc_can_see_other_uid and hidepid options are synchronized.
    They are only synchronized if kmodlve module's version
    is equal to version in synced_kmodlve_versions.
    r�z2.0-30FT)r�rB)�synced_kmodlve_versionsr��synced_version�current_versions    r#�)proc_can_see_other_uid_and_hidepid_syncedrG9sU�� %�h�/���!�!�J��0�0�0��u�,�Z�8�N�0�2�2�O��.�(�(��t��5r>�pid_filenamec�,�	t|dd���5}t|��������}t	j|d��ddd��n#1swxYwYn#tttf$rd}YnwxYw|S)z�
    Detrmines working daemon process pid
    :param pid_filename: PID filename
    :return: PID from file or None if error (file not found, etc)
    r&r'r2rN)	r+r�r�r�rr�rrsr�)rH�pfr�s   r#�get_process_pidrKLs����
�,��g�
6�
6�
6�	�"��b�g�g�i�i�o�o�'�'�(�(�C��G�C��O�O�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	���
�W�j�)�������������Js5�A5�A	A)�A5�)A-�-A5�0A-�1A5�5B�Bc��t|dd���5}|�tj�����ddd��dS#1swxYwYdS)z
    Writes pid file
    r?r'r2N)r+�writer�getpid)rHrJs  r#�write_pid_filerO\s���
�l�D�7�	3�	3�	3�#�r�
���B�I�K�K�!�"�"�"�#�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�#�#s�(A�A�Ac�`�	tj|��dS#ttf$rYdSwxYw)z
    Remove PID file
    N)r�removerrs)rHs r#�remove_pid_filerRdsD��
�
�	�,��������W��
�
�
����
���s��-�-c������fd�}|S)a
    Set user's real uid and gid to specified ones.
    Checking equality of real and effective uids is needed
    because this function may be used by root
    with effective uid dropped to user's uid.
    In that case it is needed to set effective uid back to 0 first.
    c����tj��}tj��}||krtj|��tj���tj���dS�N)r�getuidrI�seteuid�setgid�setuid)�real_uid�eff_uid�gidr�s  ��r#�funczdemote.<locals>.funcwsR����9�;�;���*�,�,���w����J�x� � � �
�	�#����
�	�#�����r>rW)r�r\r]s`` r#�demoter^ns)�����������Kr>�dirpathc�L�tj�|��std|�d����dd|g}t	|��}	|�d��d}|�d��d}n%#t$r}td	|����|�d
}~wwxYw|S)zK
    Get mount point for dirpath directory from output of `df` utility
    zDirectory "rz/bin/dfz-hr8r�rrHz)Utility "df" returned unexpected output:
N)rr�isdirrrr�rt)r_�fs_info_cmd�fs_info�mountpoint_info�
mounted_on�es      r#�get_mount_pointrg�s����7�=�=��!�!�?��=�G�=�=�=�>�>�>��d�G�,�K��+�&�&�G�
U�!�-�-��-�-�a�0��$�*�*�3�/�/��3�
�
���U�U�U��L�7�L�L�M�M�ST�T�����U�����s�6A?�?
B!�	B�B!c��d}tj�|��st��dkSt	|d���5}t|�����}|dkcddd��S#1swxYwYdS)z�
    Detect if 'may_detach_mounts' kernel option is enabled.
    More info on the option: https://cloudlinux.atlassian.net/browse/KMODLVE-512
    z/proc/sys/fs/may_detach_mountsr�r'r2r�N)rrr*r�r+r�r�)�may_detach_mounts_filer/�vals   r#�is_may_detach_mounts_enabledrk�s���
>��
�7�>�>�0�1�1�)����5�(�(�	
�$�w�	7�	7�	7��1��!�&�&�(�(�m�m���a�x���������������������s�'A9�9A=�A=�devicec�^�tj��}|D]}|j|kr	|jcS�dS)z;
    Return the file system type for the given device.
    r�)r�disk_partitionsrl�fstype)rl�
partitions�	partitions   r#�get_filesystem_typerr�sH���'�)�)�J��$�$�	���v�%�%��#�#�#�#�&�
�2r>c���	d}d}tj��}t|d���5}|�d|�d�|���z��ddd��n#1swxYwY|�|d���d	��}|�|d
���d	��}||fS#tttj	f$rYnwxYwdS)zM
    Detect system name and version
    :return: tuple (os_name, os_ver)
    z/etc/os-release�topr'r2�[z]
N�NAMEr�
VERSION_ID)NN)
�configparserrr+�read_stringr��getr�rrsr)�os_release_filename�section_name�config�stream�os_name�os_vers      r#�get_os_versionr��s>��
�/�����*�,�,��
�%��
8�
8�
8�	F�F����4�<�4�4�4�v�{�{�}�}�D�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F��*�*�\�6�2�2�8�8��=�=�����L�,�7�7�=�=�c�B�B��������W�l�0�1�
�
�
���
�����:s5�(C�/A%�C�%A)�)C�,A)�-AC�C%�$C%c�0�t��\}}|dkS)zL
    Detertmines is this system Ubuntu
    :return: bool flag is_ubuntu
    �Ubuntu)r�)rrAs  r#r�r��s��
 �!�!�J�G�Q��h��r>c��d}tj�d��r1tjdddtjtj���dk}|S)z]
    Determines if secure boot is turned on
    :return: bool flag is_secureboot_enabled
    Fz/sys/firmware/efiz!mokutil --sb-state | grep enabledTr{)r}r~r�rRr)rrr�r��callr)r�s r#�is_secureboot_enabledr��s]��
�G�	�w�~�~�)�*�*�]��/�"E�(,��)3�);�J�DV�X�X�X�[\�]���Nr>rU)NFTFN)Trxr"rJr�rr�r�r\r�r�rQrr�	functoolsr�typingrrrr	r
rrr��lxmlr�clcommon.utils_cmdr
rrrrjr&r�r$r0r5rDrUrXrgrkr�rwr��boolr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr
rrr#r(r;rBrGrKrOrRr^rgrkrrr�r�r�rWr>r#�<module>r�s����������
�
�
�
�	�	�	�	�	�	�	�	�����
�
�
�
�	�	�	�	���������
�
�
�
�,�,�,�,�,�,�,�,�������<�<�<�<�<�<�<�<�<�<�<�<�<�<�<�<�
�
�
�
�����������������������2��=�	�?��*�*�*�.����"
�
�
����"���$4�4�4������
/�/�/�/�d*�*�*�
�H�S�M�
�
�
�
� %�%�%�P������'���
�'�'�'�'�T��4����#�x��}�#�#�#���#�L�3�����"�c��d�����"!�d�!�!�!�!�(-�$�-�-�-�-����
�
�
� 
#�
#�
#����4���8�������c��d�������������
��
�H�T�N�
�
�
�
��S�����&�c��e�D�$�J�>O�����D$ �s�$ �u�T�4�Z�?P�$ �$ �$ �$ �N"��"��t�T�z�9J�"�"�"�"�"�#��T��t�����<	#�E�(�+�X�]�:�;�	#��	#�	#�	#�	#� �	K%�K%��K%��K%��K%��	K%�
�3��8�_�K%�K%�K%�K%�\�C�����"�4�����&
�#�
�(�3�-�
�
�
�
� #��#�#�#�#�
�#�
�
�
�
����,�S��S�����,
�d�
�
�
�
� ����������h�s�m�X�c�]�:�;�����4�4�����
�t�
�
�
�
�
�
r>

Zerion Mini Shell 1.0