AlkantarClanX12

Your IP : 3.145.34.237


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/__pycache__/cllicenselib.cpython-311.pyc

�

".gj$����ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
Zddlm
Z
dZdZdZej�e��ZdZej�ed��Zej�ed	��Zej�ed
��ZdZdZd
ZdZedd�edd�d�ZdZGd�d��Ze��Z de!fd�Z"de!de#fd�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d �Z+dS)!�N)�error�request)�mod_makedirsz/usr/sbin/rhn_checkz/usr/sbin/rhnreg_ksz/var/lve/lveinfo.verz/etc/sysconfig/rhn�systemidz	jwt.token�jwt_last_update_tsi��i@8z1/usr/share/cloudlinux/no_valid_license_screen.txtz3/usr/share/cloudlinux/license_out_of_date_email.txtz3Error: License out of date, email template missing.)�
template_file�	error_msgz3Error: No valid license found, template is missing.)�Email�NoValidz http://cloudlinux.com/showip.phpc�N�eZdZdZdZdZed���Zd�Zd�Z	d�Z
d�Zd�ZdS)	�LicenseData�c�j�tj�t��r�tj�t��sdSttj�t����}|ttj����tz
krdStt��}||krdSdStj�t��rGtj�t��}|tj�|��kSdS)a�
        Update license when:

        in case JWT token present:
        - if no timestamp file with jwt token last update time
        - if jwt token was not updated during last 4 hours
        - if jwt token was updated later than our timestamp in file

        in case JWT token is not present, but systemid exists
        (fallback for licensing w/o token)
        - update license only if systemid was changed after last timestamp update

        when no jwt and no systemid - re-update license
        TF)�os�path�exists�	JWT_TOKEN�JWT_TOKEN_TIMESTAMP_FILE�int�getmtime�time�JWT_UPDATE_INTERVAL�read_time_from_file�RHN_SYSTEMID)�license_timestamp_file�rhn_updated�jwt_last_update_timestamps   �py/cllicenselib.py�_is_license_needs_updatez$LicenseData._is_license_needs_updateKs��� �7�>�>�)�$�$�		��7�>�>�":�;�;�
��t��b�g�.�.�y�9�9�:�:�K��S�����-�-�0C�C�C�C��t�(;�<T�(U�(U�%�(�;�6�6��t��5�
�7�>�>�,�'�'�	J��'�*�*�<�8�8�K����!1�!1�2H�!I�!I�I�I��t�c�Z�	t|��|_ttj����|jz
tkrG|�|��rt
��Stj�	t��SdS#ttj
f$rYdSwxYw)z�
        Checks license:
        1. Reads cache file with timestamp
        2. Ensures license must be re-checked:
            - if timestamp in cache file > CACHE_TIME ->
            check if we need to re-update licensing
        TF)r�_license_last_timestamprr�
CACHE_TIMEr�update_license_timestamp_filerrrr�IOError�structr)�selfrs  r�
check_licensezLicenseData.check_licensejs���	�+>�?U�+V�+V�D�(��D�I�K�K� � �4�#?�?�:�M�M��0�0�1G�H�H�;�8�:�:�:��w�~�~�i�0�0�0��4�����&�	�	�	��5�5�	���s�A'B�*#B�B*�)B*c��|js�	tjt��5}|����d�����|_ddd��dS#1swxYwYdS#tj$r>}tdt|��z��tjd��Yd}~dSd}~wwxYwdS)N�utf-8zError: Get server IP. �)
�
_server_ipr�urlopen�SHOW_IP_LINK�read�decode�stripr�URLError�print�str�sys�exit)r'�response�es   r�get_ipzLicenseData.get_ip�s����	�
��_�\�2�2�N�h�&.�m�m�o�o�&<�&<�W�&E�&E�&K�&K�&M�&M�D�O�N�N�N�N�N�N�N�N�N�N�N�N����N�N�N�N�N�N���>�
�
�
��.��Q���7�8�8�8�����������������
����		�	s:�A;�?A.�!A;�.A2�2A;�5A2�6A;�;C�
3C�Cc�p�tj�|j���|��S)N)�datetime�
fromtimestampr"�strftime)r'�formats  r�date_formatzLicenseData.date_format�s+��� �.�.�t�/K�L�L�U�U�V\�]�]�]r c�&�	t|dd���5}|���|_ddd��dS#1swxYwYdS#t$r>}t	dt|��z��t
jd��Yd}~dSd}~wwxYw)N�rr*)�encodingz%Error: Failed to open template file. r+)�openr/�_letter_templater%r3r4r5r6)r'�template�fr8s    r�open_letter_templatez LicenseData.open_letter_template�s���	��h��g�6�6�6�
1�!�()������%�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1�
1����
1�
1�
1�
1�
1�
1���	�	�	��9�C��F�F�B�C�C�C��H�Q�K�K�K�K�K�K�K�K�K�����	���s4�A�;�A�?�A�?�A�
B�3B�Bc�F�tj��}|sdS|���|jsm|j�dd���d|j���dtj�����d|��S|j�dd|�	d��z���d|j���dtj�����d|��S)Nz
%LIC_DATE%rz%IP%z
%HOSTNAME%z%FROM%z since �	%b %d, %y)
�detect�getCPAdminEmailr9r"rD�replacer,�socket�gethostnamer?)r'�admin_emails  r�
format_letterzLicenseData.format_letter�s����,�.�.���	��4����
�
�
��+�	��%�-�-�l�B�?�?������1�1����v�'9�';�';�<�<����;�/�/�	
�
�!�)�)�,�	�D�DT�DT�U`�Da�Da�8a�b�b�
�W�V�T�_�
-�
-�
�W�\�6�#5�#7�#7�
8�
8�
�W�X�{�
+�
+�		
r N)
�__name__�
__module__�__qualname__r"r,rD�staticmethodrr(r9r?rGrP�r rr
r
Fs������� ���J�������\��<���,���^�^�^����
�
�
�
�
r r
�filec��t|d��5}tjd|�����dcddd��S#1swxYwYdS)N�rb�ir)rCr&�unpackr/)rVrFs  rrr�s���	
�d�D�	�	�/�Q��}�S�!�&�&�(�(�+�+�A�.�/�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/�/�/s�-A�A�A�	timestampc��t|d��5}|�tjd|����ddd��dS#1swxYwYdS)N�wbrY)rC�writer&�pack)rVr[rFs   r�write_time_to_filer`�s���	
�d�D�	�	�-�Q�	�����C��+�+�,�,�,�-�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-�-�-s�)A�A�Ac	���	tj�t��st	td��tjtgt
jt
j	���5}|�
��|jdkr�ttttj������tj�t"��rDtt$ttj�t"������	ddd��dS	ddd��dS#1swxYwYdS#t(t*f$rYdSwxYw)N����stdout�stderrrTF)rr�isdir�LICENSE_TIMESTAMP_DIRr�
subprocess�Popen�RHN_CHECK_FILE�PIPE�STDOUT�communicate�
returncoder`�LICENSE_TIMESTAMP_FILErrrrrr�OSErrorr%)�procs rr$r$�s�����w�}�}�2�3�3�	7��.��6�6�6�
�
�
���?��$�
�
�
�	����������!�#�#�"�#9�3�t�y�{�{�;K�;K�L�L�L��7�>�>�)�,�,�c�&�'?��R�W�EU�EU�V_�E`�E`�Aa�Aa�b�b�b��	�	�	�	�	�	�	�	��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��
�W������u�u����sC�A*E�,B<E�(E�5E�6E�E�E�
E�E�E%�$E%c	�^�	tj�t��st	td��tjtd|zdgt
jt
j	���5}|�
��\}}|jdkr�ttttj������tj�t"��rDtt$ttj�t"������t)d��	ddd��dSt)|�����	ddd��dS#1swxYwYdS#t,t.f$rt)d	��YdSwxYw)
Nrbz--activationkey=z--forcercr�OKTFz9Error: New key activation failed, please try again later.)rrrfrgrrhri�RHN_UPDATE_NEW_KEYrkrlrmrnr`rorrrrrrr3r1rpr%)�keyrq�out�_s    r�update_license_with_keyrx�s�����w�}�}�2�3�3�	7��.��6�6�6�
�
�
�!3�c�!9�9�E��?��$�
�
�
�	���%�%�'�'�F�C����!�#�#�"�#9�3�t�y�{�{�;K�;K�L�L�L��7�>�>�)�,�,�c�&�'?��R�W�EU�EU�V_�E`�E`�Aa�Aa�b�b�b��d�����	�	�	�	�	�	�	�	�
�#�)�)�+�+�����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��
�W�����
�I�J�J�J��u�u����sC�A/F�1CE;�?F�"E;�.F�;E?�?F�E?�F� F,�+F,c�8�tj�t��rt�t��Stj�t��s$tj�t��rt��SdS)NF)
rr�isfilero�Licenser(rrrr$rUr rr(r(�sl��	�w�~�~�,�-�-�=��$�$�%;�<�<�<�
�w�~�~�i� � �/�B�G�N�N�<�$@�$@�/�,�.�.�.��5r c��|rdStj�t��rdt�d��zSdS)Nrsz5No valid license found, last successful check was on rIzNo valid license found.)rrrzror{r?)�is_valids r�last_license_checkr~�sG�����t�	�w�~�~�,�-�-�j�F��I\�I\�]h�Ii�Ii�i�i�$�$r c�6�ttd��S)Nr
��get_template_to_display�	TEMPLATESrUr r�get_email_templater�s��"�9�W�#5�6�6�6r c�6�ttd��S)Nrr�rUr r�get_novalid_templater�s��"�9�Y�#7�8�8�8r c���tj�|d��s|dSt��s9t�|d��t���SdS)Nrr	)rrrzr(r{rGrP)rEs rr�r�
sf��
�7�>�>�(�?�3�4�4�%���$�$��?�?�'��$�$�X�o�%>�?�?�?��$�$�&�&�&��4r ),r;rrMr&rhr5r�urllibrr�cldetectlibrJ�clcommon.utilsrrjrtror�dirnamerg�
RHN_DIRECTORY�joinrrrr#r�NO_VALID_LICENSE_FOUND_TEMPLATE�"LICENSE_OUT_OF_DATE_EMAIL_TEMPLATEr�r.r
r{r4rrr`r$rxr(r~r�r�r�rUr r�<module>r�s(��8����	�	�	�	�
�
�
�
�
�
�
�
�����
�
�
�
�����!�!�!�!�!�!�!�!�����'�'�'�'�'�'�&��*��/������(>�?�?��$�
��w�|�|�M�:�6�6���G�L�L���4�4�	��7�<�<�(=�?S�T�T��
�
���"U��%Z�"�<�J���
9�J���	
�	
�	�2��d
�d
�d
�d
�d
�d
�d
�d
�P�+�-�-��/�c�/�/�/�/�
-�S�-�S�-�-�-�-����*���6���%�%�%�7�7�7�9�9�9�
����r