%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/__pycache__/cllicenselib.cpython-37.pyc

B

L#Lb �@slddlmZddlmZddlmZmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlmZddlmZdZdZd	Zej�e�Zd
Zej�ed�Zej�ed�Zej�ed
�Zedd�r�dndZdZdZ dZ!e!dd�e dd�d�Z"dZ#Gdd�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_checkii��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@sLeZdZdZdZdZedd��Zdd�Zdd�Z	dd	�Z
d
d�Zdd
�ZdS)�LicenseData�cCs�tj�t�r\tj�t�sdSttj�t��}|tt���tkrDdSt	t�}||krXdSdStj�t
�r�tj�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_fileZrhn_updatedZjwt_last_update_timestamp�r�=/opt/alt/python37/lib/python3.7/site-packages/cllicenselib.py�_is_license_needs_updateIsz$LicenseData._is_license_needs_updatec	CsdyDt|�|_tt���|jtkr>|�|�r2t�Stj�	t
�SdSWnttj
fk
r^dSXdS)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_timestamprr�
CACHE_TIMEr�update_license_timestamp_filerrrr�IOError�structr)�selfrrrr�
check_licensehs

zLicenseData.check_licensec
Csb|js^yt�t�����|_Wn>tjk
r\}ztdt	|��t
�d�Wdd}~XYnXdS)NzError: Get server IP. �)�
_server_iprZurlopen�SHOW_IP_LINK�read�striprZURLError�print�str�sys�exit)r"�errr�get_ipszLicenseData.get_ipcCstj�|j��|�S)N)�datetimeZ
fromtimestamprZstrftime)r"�formatrrr�date_format�szLicenseData.date_formatc
CsVyt|d���|_Wn<tk
rP}ztdt|��t�d�Wdd}~XYnXdS)N�rz%Error: Failed to open template file. r$)�openr'�_letter_templater r)r*r+r,)r"�templater-rrr�open_letter_template�s
z LicenseData.open_letter_templatecCs�t��}|r~|��|jsF|j�dd��d|j��dt����d|�S|j�dd|�	d���d|j��dt����d|�SndSdS)Nz
%LIC_DATE%r
z%IP%z
%HOSTNAME%z%FROM%z since z	%b %d, %y)
�detectZgetCPAdminEmailr.rr4�replacer%�socketZgethostnamer1)r"Zadmin_emailrrr�
format_letter�s,8zLicenseData.format_letterN)
�__name__�
__module__�__qualname__rr%r4�staticmethodrr#r.r1r6r:rrrrrDs	r)�filec	Cs*t|d��}t�d|���dSQRXdS)N�rb�ir)r3r!�unpackr')r?�frrrr�sr)r?�	timestampc	Cs,t|d��}|�t�d|��WdQRXdS)N�wbrA)r3�writer!�pack)r?rDrCrrr�write_time_to_file�srHc	Cs�y~tj�t�sttd�tjtgtjtj	d�}|�
�\}}|jdkr|tt
tt����tj�t�rxttttj�t���dSdSttfk
r�dSXdS)Ni�)�stdout�stderrrTF)rr�isdir�LICENSE_TIMESTAMP_DIRr�
subprocess�Popen�RHN_CHECK_FILE�PIPE�STDOUT�communicate�
returncoderH�LICENSE_TIMESTAMP_FILErrrrrr�OSErrorr )�p�out�errrrrr�s

rc	Cs�y�tj�t�sttd�tjtd|dgtjtj	d�}|�
�\}}|jdkr�tt
tt����tj�t�r�ttttj�t���td�dSt|���dSWn ttfk
r�td	�dSXdS)
Ni�z--activationkey=z--force)rIrJr�OKTFz9Error: New key activation failed, please try again later.)rrrKrLrrMrN�RHN_UPDATE_NEW_KEYrPrQrRrSrHrTrrrrrrr)r(rUr )�keyrVrWrXrrr�update_license_with_key�s 

r\cCs8tj�t�rt�t�Stj�t�s.tj�t�r4t	�SdS)NF)
rr�isfilerT�Licenser#rrrrrrrrr#�s

r#cCs*|rdStj�t�r"dt�d�SdSdS)NrYz5No valid license found, last successful check was on z	%b %d, %yzNo valid license found.)rrr]rTr^r1)Zis_validrrr�last_license_check�s
r_cCsttd�S)Nr
)�get_template_to_display�	TEMPLATESrrrr�get_email_template�srbcCsttd�S)Nr)r`rarrrr�get_novalid_template�srccCs>tj�|d�r2t�rdSt�|d�t��Sn|dSdS)Nrr	)rrr]r#r^r6r:)r5rrrr`�s
r`)1Z
__future__rrZfuture.moves.urllibrrrr+rMr!rr/r9Zcldetectlibr7Zclcommon.utilsrZclcommon.lib.cleditionrrOrZrTr�dirnamerLZ
RHN_DIRECTORY�joinrrrrrZNO_VALID_LICENSE_FOUND_TEMPLATEZ"LICENSE_OUT_OF_DATE_EMAIL_TEMPLATErar&rr^r*rrrHrr\r#r_rbrcr`rrrr�<module>sD8]


Zerion Mini Shell 1.0