|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /opt/alt/python37/lib/python3.7/site-packages/__pycache__/ |
Upload File : |
B
��c � @ sl 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
�Zedd�r�dndZdZdZ dZ!e!dd�e dd�d�Z"dZ#G dd� d�Z$e$� Z%e&d�dd�Z'e&e(d�d d!�Z)d"d#� Z*d$d%� Z+d&d'� Z,d(d)� Z-d*d+� Z.d,d-� Z/d.d/� Z0dS )0� )�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/rhnZsystemidz jwt.tokenZjwt_last_update_tsT)Zskip_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 @ sL e Zd ZdZdZdZedd� �Zdd� Zdd� Z dd � Z
d
d� Zdd
� ZdS )�LicenseData� c C s� t j�t�r\t j�t�sdS tt j�t��}|tt�� �t k rDdS t t�}||k rXdS dS t j�t
�r�t j�t
�}|t j�| �kS 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_fileZrhn_updatedZjwt_last_update_timestamp� r �=/opt/alt/python37/lib/python3.7/site-packages/cllicenselib.py�_is_license_needs_updateI s z$LicenseData._is_license_needs_updatec C sd yDt |�| _tt�� �| j tkr>| �|�r2t� S tj� t
�S dS W n ttj
fk
r^ dS X dS )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
TFN)r �_license_last_timestampr r �
CACHE_TIMEr �update_license_timestamp_filer r r r �IOError�structr )�selfr r r r �
check_licenseh s
zLicenseData.check_licensec
C sb | j s^yt�t��� �� | _ W n> tjk
r\ } ztdt |� � t
�d� W d d }~X Y nX d S )NzError: Get server IP. � )�
_server_ipr Zurlopen�SHOW_IP_LINK�read�stripr ZURLError�print�str�sys�exit)r"