관리-도구
편집 파일: cllicenselib.cpython-311.pyc
� �EBgj$ � �� � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZm Z d dl Zd dlm Z dZdZdZej � e� � ZdZej � ed� � Zej � ed � � Zej � ed � � ZdZdZd ZdZedd�edd�d�ZdZ 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 )!� 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@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_updateK s� � � �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 |� � | _ 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_licensej s� � � �+>�?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 � � | j s� t j t � � 5 }|� � � � d� � � � � | _ d d d � � d S # 1 swxY w Y d S # t j $ r>}t dt |� � z � � t j d� � Y d }~d S d }~ww xY wd S )N�utf-8zError: Get server IP. � ) � _server_ipr �urlopen�SHOW_IP_LINK�read�decode�stripr �URLError�print�str�sys�exit)r'