관리-도구
편집 파일: cledition.cpython-311.pyc
� ���H�f;6����������������������������d�dl�Z�d�dlZd�dlZd�dlmZ�d�dlmZ�d�dlmZ�d�dl m Z mZ�d�dlm Z mZmZ�d�dlmZ�d�dlmZ�d�d lmZmZmZ�d ZdZdZd ZdZdZ�G�d��de������������Z�G�d��de������������Zeej ��������j!��������eej"��������j!��������eej#��������j!��������eej$��������j!��������iZ%�G�d��d������������Z&d$d�Z'd%d�Z( � � �d%d�Z)d��Z* � � �d%d�Z+defd�Z,d��Z-d ��Z.d!��Z/d"��Z0de1fd#�Z2dS�)&�����N)�Enum)�AnyStr)� exceptions)�CLN_JWT_TOKEN_PATH�CL_EDITION_FILE_FOR_USERS)�read_jwt� decode_jwt�jwt_token_check)�FormattedException)� in_cagefs)�get_os_version� is_ubuntu�is_secureboot_enabledz/etc/cloudlinux-edition-soloz/etc/cloudlinux-edition-adminzCloudLinux OS Shared ProzCloudLinux OS SharedzCloudLinux OS SolozCloudLinux OS Adminc��������������������"�����e�Zd�ZdZdZdZdZdZdS�)�SupportedEditionsz- Keeps supported CloudLinux editions �solo�shared� shared_pro�adminN)�__name__� __module__�__qualname__�__doc__�SOLO�SHARED� SHARED_PRO�ADMIN��������v/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/lib/cledition.pyr���r���"���s.�������������������D� �F��J��E�E�Er���r���c�������������������������e�Zd�Zd��ZdS�)�CLEditionDetectionErrorc������������������6�����t����������j��������|�||d��������������d�S�)N)�message�context)r����__init__)�selfr$���r%���s��� r ���r&���z CLEditionDetectionError.__init__.���s3�������#�D���+ ��+ �� �� �� �� �� r���N)r���r���r���r&���r���r���r ���r"���r"���-���s#����������������������r���r"���c��������������������X�����e�Zd�Zedd���������������Zed����������������Ze � �dd���������������ZdS�) � CLEditionsNTc����������������������|��t����������t����������������������}� �t����������|�|�������������}n2#�t����������j��������$�r }t����������dt������������d|���������������|�d}~ww�xY�w �|d���������S�#�t����������$�r^}|���������������������d������������}|�t����������dt������������d�������������|�|rt����������j ��������j ��������nt����������j��������j ��������cY�d}~S�d}~ww�xY�w)z� Note: be careful when modifying this method. Passing token in is used in X-Ray, ask @dkavchuk or someone else from C-Projects team for details :param token: :param verify_exp: :return: N)� verify_expz)Unable to detect edition from jwt token: z-. Please, make sure it is not broken, error: �edition�cl_pluszL. Please, make sure it is not broken, error: not enough fields for detection)r���r���r ���r���� PyJWTErrorr"����KeyError�getr���r����valuer���)�tokenr+����jwt�er-���s��� r ����get_from_jwtzCLEditions.get_from_jwt?���s8�������=��/�0�0�E� ��U�z�:�:�:�C�C���$�� �� �� �)�B�<N��B��B�>?�B��B������ ����� ���� e��y�>�!���� e�� e�� e��g�g�i�(�(�G���-�b�@R��b��b��b��������:A�d�$�/�5�5�FW�F^�Fd�d�d�d�d�d�d����� e���s3����*��A�A�A�A%��% C �/AC�C �C c����������� �������P����t����������j��������dd|�gt�����������j��������t�����������j��������di�t����������j���������ddi��������������5�}|�����������������������������������\��}}|j��������dk����r*d|v�r �d�d�d��������������d S�t����������d |���d|��d|���������������� �d�d�d��������������n#�1�swxY�w�Y���dS�) N�rpmz-qT�LC_ALL�C)�stdout�stderr�text�envr���zis not installedFzUnable to check if package z is installed, reason: z, )� subprocess�Popen�PIPE�os�environ�communicate� returncoder"���)�package_name�proc�out�errs��� r ����is_package_installedzCLEditions.is_package_installed^���s<����� � � �D�,�'��?��?��1�2�:�1�(�C��1� �� �� �� ����'�'�)�)�H�C����!�#�#�%��,�,� � �� �� �� �� �� �� �� ��.�,�,��,��,�"�,��,�&)�,��,������ �$� �� �� �� �� �� �� �� �� �� �� ����� �� �� �� � ��ts����(B�6B�B�"BFc������������������<����|r|rt����������d�������������|s_t����������j�����������������������������t����������������������r; �|����������������������||�������������}n#�t����������$�r�t������������������������}Y�nw�xY�w|r|S�t������������������������rt������������������������S�|s�t����������j�����������������������������t����������������������rt����������j��������j��������S�t����������j�����������������������������t����������������������rt����������j��������j��������S�t������������������������pt����������j��������j��������S�dS�)a�� 1. Try to detect edition from jwt token if edition field is in token -> return edition if edition field is not present -> recheck via cl_plus flag if token is broken -> raise error about it 2. Try to detect from file if edition is in file -> return edition if file is broken -> raise about it if file is missed -> check if meta package is present Detection from file may be switched off using skip_marker_check In case there is no token with correct edition, no file we consider edition as regular CL. Note: be careful when modifying this method. It is used in X-Ray, ask @dkavchuk or someone else from C-Projects team for details zOUnable to detect edition: neither jwt token check, no file marker check enabled)r2���r+���N)r"���rA����path�isfiler���r5����PermissionError�user_cl_editionr����CL_SOLO_EDITION_FILE_MARKERr���r���r1����CL_ADMIN_EDITION_FILE_MARKERr���r���)�cls�skip_jwt_check�skip_marker_check�raw_jwtr+���r,���s��� r ����get_cl_editionzCLEditions.get_cl_editionr���s5�����(��� c�/�� c�)�a�c��c�� c���� �"�'�.�.�1C�"D�"D�� � ,��*�*��Z�*�P�P����"�� ,�� ,�� ,�)�+�+���� ,������� �����;�;�� %�"�$�$�$��!�� G��w�~�~�9�:�:�� 5�(�-�3�3����� <�=�=�� 5�(�.�4�4�"�$�$�F�(9�(@�(F�F� G�� Gs����A��A.�-A.)NT)FFNT)r���r���r����staticmethodr5���rI����classmethodrU���r���r���r ���r)���r)���=���s}���������������e��e��e���\�e�<�������\��&��DI�04�+G��+G��+G���[�+G��+G��+Gr���r)���TFc������������������n�����t��������������������������������|�||�������������}|duo|t����������j��������j��������k����S�)aU�� Allow skip_jwt_check ONLY if it not critical when license is not valid Use skip_marker_check=True when validity of license is critical and fallback to file is not applicable Note: be careful when modifying this method. It is used in X-Ray and SSA, ask @dkavchuk or someone else from C-Projects team for details �rR���rS���r+���N)r)���rU���r���r���r1����rR���rS���r+���r,���s��� r ����is_cl_solo_editionr[�������sE��������'�'�%�+���(�����G� ��$��J�7�.?�.D�.J�#J�Jr���c������������������n�����t��������������������������������|�||�������������}|duo|t����������j��������j��������k����S��z� Allow skip_jwt_check ONLY if it not critical when license is not valid Use skip_marker_check=True when validity of license is critical and fallback to file is not applicable rY���N)r)���rU���r���r���r1���rZ���s��� r ����is_cl_shared_editionr^�������sE��������'�'�%�+���(�����G� ��$��L�7�.?�.F�.L�#L�Lr���c������������������n�����t��������������������������������|�||�������������}|duo|t����������j��������j��������k����S�r]���)r)���rU���r���r���r1���rZ���s��� r ����is_cl_shared_pro_editionr`�������sE��������'�'�%�+���(�����G� ��$��P�7�.?�.J�.P�#P�Pr���c�������������������>����� �t����������di�|���S�#�t����������$�r�Y�dS�w�xY�w)z: Supress edition checking error and returns False FNr���)r`���r"���)�kwargss��� r ����is_cl_shared_pro_edition_safelyrc�������s=�������'�1�1�&�1�1�1��"��������u�u����s������ �c������������������n�����t��������������������������������|�||�������������}|duo|t����������j��������j��������k����S�r]���)r)���rU���r���r���r1���rZ���s��� r ����is_cl_admin_editionre�������sE��������'�'�%�+���(�����G� ��$��K�7�.?�.E�.K�#K�Kr����returnc������������������������ �t����������d�������������rt����������S�t����������d�������������rt����������S�n#�t����������$�r �t ����������cY�S�w�xY�wt ������������������������\��}�}}d|v�r�t����������j��������� ��������������������t����������������������st������������������������rUt����������t����������dd�������������5�}|����������������������������������������������������������������������cddd�������������S�#�1�swxY�w�Y���|�rt ����������S�t ����������S�)z� Function returns current edition of CL: - CloudLinux OS Shared - CloudLinux OS Shared Pro - CloudLinux OS Solo - Error string T)rR���z read error�r�utf-8��encodingN)r[����SOLO_EDITION_HUMAN_READABLEre����ADMIN_EDITION_HUMAN_READABLEr"����SHARED_EDITION_HUMAN_READABLEr ���rA���rK���rL���r���r����openr����read�strip�!SHARED_PRO_EDITION_HUMAN_READABLE)�success_flag� error_message�_�fs��� r ����get_cl_edition_readablerw�������s>�����-��T�2�2�2�� 0�.�.� �� 5� 5� 5�� 0�/�/� 0��"��-��-��-�,�,�,�,�-�����&5�%6�%6�"�L�-����}�$�$�"�'�.�.�9K�*L�*L�$�PY�P[�P[�$� �+�S�7� C� C� C�� $�q��6�6�8�8�>�>�#�#� $�� $�� $�� $�� $�� $�� $�� $�� $�� $�� $�� $����� $�� $�� $�� $����-�0�0�,�,s%����1��1��A�A�'&C�C�!Cc�������������������X�����t����������j��������dt�����������������������t����������d�������������dS�)zJust print skip messagezJas part of unification effort, features might not map directly to editionszpCloudLinux Solo edition detected! Command is skipped, because it is unsupported and unneeded on current editionN)�warnings�warn�DeprecationWarning�printr���r���r ����print_skip_message_on_solor}��� ��sG������� �M�T�������� ��Z��[��[��[��[��[r���c�������������������V�����t����������j��������dt�����������������������ddlm}���|���������������S�)Nz@since v3.4.1 use "clcommon.cpapi.utils:skip_without_lve" insteadr�����skip_without_lve)ry���rz���r{����clcommon.cpapi.utilsr����r���s��� r ���r����r������s?�������M�J��������6�5�5�5�5�5�����r���c������������������X�����t����������j��������dt�����������������������ddlm}��||�������������S�)NzEsince v3.4.1 use "clcommon.cpapi.utils:lve_supported_or_exit" insteadr���)�lve_supported_or_exit)ry���rz���r{���r����r����)rv���r����s��� r ���r����r����&��sA�������M�O��������;�:�:�:�:�:� � ��#�#�#r���c�������������������,����t�����������j�����������������������������t����������������������rot ����������t����������dd�������������5�}�|�����������������������������������������������������������������������}ddd�������������n#�1�swxY�w�Y���t�������������������������������|������������S�dS�)z�This function is used as workaround for users to be able to get CL Edition. Crontab will write to CL_EDITION_FILE_FOR_USERS, output of cldetect --detect-edition command with 0644 permission. rh���ri���rj���N) rA���rK����existsr���ro���rp���rq����"HUMAN_READABLE_TOKEN_EDITION_PAIRSr0���)rv���r,���s��� r ���rN���rN���/��s�������� �w�~�~�/�0�0��?� �+�S�7� C� C� C�� '�q��f�f�h�h�n�n�&�&�G� '�� '�� '�� '�� '�� '�� '�� '�� '�� '�� '����� '�� '�� '�� '��2�5�5�g�>�>�>��4s����'A/�/A3�6A3c�������������������@�����t�����������j�����������������������������d������������S�)z< Determines is this system running inside container z/etc/cloudlinux-container)rA���rK���r����r���r���r ����is_containerr����;��s��������7�>�>�5�6�6�6r���)TFT)FFT)3rA���r>���ry����enumr����typingr���r3���r����clcommon.lib.constsr���r����clcommon.lib.jwt_tokenr���r ���r ����clcommon.clexceptionr����clcommon.clcagefsr����clcommon.utilsr ���r���r���rO���rP���rr���rn���rl���rm���r���r"���r���r1���r���r���r���r����r)���r[���r^���r`���rc���re���rw���r}���r����r����rN����boolr����r���r���r ����<module>r�������s������ � � � ���������������������������������������������������M��M��M��M��M��M��M��M��H��H��H��H��H��H��H��H��H��H��3��3��3��3��3��3��'��'��'��'��'��'��L��K��K��K��K��K��K��K��K��K�<���>���$>��!� 6���2���4����������������������������0�������� �!2�!7�!=�%�'8�'C�'I�!�#4�#;�#A� �"3�"9�"?� &��"�aG��aG��aG��aG��aG��aG��aG��aG�HK��K��K��K�$M��M��M��M��-2�/4�(,�Q��Q��Q��Q� ������(-�*/�#'�L��L��L��L�"-���-��-��-��-�>[��[��[� �����$��$��$� �� �� �7�d��7��7��7��7��7��7r���