Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
__pycache__
/
File Content:
cllicenselib.cpython-311.pyc
� ܨf� � � � d dl mZ d dl mZ d dlmZmZ d dlZd dlZd dlZd dl Z d dl Z d dlZd dlZd dl Zd dlmZ dZdZdZej � e� � Zd Zej � ed � � Zej � ed� � Zej � ed� � Zd ZdZdZdZedd�edd�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"� Z.dS )#� )�print_function)�absolute_import)�request�errorN)�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@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_updateG 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_licensef 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"