Edit File: cllicenselib.cpython-311.pyc
� ����5/9e �����������������������&����d�dl�mZ�d�dl�mZ�d�dlmZmZ�d�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlZd�dl Zd�dlmZ�d�dlmZ�dZdZd Zej�����������������������������e������������Zd Zej�����������������������������ed������������Zej�����������������������������ed������������Zej�����������������������������ed ������������Z�ed�������������rdndZdZdZ dZ!e!dd�e dd�d�Z"dZ#�G�d��d������������Z$�e$��������������Z%de&fd�Z'de&de(fd�Z)d ��Z*d!��Z+d"��Z,d#��Z-d$��Z.d%��Z/d&��Z0dS�)'�����)�print_function)�absolute_import)�request�errorN)�mod_makedirs)�is_cl_solo_editionz/usr/sbin/rhn_checkz/usr/sbin/rhnreg_ksz/var/lve/lveinfo.verz/etc/sysconfig/rhn�systemidz jwt.token�jwt_last_update_tsT)�skip_jwt_checki��i���i@8��z1/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�����e�Zd�ZdZdZdZed����������������Zd��Zd��Z d��Z d��Zd��ZdS�) �LicenseData��c������������������j����t�����������j�����������������������������t����������������������r�t�����������j�����������������������������t����������������������sdS�t����������t�����������j�����������������������������t����������������������������������}|t����������t����������j����������������������������������t����������z ��k�����rdS�t����������t����������������������}||k�����rdS�dS�t�����������j�����������������������������t����������������������rGt�����������j�����������������������������t����������������������}|t�����������j�����������������������������|�������������k����S�dS�)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_updateI���s������� ��W�^�^�I����A� �'�.�.�1� 2� 2����4��R�W�%�%�i�0�0�1�1�;��C�� ���$�$�':�:�:�:��4�2�3K�L�L���+�-�-��4� �%� �w�~�~�l�#�#��A���!�!�,�/�/�;� ���(�(�)?�@�@� @�@� ������c������������������Z���� �t����������|������������|�_��������t����������t����������j����������������������������������|�j��������z ��t����������k����rG|����������������������|������������rt ������������������������S�t����������j��������� ��������������������t����������������������S�dS�#�t����������t����������j ��������f$�r�Y�dS�w�xY�w)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_timestampr���r���� CACHE_TIMEr#����update_license_timestamp_filer���r���r���r����IOError�structr���)�selfr���s��� r"���� check_licensezLicenseData.check_licenseh���s��������"5�6L�"M�"M�4�� �4�9�;�;���$�6�6�*�D�D��$�$�%;�<�<��,�)�+�+�+���7�>�>�)�$�$�$��4�� �6�<� ������� �%�%����s����A'B��*#B��B*�)B*c������������������>����|�j���������s� �t����������j��������t��������������������������������������������������������������������������������������������|�_���������d�S�#�t����������j��������$�r>}t����������dt����������|������������z����������������t����������j��������d�������������Y�d�}~d�S�d�}~ww�xY�wd�S�)NzError: Get server IP. ����)� _server_ipr����urlopen�SHOW_IP_LINK�read�stripr����URLError�print�str�sys�exit)r+����es��� r"����get_ipzLicenseData.get_ip���s������� ������o�l�3�3�8�8�:�:�@�@�B�B�D�O�O�O�� �.������� � "�S��V�V� +�,�,�,��H�Q�K�K�K�K�K�K�K�K�K�����������s����AA �� B�3B�Bc������������������p�����t�����������j������������������������������|�j�����������������������������������������|������������S�)N)�datetime� fromtimestampr&����strftime)r+����formats��� r"����date_formatzLicenseData.date_format����s+������ � � (� (��)E� F� F� O� O�PV� W� W�Wr$���c������������������������ �t����������|d�����������������������������������������������|�_��������d�S�#�t����������$�r>}t ����������dt����������|������������z����������������t ����������j��������d�������������Y�d�}~d�S�d�}~ww�xY�w)N�rz%Error: Failed to open template file. r.���)�openr2����_letter_templater)���r5���r6���r7���r8���)r+����templater9���s��� r"����open_letter_templatez LicenseData.open_letter_template����s}���������#�.�.�3�3�5�5�4����� �������� 0�#�a�&�&� 8�9�9�9��8�A�;�;�;�;�;�;�;�;�;��������s����'+�� A3�3A.�.A3c������������������H����t����������j����������������������}|�r|�������������������������������������|�j��������sm|�j�����������������������������dd���������������������������������d|�j�����������������������������������������dt����������j�������������������������������������������������������d|������������S�|�j�����������������������������dd|�� ��������������������d������������z������������������������������������d|�j�����������������������������������������dt����������j�������������������������������������������������������d|������������S�d�S�)Nz %LIC_DATE%r���z%IP%z %HOSTNAME%z%FROM%z since � %b %d, %y) �detect�getCPAdminEmailr:���r&���rD����replacer/����socket�gethostnamer@���)r+����admin_emails��� r"���� format_letterzLicenseData.format_letter����sc������&�(�(�+�����;�;�=�=�=� � &��J�� �(�(��b�9�9�A�A�&���Y�Y�a�a�bn�ou���pB���pD���pD���E���E���M���M���NV���Wb���c���c���c�� �(�(��i�$�BR�BR�S^�B_�B_�6_�`�`�h�h�io�pt�p���A���A���I���I���JV���W]���Wi���Wk���Wk���l���l���t���t���u}���~I���J���J���J� �$r$���N) �__name__� __module__�__qualname__r&���r/���rD����staticmethodr#���r,���r:���r@���rF���rO�����r$���r"���r���r���D���s���������������������������,��<�����.�����X��X��X������ �� �� �� �� r$���r����filec�����������������������t����������|�d������������5�}t����������j��������d|�����������������������������������������������d���������cd�d�d��������������S�#�1�swxY�w�Y���d�S�)N�rb�ir���)rC���r*����unpackr2���)rU����fs��� r"���r���r�������s������� �4�����)�!� ��s�A�F�F�H�H� %� %�a� (�)��)��)��)��)��)��)��)��)��)��)��)�����)��)��)��)��)��)s����-A�A�A� timestampc�����������������������t����������|�d������������5�}|���������������������t����������j��������d|�������������������������d�d�d��������������d�S�#�1�swxY�w�Y���d�S�)N�wbrX���)rC����writer*����pack)rU���r[���rZ���s��� r"����write_time_to_filer`�������s������� �4�����'�!��'�'�&�+�c�9� %� %�&�&�&�'��'��'��'��'��'��'��'��'��'��'��'�����'��'��'��'��'��'s����)A�A�Ac����������������������� �t�����������j�����������������������������t����������������������st ����������t����������d�������������t����������j��������t����������gt ����������j��������t ����������j ���������������������}�|�� ����������������������������������\��}}|�j��������dk����r�t����������t����������t����������t����������j�����������������������������������������������t�����������j�����������������������������t"����������������������rDt����������t$����������t����������t�����������j�����������������������������t"�����������������������������������������������dS�dS�#�t(����������t*����������f$�r�Y�dS�w�xY�w)N������stdout�stderrr���TF)r���r����isdir�LICENSE_TIMESTAMP_DIRr���� subprocess�Popen�RHN_CHECK_FILE�PIPE�STDOUT�communicate� returncoder`����LICENSE_TIMESTAMP_FILEr���r���r���r���r���r����OSErrorr)���)�p�out�errs��� r"���r(���r(�������s�������� ����,� -� -��.��%�u�-�-�-����'� �� �HY�Z�Z�Z�!��}�}���*�3���\�Q����,�c�$�)�+�+�.>�.>�?�?�?��g�n�n�Y����S��/��R�W�5E�5E�i�5P�5P�1Q�1Q�R�R�R� �$� ��� �'�������� ������s����D'D-��-E�Ec���������������������� �t�����������j�����������������������������t����������������������st ����������t����������d�������������t����������j��������t����������d|�z���dgt ����������j��������t ����������j ���������������������}|� ����������������������������������\��}}|j��������dk����r�t����������t����������t����������t����������j�����������������������������������������������t�����������j�����������������������������t"����������������������rDt����������t$����������t����������t�����������j�����������������������������t"�����������������������������������������������t)����������d�������������dS�t)����������|������������������������������������������������dS�#�t,����������t.����������f$�r�t)����������d �������������Y�dS�w�xY�w) Nrb���z--activationkey=z--forcerc���r����OKTFz9Error: New key activation failed, please try again later.)r���r���rf���rg���r���rh���ri����RHN_UPDATE_NEW_KEYrk���rl���rm���rn���r`���ro���r���r���r���r���r���r���r5���r3���rp���r)���)�keyrq���rr���rs���s��� r"����update_license_with_keyrx�������sG������ ����,� -� -��.��%�u�-�-�-���*�,>�s�,B�I�N�Wa�Wf�oy���pA���B���B���B�!��}�}���*�3���\�Q����,�c�$�)�+�+�.>�.>�?�?�?��g�n�n�Y����S��/��R�W�5E�5E�i�5P�5P�1Q�1Q�R�R�R���;�;�;� �$���������� �%�� �'���������C�D�D�D� ������s����D;E"��?!E"��" F�Fc�������������������8����t�����������j�����������������������������t����������������������rt�������������������������������t����������������������S�t�����������j�����������������������������t����������������������s$t�����������j�����������������������������t����������������������rt������������������������S�dS�)NF) r���r����isfilero����Licenser,���r���r���r���r(���rT���r$���r"���r,���r,�������sl�������G�N�N�)�*�*��)� � � �5� 6� 6�6�� �g�n�n�Y����)�2�7�>�>�,�#?�#?��)� &� (� (�(� �r$���c�����������������������|�rdS�t�����������j�����������������������������t����������������������rdt�������������������������������d������������z���S�dS�)Nru���z5No valid license found, last successful check was on rH���zNo valid license found.)r���r���rz���ro���r{���r@���)�is_valids��� r"����last_license_checkr~�������sF��������� ���G�N�N�)�*�*��#� @�7�CV�CV�Wb�Cc�Cc� c�c� "� "r$���c�������������������6�����t����������t����������d���������������������S�)Nr�����get_template_to_display� TEMPLATESrT���r$���r"����get_email_templater��������s������� �'� 2�3�3�3r$���c�������������������6�����t����������t����������d���������������������S�)Nr���r����rT���r$���r"����get_novalid_templater��������s������� �)� 4�5�5�5r$���c������������������������t�����������j�����������������������������|�d���������������������rIt������������������������rd�S�t�������������������������������|�d����������������������t���������������������������������������������S�|�d���������S�)Nr���r ���)r���r���rz���r,���r{���rF���rO���)rE���s��� r"���r����r��������sj��������G�N�N�8�O�,�-�-����_�_��"� �$������� 9�:�:�:��� � � !� !�!� �+� �r$���)1� __future__r���r����future.moves.urllibr���r���r���r7���rh���r*���r���r<���rL����cldetectlibrI����clcommon.utilsr����clcommon.lib.cleditionr���rj���rv���ro���r����dirnamerg���� RHN_DIRECTORY�joinr���r���r���r'���r����NO_VALID_LICENSE_FOUND_TEMPLATE�"LICENSE_OUT_OF_DATE_EMAIL_TEMPLATEr����r1���r���r{���r6���r���r���r`���r(���rx���r,���r~���r����r����r����rT���r$���r"����<module>r�������s�����8�&��%��%��%��%��%��&��&��&��&��&��&��.��.��.��.��.��.��.��.��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:��:����������'��'��'��'��'��'��5��5��5��5��5��5�&��*���/�������(>�?�?���$� ��w�|�|�M�:�6�6���G�L�L���4�4� ��7�<�<�(=�?S�T�T����(�'�t�<�<�<� H�T�T�&� ����"U���%Z��"��6�D���� �3�D� �� � �� � ��2��Y��Y��Y��Y��Y��Y��Y��Y�z��+�-�-��)�c��)��)��)��)� '�S��'�S��'��'��'��'� �� �� �"�����.�����#��#��#�4��4��4�6��6��6� ��������r$���