$54 GRAYBYTE WORDPRESS FILE MANAGER $64

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.216.174
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/

HOME
Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__//utils.cpython-311.opt-1.pyc
�

"h�i��
���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZddl
mZddlmZmZmZmZmZmZddlZddlZddlmZddlmZmZmZmZdZdZ d	Z!d
Z"dZ#d�Z$dRd
�Z%d�Z&d�Z'd�Z(d�Z)					dSd�Z*d�Z+dee,fd�Z-d�Z.de/fd�Z0de,dzfd�Z1de,dzfd�Z2edee,fd���Z3de4fd�Z5de,de/fd �Z6de/fd!�Z7de/fd"�Z8de/fd#�Z9d$�Z:d%e,de/fd&�Z;d'�Z<d(�Z=d)�Z>d*�Z?d+�Z@d,e,de/fd-�ZAd.e4de/fd/�ZBd0edee/fd1�ZCde4fd2�ZDd3e,dee/e/ffd4�ZEd3e,dee/e/ffd5�ZFd3e,dee/e/ffd6�ZGd7e,d8e/de/fd9�ZHd:eejejIfde,fd;�ZJ	dRd<e,d=e,d>e,d?e4dee4e,ff
d@�ZKde,fdA�ZLde/fdB�ZMdCe,dee4fdD�ZNdCe,fdE�ZOdCe,fdF�ZPdG�ZQdHe,de,fdI�ZRde/fdJ�ZSdKe,de,fdL�ZTdeUe,dze,dzffdM�ZVde/fdN�ZWde/fdO�ZXdP�ZYdQ�ZZdS)T�N)�ConfigParser�Error)�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_statusz/opt/cloudlinux/nginx_statusz/opt/apache2nginx/statec��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.35-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/utils.py�create_symlinkr$1s����G�	�w�~�~�i� � ��	��k�)�,�,�G�G���	�	�	��D�	�����W���	��I�i� � � � ���	�	�	��D�	����
�
�:�y�)�)�)�)�)��s!�8�
A�A�A$�$
A1�0A1c���g}tj�|��r>t|d|���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
    �utf-8)�encoding�errorsN)rr�isfile�open�	readlines)r�unicode_errors_handle�content�fs    r#�get_file_linesr/Hs����G�	�w�~�~�d���$�
�$��1F�
G�
G�
G�	$�1��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_linesr4Xs���
�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 ('\n')
    :type line: string
    :rtype bool
    c�F��g|]}�|�d��k�|��S)�
)�rstrip)�.0�item�lines  �r#�
<listcomp>z)delete_line_from_file.<locals>.<listcomp>ps/���O�O�O�t�T�T�[�[��=N�=N�5N�5N�d�5N�5N�5N��w+)r/�lenr4)rr;�
file_lines�out_file_lines�founds `   r#�delete_line_from_filerCdsZ��� ��%�%�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)�euidrKs  r#�is_root_or_exitrTws����:�<�<�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)z^
    Detect whether EA4 is installed.
    :return: True - EA4 present; False - EA4 absent
    z/etc/cpanel/ea4/is_ea4)rrr)�r=r#�is_ea4rW�s��
�7�>�>�2�3�3�3r=FTc#�jK�|�t|��}d}|s1|�d��s|sd|��}tj|��}nd}|D]]}|r3|r|�|��dks|�|��r|}n|�|��r|}|r|�|V�n|�nd}�^|�|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�^rG)r/�
startswith�re�compile�find�search)	�patternr�fixed_string�match_any_position�multiple_search�data_from_file�result�pattern_compr;s	         r#�greprf�s����*��'��-�-��
�F����!�!�#�&�&�	$�/A�	$�#�'�m�m�G��z�'�*�*������
�
���	�"�
�t�y�y��'9�'9�R�'?�'?�D�O�O�T[�D\�D\�'?����
�
 �
 ��
&�
&�	��F��	�v�1��L�L�L�L�
�
��E����
���������r=c�4�tjt��S)z-
    :rtype: lxml.etree._ElementTree obj
    )r�parse�RHN_SYSTEMID_FILErVr=r#�_parse_systemid_filerj�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)	rj�iterr]�textr�
IndexErrorrNr�
ParseError)rn�rhn_systemid_xmlrms   r#�get_rhn_systemid_valueru�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)aG
    Detect the file system on which a given file is stored.

    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�
executablerqzmount | grep "on z type"rwrxz#We can't get file system for file "z". Exception "�"N)rr�exists�
subprocess�check_output�strip�CalledProcessErrorr)�	file_pathrd�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�
    Check 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��ddd�}td��}|r||vr||St��d}|r |�d��d}d|��Sd	S)
ax
    Return the CloudLinux OS version.

    Ubuntu + CL Extension is a separate case from normal CL variants.
    The string returned is based on /etc/os-release and contains the major version of the Ubuntu system.

    Previously Ubuntu 20.04 identified itself as "cl8" in this scenario.

    :return: Appropriate version string or None if the version is not recognized.
    �ubuntu22�ubuntu20)�jammy�focal�
os_release��.r�ubuntuN)ru�get_os_version�split)�
ubuntu_map�release�
version_ids   r#�get_cl_version_ubuntur�s�������J�%�\�2�2�G��#�7�j�(�(��'�"�"� �!�!�!�$�J��%��%�%�c�*�*�1�-�
�$�
�$�$�$��4r=c�@�t��rt��Sdddddddd�}tj��}|���D]\}}|r||vr|cS�td	��}|�d
St
dd��}|D]}t|��|vrd
|��cS�d
S)ab
    Return the CloudLinux OS version taking into account the release version
    from `platform.release()` or the RHN systemid file.

    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

    The release string is converted to return the appropriate version string:
        el6 = cl6
        el8 = cl8
    �cl6�cl6h�cl7�cl7h�cl8�cl9�cl10)zel6.zel6h.zel7.zel7h.zel8.z.el9z.el10r�N���cl)�	is_ubuntur��platformr��itemsru�range�str)�check_vals_decoderr��	check_val�
cl_version�accepted_cl_versions�vers      r#�get_cl_versionr�,s����{�{�'�$�&�&�&������������� � �G�!3�!9�!9�!;�!;����	�:��	�y�G�+�+������$�\�2�2�G����t� ��F�+�+��#�����s�8�8�w�����:�:������4r=c���	tdg�����}n#tjtf$rYdSwxYw|dkr|�dd���dSdS)	a�
    Return 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�r7r�)�maxsplitr�physical)rr�rr��FileNotFoundErrorr�)�virt_what_outputs r#�
get_virt_typer�Xs���:�&�(=�'>�?�?�E�E�G�G�����)�+<�=�����t�t������2����%�%�d�Q�%�7�7��:�:��:s�"%�?�?�pidc�T�	tj|d��dS#t$rYdSwxYw)z�
    Check 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&r1NF)	rrr)r*r��intr�r��
ValueError)r�r.s  r#�is_process_runningr��s���
�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�t�tj��dkr"d}d}t|��pt|��Stj�t
��sdSt
t
d���5}|������}ddd��n#1swxYwY|dkS)	a
    Detect 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.pidz/var/run/openlitespeed.pidFr&r1N�0)	rrHr�rr~�LITESPEED_STATUS_FOR_USERSr*r�r�)�litespeed_pid_path�openlitespeed_pid_pathr.�statuss    r#�is_litespeed_runningr��s���
�z�|�|�q���7��!=��!�"4�5�5�c�9K�Lb�9c�9c�c�
�7�>�>�4�5�5���u�	
�(�7�	;�	;�	;�"�q��������!�!��"�"�"�"�"�"�"�"�"�"�"����"�"�"�"��S�=�s�6'B)�)B-�0B-c�R�tj��dkrd}t|��Stj�t
��sdSt
t
d���5}|������}ddd��n#1swxYwY|dkS)a

    Detect that server works under nginx.
    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 - nginx working; False - nginx not running (stopped or absent)
    rz/run/nginx.pidFr&r1Nr�)	rrHr�rr~�NGINX_STATUS_FOR_USERSr*r�r�)r�r.r�s   r#�is_nginx_runningr��s���
�z�|�|�q���(�
�!�-�0�0�0�
�7�>�>�0�1�1���u�	
�$�w�	7�	7�	7�"�1��������!�!��"�"�"�"�"�"�"�"�"�"�"����"�"�"�"��S�=�s�%'B�B�Bc��tj�t��sdSt	td���5}|������}ddd��n#1swxYwY|dkS)a"
    Detect that server works under apache2nginx.
    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 - apache2nginx working; False - apache2nginx not running (stopped or absent)
    Fr&r1N�on)rrr~�APACHE2NGINX_STATEr*r�r�)r.r�s  r#�is_apache2nginx_runningr��s����7�>�>�,�-�-���u�	
� �7�	3�	3�	3�"�q��������!�!��"�"�"�"�"�"�"�"�"�"�"����"�"�"�"��T�>�s�'A0�0A4�7A4c�&�t��rdSdS)zU
    Return proper passenger package according to apache version
    :rtype: str
    zapache24-passengerzalt-mod-passenger)rWrVr=r#�get_passenger_package_namer��s��
�x�x�$�$�#��r=�package_namec��	t��rtddd|g��}d|vrdSntdd|g��n#t$rYdSwxYwdS)	z�
    Check that the given package is installed on the server.

    :param package_name: Package name to check.
    :return: True if package is installed, False otherwise.
    z
dpkg-queryz-Wz-f='${Status}
'zinstall ok installedF�rpmz-qT)r�rr
)r��
pkg_statuss  r#�is_package_installedr��s���
��;�;�
	5�%�l�D�:L�l�%[�\�\�J�&�Z�7�7��u�8�
���l�3�4�4�4��� �����u�u������4s�%=�=�
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_errorsrVr=r#�get_package_db_errorsr��s(���{�{�#� �"�"�"����r=c�T�	tjddgdtjtjd���5}|���\}}|jdkrd|�d|�d	�cd
d
d
��S	d
d
d
��n#1swxYwYn&#t
$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.
    �dpkgz--auditFT)r{�stdoutrQrqrzdpkg audit error: r7r�N�r�Popen�PIPE�communicate�
returncoderr�)�proc�std_out�std_errr�s    r#r�r�sH���
�
�
�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��������3�x�x����������������4sF�/B�+A6�B�*B�6A:�:B�=A:�>B�
B%�B �B%� B%c�Z�d}	tjgd�tjtjd���5}|���\}}|jdkrd|�d|�d|��cd	d	d	��S	d	d	d	��n#1swxYwYn&#t
$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�rQrqrzRPM DB check error: r7z.
See doc: Nr�)�doc_linkr�r�r�r�s     r#r�r�%sV��	u�
��
�
�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��������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�StringIOrPr�rQrVr=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�Os����C�%�K�(�L�	�	�L�	)�	)���
��D�#������������������������s�A�A�A�usernamec�T�	tj|��n#t$rYdSwxYwdS)z,
    Check user existence in the system
    FT)�pwd�getpwnamrN)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��getpwuidrN)r�s r#�is_uid_presentrisA�����S�����������u�u������4r�rc��	tj|��j}n#ttf$rYdSwxYwtj|��}|S)z+
    Check that file by path is socket
    N)r�lstat�st_moder�r�stat�S_ISSOCK)rr3�	is_sockets   r#�is_socket_filertsU����x��~�~�%�����w�'�����t�t������
�d�#�#�I��s��1�1c��tjdddd���}|������d}|dkrdnt	|��}|S)z?
    Get number of system run level by command `runlevel`.
    z/sbin/runlevelTryrzr��S)rr�r�r�r�)�outputrd�levels   r#�get_system_runlevelr�sc���
$����
�	���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�
    Return 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 Tryrz�FFr�N�:r�r�TF)rrr�r�r�r�r�r�)r
�runlevelr
�output_list�
state_info�
state_list�	is_active�state_runlevels        r#�#_get_service_state_on_init_d_systemr�s��#�$�$�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�
    Return 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/nullTry)r{r|)TTz/usr/bin/systemctlr�)rQr�)r�Nrr)r�
check_callr�r�r��DEVNULLr�r�)r
r�s  r#�$_get_service_state_on_systemd_systemr�s��� ���
I�\�H�H�H��"�	
�	
�	
�	
��z���)�+<�=� � � �	 ��!�(�� ��
"�)�!�)����
$��� � �"�"�"��?�f�,�,�&�
$�
$�
$�
$�
$�
$�
$�
$�
$�$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�
$�
$�
$�� �-�/@�A�	 �	 �	 ��<�<�<�	 ����% ���sV��C
�.B.�$B �B.�B �B.� B$	�$B.�'B$	�(B.�.C	�C
�C	�	C
c��t��}|rd|vrt|���\}}nt|���\}}||fS)zb
    Return 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)r#r$�processs   r#�process_is_runningr.�s����7�>�>�+�,�,�^�� \�9J� \� \� \�]�]�]��&�	�{�3�3����	� �
�%6�'�/�/�:K�:K�%K�%K��&L�!2�c�h�h�w���?P�?P�6Q�6Q�!Q�!Q��t�t����#�	�	�	��H�	�����5s�AB�B&�%B&�dtc���t|tjtjf��stdt	|�������t
|���S)z�
    Get 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)r/s r#�get_weekdayr8sU��

�r�H�-�x�}�=�>�>�m��k�ae�fh�ai�ai�k�k�l�l�l��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
    Parse httpd config for details about the 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>)rbr`rcc���g|]=}|��������)|�����>SrV)r�rZ)r9�	directiver;s  �r#r<z/find_module_param_in_config.<locals>.<listcomp>DsA���p�p�p�i�y���GX�GX�Gc�Gc�dn�Go�Go�p�	���!�!�p�p�pr=N�OKrz.MaxRequestWorkers directive not found for mpm_z_module module in rGr()r/r��append�listrfr�r�)
r9r: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_configrK
s\���@C�&8�B�B�B�N��M��{�+�+�I����	'�	'���z�z�|�|���>�!�!�#����	��
� 5� 5��E��	'�� � ��&�&�&����� ��(�		
�	
�	
����q�p�p�p�3C�p�p�p�H����+���}���
���
�p�=O�p�p�cn�p�p�
�	
�
�R�L���s�#�#�E��e�B�i�.�.����$�$r=c�P�d}tj�|��sdS	t|d���5}|������}ddd��n#1swxYwY|�dd��\}}n#ttf$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&r1Nr�r�)	rrr)r*r�r��rsplitrr�)�kmodlve_module_file_pathr.�module�module_version�_s     r#�get_kmodlve_module_versionrRWs���
 =��
�7�>�>�2�3�3���r��
�*�W�
=�
=�
=�	&���V�V�X�X�^�^�%�%�F�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�"�M�M�#�q�1�1�������Z� �����r�r������s4�B�'A)�B�)A-�-B�0A-�1B�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�rR)�synced_kmodlve_versionsr��synced_version�current_versions    r#�)proc_can_see_other_uid_and_hidepid_syncedrWhsU�� %�h�/���!�!�J��0�0�0��u�,�Z�8�N�0�2�2�O��.�(�(��t��5r=�pid_filenamec��	t|d���5}t|��������}t	j|d��ddd��n#1swxYwYn#ttf$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&r1rN)r*r�r�r�rr�rr�)rX�pfr�s   r#�get_process_pidr[{s����
�,��
1�
1�
1�	�R��b�g�g�i�i�o�o�'�'�(�(�C��G�C��O�O�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	���
�Z� �������������Js5�A4�A	A(�A4�(A,�,A4�/A,�0A4�4B
�	B
c��t|dd���5}|�tj�����ddd��dS#1swxYwYdS)z
    Writes pid file
    r>r&r1N)r*�writer�getpid)rXrZs  r#�write_pid_filer_�s���
�l�D�7�	3�	3�	3�#�r�
���B�I�K�K�!�"�"�"�#�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�#�#s�(A�A�Ac�R�	tj|��dS#t$rYdSwxYw)z
    Remove PID file
    N)r�remover)rXs r#�remove_pid_filerb�s?��
�
�	�,��������
�
�
����
���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�getuidrH�seteuid�setgid�setuid)�real_uid�eff_uid�gidr�s  ��r#�funczdemote.<locals>.func�sR����9�;�;���*�,�,���w����J�x� � � �
�	�#����
�	�#�����r=rV)r�rlrms`` r#�demotern�s)�����������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 "r&z/bin/dfz-hr7r�r(rGz)Utility "df" returned unexpected output:
N)rr�isdirrrr�rr)ro�fs_info_cmd�fs_info�mountpoint_info�
mounted_on�es      r#�get_mount_pointrw�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&r1r�N)rrr)r�r*r�r�)�may_detach_mounts_filer.�vals   r#�is_may_detach_mounts_enabledr{�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_partitionsr|�fstype)r|�
partitions�	partitions   r#�get_filesystem_typer��sH���'�)�)�J��$�$�	���v�%�%��#�#�#�#�&�
�2r=c��	d}d}tj��}t|d���5}|�d|�d�|���z��ddd��n#1swxYwY|�|d���d	��}|�|d
���d	��}n#ttjf$rYdSwxYw|dkr|�	d
��rd}||fS)zN
    Detect system name and version.
    :return: tuple (os_name, os_ver)
    z/etc/os-release�topr&r1�[z]
N�NAMEr}�
VERSION_ID)NN�	AlmaLinux�10�
CloudLinux)
�configparserrr*�read_stringr��getr�rrrZ)�os_release_filename�section_name�config�stream�os_name�os_vers      r#r�r��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�����\�'�(�����z�z�����
�+���&�"3�"3�D�"9�"9�����F�?�s5�(C�/A%�C�%A)�)C�,A)�-AC�C�Cc�0�t��\}}|dkS)z~
    Determine whether this system is Ubuntu.

    Reads /etc/os-release file to do so.

    :return: bool flag is_ubuntu
    �Ubuntu)r�)r�rQs  r#r�r�s�� �!�!�J�G�Q��h��r=c��d}tj�d��r1tjdddtjtj���dk}|S)z\
    Determine if secure boot is turned on
    :return: bool flag is_secureboot_enabled
    Fz/sys/firmware/efiz!mokutil --sb-state | grep enabledTry)r{r|r�rQr)rrr~r�callr)r�s r#�is_secureboot_enabledr�s_��
�G�	�w�~�~�)�*�*�

��O�3��&�!�)�!�)�
�
�
��
�	��Nr=c�|�	tjtj����dS#t$rYdSwxYw)z'
    Get username of current user.
    rN)r�r�rrf�	ExceptionrVr=r#�get_usernamer�#sD����|�B�I�K�K�(�(��+�+�������t�t����s�*-�
;�;c�&�t��rdSdS)z-
    It differs on Ubuntu and CloudLinux
    z%usr/lib/x86_64-linux-gnu/php/modules/zusr/lib64/php/modules/)r�rVr=r#�get_modules_dir_for_alt_phpr�-s���{�{�7�6�6�#�#r=re)NFTFN)[r�r2rIr�rr�r�r[rrrPrr�	functoolsr�typingrrrr	r
rr)r��lxmlr�clcommon.utils_cmdr
rrrrir6r�r�r�r$r/r4rCrTrWrfrjr�rur��boolr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr"r.r3r8rKrRrWr[r_rbrnrwr{r��tupler�r�r�r�r�rVr=r#�<module>r�s�����������
�
�
�
�	�	�	�	�	�	�	�	�����
�
�
�
�	�	�	�	���������
�
�
�
�,�,�,�,�,�,�,�,�������<�<�<�<�<�<�<�<�<�<�<�<�<�<�<�<�
�
�
�
�����������������������2��=�	�?��7��.��*�*�*�.
�
�
�
� 	�	�	����&���$4�4�4�
�����
,�,�,�,�^*�*�*�
�H�S�M�
�
�
�
� &�&�&�R�������s�T�z�����:)��d�
�)�)�)�)�X�#�x��}�#�#�#���#�L�3�����"�c��d�����&�d�����(�$�����$����������s��t�����0	�	�	����4���6�������c��d�������������
��
�H�T�N�
�
�
�
��S�����$�c��e�D�$�J�>O�����B# �s�# �u�T�4�Z�?P�# �# �# �# �L"��"��t�T�z�9J�"�"�"�"�"�#��T��d�����0#�E�(�+�X�]�:�;�#��#�#�#�#��	G%�G%��G%��G%��G%��	G%�
�3��8�_�G%�G%�G%�G%�T�C�����"�4�����&
�#�
�(�3�-�
�
�
�
� #��#�#�#�#�
�#�
�
�
�
����,�S��S�����,
�d�
�
�
�
� ����������c�D�j�#��*�4�5�����>	�4�	�	�	�	��t�����(���$�$�$�$�$r=


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
9 Apr 2026 8.30 AM
root / root
0755
__init__.cpython-311.opt-1.pyc
1.566 KB
13 Mar 2026 7.40 PM
root / root
0644
__init__.cpython-311.pyc
1.566 KB
13 Mar 2026 7.40 PM
root / root
0644
clcagefs.cpython-311.opt-1.pyc
16.89 KB
13 Mar 2026 7.40 PM
root / root
0644
clcagefs.cpython-311.pyc
16.89 KB
13 Mar 2026 7.40 PM
root / root
0644
clcaptain.cpython-311.opt-1.pyc
4.338 KB
13 Mar 2026 7.40 PM
root / root
0644
clcaptain.cpython-311.pyc
4.338 KB
13 Mar 2026 7.40 PM
root / root
0644
clconfig.cpython-311.opt-1.pyc
3.218 KB
13 Mar 2026 7.40 PM
root / root
0644
clconfig.cpython-311.pyc
3.218 KB
13 Mar 2026 7.40 PM
root / root
0644
clconfpars.cpython-311.opt-1.pyc
18.688 KB
13 Mar 2026 7.40 PM
root / root
0644
clconfpars.cpython-311.pyc
18.688 KB
13 Mar 2026 7.40 PM
root / root
0644
clcustomscript.cpython-311.opt-1.pyc
1.884 KB
13 Mar 2026 7.40 PM
root / root
0644
clcustomscript.cpython-311.pyc
1.884 KB
13 Mar 2026 7.40 PM
root / root
0644
cldebug.cpython-311.opt-1.pyc
1.325 KB
13 Mar 2026 7.40 PM
root / root
0644
cldebug.cpython-311.pyc
1.325 KB
13 Mar 2026 7.40 PM
root / root
0644
clemail.cpython-311.opt-1.pyc
2.446 KB
13 Mar 2026 7.40 PM
root / root
0644
clemail.cpython-311.pyc
2.446 KB
13 Mar 2026 7.40 PM
root / root
0644
clexception.cpython-311.opt-1.pyc
1.727 KB
13 Mar 2026 7.40 PM
root / root
0644
clexception.cpython-311.pyc
1.727 KB
13 Mar 2026 7.40 PM
root / root
0644
clfunc.cpython-311.opt-1.pyc
11.978 KB
13 Mar 2026 7.40 PM
root / root
0644
clfunc.cpython-311.pyc
11.978 KB
13 Mar 2026 7.40 PM
root / root
0644
clhook.cpython-311.opt-1.pyc
6.191 KB
13 Mar 2026 7.40 PM
root / root
0644
clhook.cpython-311.pyc
6.191 KB
13 Mar 2026 7.40 PM
root / root
0644
cllog.cpython-311.opt-1.pyc
2.814 KB
13 Mar 2026 7.40 PM
root / root
0644
cllog.cpython-311.pyc
2.814 KB
13 Mar 2026 7.40 PM
root / root
0644
cloutput.cpython-311.opt-1.pyc
0.857 KB
13 Mar 2026 7.40 PM
root / root
0644
cloutput.cpython-311.pyc
0.857 KB
13 Mar 2026 7.40 PM
root / root
0644
clproc.cpython-311.opt-1.pyc
8.958 KB
13 Mar 2026 7.40 PM
root / root
0644
clproc.cpython-311.pyc
8.958 KB
13 Mar 2026 7.40 PM
root / root
0644
clpwd.cpython-311.opt-1.pyc
12.005 KB
13 Mar 2026 7.40 PM
root / root
0644
clpwd.cpython-311.pyc
12.005 KB
13 Mar 2026 7.40 PM
root / root
0644
clquota.cpython-311.opt-1.pyc
1.817 KB
13 Mar 2026 7.40 PM
root / root
0644
clquota.cpython-311.pyc
1.817 KB
13 Mar 2026 7.40 PM
root / root
0644
clsec.cpython-311.opt-1.pyc
1.583 KB
13 Mar 2026 7.40 PM
root / root
0644
clsec.cpython-311.pyc
1.583 KB
13 Mar 2026 7.40 PM
root / root
0644
clwpos_lib.cpython-311.opt-1.pyc
23.119 KB
13 Mar 2026 7.40 PM
root / root
0644
clwpos_lib.cpython-311.pyc
23.119 KB
13 Mar 2026 7.40 PM
root / root
0644
const.cpython-311.opt-1.pyc
0.317 KB
13 Mar 2026 7.40 PM
root / root
0644
const.cpython-311.pyc
0.317 KB
13 Mar 2026 7.40 PM
root / root
0644
evr_utils.cpython-311.opt-1.pyc
5.042 KB
13 Mar 2026 7.40 PM
root / root
0644
evr_utils.cpython-311.pyc
5.042 KB
13 Mar 2026 7.40 PM
root / root
0644
features.cpython-311.opt-1.pyc
6.118 KB
13 Mar 2026 7.40 PM
root / root
0644
features.cpython-311.pyc
6.118 KB
13 Mar 2026 7.40 PM
root / root
0644
group_info_reader.cpython-311.opt-1.pyc
6.491 KB
13 Mar 2026 7.40 PM
root / root
0644
group_info_reader.cpython-311.pyc
6.491 KB
13 Mar 2026 7.40 PM
root / root
0644
lock.cpython-311.opt-1.pyc
2.003 KB
13 Mar 2026 7.40 PM
root / root
0644
lock.cpython-311.pyc
2.003 KB
13 Mar 2026 7.40 PM
root / root
0644
mail_helper.cpython-311.opt-1.pyc
7.235 KB
13 Mar 2026 7.40 PM
root / root
0644
mail_helper.cpython-311.pyc
7.235 KB
13 Mar 2026 7.40 PM
root / root
0644
mysql_lib.cpython-311.opt-1.pyc
10.037 KB
13 Mar 2026 7.40 PM
root / root
0644
mysql_lib.cpython-311.pyc
10.037 KB
13 Mar 2026 7.40 PM
root / root
0644
php_conf_reader.cpython-311.opt-1.pyc
11.317 KB
13 Mar 2026 7.40 PM
root / root
0644
php_conf_reader.cpython-311.pyc
11.317 KB
13 Mar 2026 7.40 PM
root / root
0644
sysctl.cpython-311.opt-1.pyc
10.452 KB
13 Mar 2026 7.40 PM
root / root
0644
sysctl.cpython-311.pyc
10.452 KB
13 Mar 2026 7.40 PM
root / root
0644
ui_config.cpython-311.opt-1.pyc
4.718 KB
13 Mar 2026 7.40 PM
root / root
0644
ui_config.cpython-311.pyc
4.718 KB
13 Mar 2026 7.40 PM
root / root
0644
utils.cpython-311.opt-1.pyc
43.709 KB
13 Mar 2026 7.40 PM
root / root
0644
utils.cpython-311.pyc
43.709 KB
13 Mar 2026 7.40 PM
root / root
0644
utils_cmd.cpython-311.opt-1.pyc
4.223 KB
13 Mar 2026 7.40 PM
root / root
0644
utils_cmd.cpython-311.pyc
4.223 KB
13 Mar 2026 7.40 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF