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੐)|#o0aڱ$I>}k&1`U#V?YsV x>{t1[I~D&(I$I/{H0fw"q"y%4 IXyE~M3 8XψL}qE$I[> nD?~sf ]o΁ cT6"?'_Ἣ $I>~.f|'!N?⟩0G KkXZE]ޡ;/&?k OۘH$IRۀwXӨ<7@PnS04aӶp.:@\IWQJ6sS%I$e5ڑv`3:x';wq_vpgHyXZ 3gЂ7{{EuԹn±}$I$8t;b|591nءQ"P6O5i }iR̈́%Q̄p!I䮢]O{H$IRϻ9s֧ a=`- aB\X0"+5"C1Hb?߮3x3&gşggl_hZ^,`5?ߎvĸ%̀M!OZC2#0x LJ0 Gw$I$I}<{Eb+y;iI,`ܚF:5ܛA8-O-|8K7s|#Z8a&><a&/VtbtLʌI$I$I$I$I$I$IRjDD%tEXtdate:create2022-05-31T04:40:26+00:00!Î%tEXtdate:modify2022-05-31T04:40:26+00:00|{2IENDB`Mini Shell

HOME


Mini Shell 1.0
DIR:/opt/imunify360/venv/lib64/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/clcommon/__pycache__/utils.cpython-311.pyc
�

Ӻh!y�
���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZddl
mZddlmZmZmZmZmZmZddlZddlZddlmZddlmZmZmZmZdZdZ d	Z!d
�Z"dMd�Z#d�Z$d
�Z%d�Z&d�Z'					dNd�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	dMd8e*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�ZSdL�ZTdS)O�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   �n/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/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
ttjf$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
tf$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
tf$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��YdS	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#tttf$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�Ac�`�	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>c�|�	tjtj����dS#t$rYdSwxYw)z'
    Get username of current user.
    rN)r�r�rrV�	ExceptionrWr>r#�get_usernamer��sD����|�B�I�K�K�(�(��+�+�������t�t����s�*-�
;�;rU)NFTFN)Urxr"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�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>