Hackfut Security File Manager
Current Path:
/opt/alt/python37/lib/python3.7/site-packages
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
📁
..
📁
Babel-2.9.1-py3.7.egg-info
📁
Jinja2-3.0.3-py3.7.egg-info
📁
Mako-1.1.0-py3.7.egg-info
📁
PyJWT-1.7.1-py3.7.egg-info
📄
PySocks-1.5.7-py3.7.egg-info
(322 B)
📁
__pycache__
📁
_distutils_hack
📁
aiosignal
📁
aiosignal-1.2.0a0-py3.7.egg-info
📁
alembic
📁
alembic-0.8.3-py3.7.egg-info
📁
async_timeout
📁
async_timeout-4.0.2-py3.7.egg-info
📁
attr
📁
attrs-17.4.0-py3.7.egg-info
📁
babel
📁
beautifulsoup4-4.5.1-py3.7.egg-info
📁
bs4
📁
certifi
📁
certifi-2018.4.16-py3.7.egg-info
📁
chardet
📁
chardet-3.0.4-py3.7.egg-info
📁
charset_normalizer
📁
charset_normalizer-2.0.12-py3.7.egg-info
📁
cl_dom_collector
📄
cl_proc_hidepid.py
(4.44 KB)
📁
clcommon
📁
clconfig
📁
clconfigure
📄
clcontrollib.py
(51.88 KB)
📁
cldashboard
📄
cldetectlib.py
(18.31 KB)
📄
cldiaglib.py
(47.53 KB)
📁
clevents
📄
clhooklib.py
(1.4 KB)
📄
cli_utils.py
(1.73 KB)
📁
cllicense
📄
cllicenselib.py
(8.03 KB)
📁
cllimits
📁
cllimits_validator
📁
cllimitslib_v2
📁
clpackages
📁
clquota
📁
clselect
📁
clselector
📁
clsentry
📄
clsetuplib.py
(4.32 KB)
📄
clsudo.py
(14.7 KB)
📁
clsummary
📁
clveconfig
📁
clwizard
📁
clwpos
📄
cpanel.py
(28.99 KB)
📁
cssselect
📁
cssselect-0.9.2-py3.7.egg-info
📁
distlib
📄
distlib-0.3.4-py3.7.egg-info
(1.13 KB)
📄
distutils-precedence.pth
(152 B)
📁
docopt-0.6.2-py3.7.egg-info
📄
docopt.py
(19.48 KB)
📄
editor.py
(2.49 KB)
📄
editor.pyc
(3.6 KB)
📄
editor.pyo
(3.6 KB)
📁
filelock
📁
filelock-0.0.0-py3.7.egg-info
📁
future
📁
future-0.17.0-py3.7.egg-info
📁
html5lib
📁
html5lib-1.0.1-py3.7.egg-info
📁
idna
📁
idna-2.5-py3.7.egg-info
📁
importlib_metadata
📁
importlib_metadata-0.0.0-py3.7.egg-info
📁
jinja2
📁
jsonschema
📁
jsonschema-3.2.0-py3.7.egg-info
📁
jwt
📁
libfuturize
📁
libpasteurize
📄
lve_stats-2.0-py3.7.egg-info
(185 B)
📁
lve_utils
📄
lveapi.py
(19.24 KB)
📄
lvectllib.py
(92.33 KB)
📁
lvemanager
📄
lvestat.py
(6.94 KB)
📁
lvestats
📁
mako
📁
nose
📁
nose-1.3.7-py3.7.egg-info
📁
past
📁
pip
📁
pip-20.2.4.dist-info
📁
pkg_resources
📁
platformdirs
📁
platformdirs-0.0.0-py3.7.egg-info
📁
prettytable-0.7.2-py3.7.egg-info
📄
prettytable.py
(52.93 KB)
📁
pyparsing-2.1.10-py3.7.egg-info
📄
pyparsing.py
(224.48 KB)
📁
python_editor-0.4-py3.7.egg-info
📁
pytz
📁
pytz-2017.2-py3.7.egg-info
📁
raven
📁
raven-6.3.0-py3.7.egg-info
📄
remove_ubc.py
(5.54 KB)
📁
requests
📁
requests-2.26.0-py3.7.egg-info
📁
schema-0.7.1-py3.7.egg-info
📄
schema.py
(28.51 KB)
📄
secureio.py
(16.98 KB)
📁
sentry_sdk
📁
sentry_sdk-0.19.4-py3.7.egg-info
📁
setuptools
📁
setuptools-58.3.0.dist-info
📁
six-1.15.0-py3.7.egg-info
📄
six.py
(33.36 KB)
📄
socks.py
(29.25 KB)
📄
sockshandler.py
(2.84 KB)
📁
svgwrite
📁
svgwrite-1.3.0-py3.7.egg-info
📁
typing_extensions-3.7.4.3-py3.7.egg-info
📄
typing_extensions.py
(81.76 KB)
📁
urllib3
📁
urllib3-1.26.6-py3.7.egg-info
📁
vendors_api
📁
virtualenv
📁
virtualenv-20.13.0-py3.7.egg-info
📁
webencodings
📁
webencodings-0.5.1-py3.7.egg-info
📁
wmt
📁
zipp-0.0.0-py3.7.egg-info
📄
zipp.py
(8.23 KB)
Editing: cllicenselib.py
# -*- coding: utf-8 -*- # CL LICENSE CHECK python lib # # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT # CLASSES: # # LicenseData - main class for CL licence check # : check_license # : get_ip # : date_format # : open_letter_template # : format_letter # # FUNCTIONS: # # License update cron : update_license_timestamp_file # License update new key : update license with new key # Check license : check_license # Return Last License check date : last_license_check # Return Template to display : return_template_to_display from __future__ import print_function from __future__ import absolute_import from future.moves.urllib import request, error import os, sys, subprocess, struct, time, datetime, socket import cldetectlib as detect from clcommon.utils import mod_makedirs from clcommon.lib.cledition import is_cl_solo_edition RHN_CHECK_FILE = '/usr/sbin/rhn_check' RHN_UPDATE_NEW_KEY = '/usr/sbin/rhnreg_ks' LICENSE_TIMESTAMP_FILE = '/var/lve/lveinfo.ver' LICENSE_TIMESTAMP_DIR = os.path.dirname(LICENSE_TIMESTAMP_FILE) RHN_DIRECTORY = '/etc/sysconfig/rhn' RHN_SYSTEMID = os.path.join(RHN_DIRECTORY, 'systemid') JWT_TOKEN = os.path.join(RHN_DIRECTORY, 'jwt.token') JWT_TOKEN_TIMESTAMP_FILE = os.path.join(LICENSE_TIMESTAMP_DIR, 'jwt_last_update_ts') # 1h if solo else 3 days CACHE_TIME = 3600 if is_cl_solo_edition(skip_jwt_check=True) else 259200 JWT_UPDATE_INTERVAL = 3600 * 4 NO_VALID_LICENSE_FOUND_TEMPLATE = '/usr/share/cloudlinux/no_valid_license_screen.txt' LICENSE_OUT_OF_DATE_EMAIL_TEMPLATE = '/usr/share/cloudlinux/license_out_of_date_email.txt' TEMPLATES = { 'Email': { 'template_file': LICENSE_OUT_OF_DATE_EMAIL_TEMPLATE, 'error_msg': 'Error: License out of date, email template missing.' }, 'NoValid': { 'template_file': NO_VALID_LICENSE_FOUND_TEMPLATE, 'error_msg': 'Error: No valid license found, template is missing.' } } SHOW_IP_LINK = 'http://cloudlinux.com/showip.php' # License Data Class class LicenseData: _license_last_timestamp = '' _server_ip = '' _letter_template = '' @staticmethod def _is_license_needs_update(license_timestamp_file): """ 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 """ if os.path.exists(JWT_TOKEN): if not os.path.exists(JWT_TOKEN_TIMESTAMP_FILE): return True rhn_updated = int(os.path.getmtime(JWT_TOKEN)) if rhn_updated < int(time.time()) - JWT_UPDATE_INTERVAL: return True jwt_last_update_timestamp = read_time_from_file(JWT_TOKEN_TIMESTAMP_FILE) if jwt_last_update_timestamp < rhn_updated: return True return False elif os.path.exists(RHN_SYSTEMID): rhn_updated = os.path.getmtime(RHN_SYSTEMID) return rhn_updated > os.path.getmtime(license_timestamp_file) return True def check_license(self, license_timestamp_file): """ 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 """ try: # Get timestamp of last license check self._license_last_timestamp = read_time_from_file(license_timestamp_file) if (int(time.time()) - self._license_last_timestamp) > CACHE_TIME: if self._is_license_needs_update(license_timestamp_file): return update_license_timestamp_file() # because if server does not have jwt token and license is not needed update # consider no license return os.path.exists(JWT_TOKEN) else: return True except (IOError, struct.error): return False # Get IP def get_ip(self): if not self._server_ip: try: self._server_ip = request.urlopen(SHOW_IP_LINK).read().strip() except error.URLError as e: print('Error: Get server IP. ' + str(e)) sys.exit(1) # Format Date def date_format(self, format): return datetime.datetime.fromtimestamp(self._license_last_timestamp).strftime(format) # Open letter template def open_letter_template(self, template): try: self._letter_template = open(template, "r").read() except IOError as e: print('Error: Failed to open template file. ' +str(e)) sys.exit(1) # Format Screen def format_letter(self): admin_email = detect.getCPAdminEmail() if admin_email: self.get_ip() if not self._license_last_timestamp: return self._letter_template.replace('%LIC_DATE%','').replace('%IP%',self._server_ip).replace('%HOSTNAME%',socket.gethostname()).replace('%FROM%',admin_email) else: return self._letter_template.replace('%LIC_DATE%',' since ' + self.date_format('%b %d, %y')).replace('%IP%',self._server_ip).replace('%HOSTNAME%',socket.gethostname()).replace('%FROM%',admin_email) else: return None # License Data Class Object License = LicenseData() def read_time_from_file(file: str): with open(file, 'rb') as f: return struct.unpack('i', f.read())[0] def write_time_to_file(file: str, timestamp: int): with open(file, 'wb') as f: f.write(struct.pack('i', timestamp)) # License update cron def update_license_timestamp_file(): try: if not os.path.isdir(LICENSE_TIMESTAMP_DIR): mod_makedirs(LICENSE_TIMESTAMP_DIR, 0o755) p = subprocess.Popen([RHN_CHECK_FILE], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) (out, err) = p.communicate() if p.returncode == 0: write_time_to_file(LICENSE_TIMESTAMP_FILE, int(time.time())) if os.path.exists(JWT_TOKEN): write_time_to_file(JWT_TOKEN_TIMESTAMP_FILE, int(os.path.getmtime(JWT_TOKEN))) return True return False except (OSError, IOError): return False # update license with new key def update_license_with_key(key): try: if not os.path.isdir(LICENSE_TIMESTAMP_DIR): mod_makedirs(LICENSE_TIMESTAMP_DIR, 0o755) p = subprocess.Popen([RHN_UPDATE_NEW_KEY, '--activationkey='+key, '--force'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) (out, err) = p.communicate() if p.returncode == 0: write_time_to_file(LICENSE_TIMESTAMP_FILE, int(time.time())) if os.path.exists(JWT_TOKEN): write_time_to_file(JWT_TOKEN_TIMESTAMP_FILE, int(os.path.getmtime(JWT_TOKEN))) print('OK') return True else: print(out.strip()) return False except (OSError, IOError): print('Error: New key activation failed, please try again later.') return False # Returns: # True == license is Ok # False == license expired or not found def check_license(): # Check for license timestamp file in /var/lve/lveinfo.ver if os.path.isfile(LICENSE_TIMESTAMP_FILE): return License.check_license(LICENSE_TIMESTAMP_FILE) # try to re-update license file if jwt token is present # or systemid file as fallback when jwt absent (goDaddy) elif os.path.exists(JWT_TOKEN) or os.path.exists(RHN_SYSTEMID): return update_license_timestamp_file() return False # Return Last license check Date def last_license_check(is_valid): if is_valid: return 'OK' # Check for license timestamp file in /var/lve/lveinfo.ver if os.path.isfile(LICENSE_TIMESTAMP_FILE): return 'No valid license found, last successful check was on ' + License.date_format('%b %d, %y') else: return 'No valid license found.' def get_email_template(): return get_template_to_display(TEMPLATES['Email']) def get_novalid_template(): return get_template_to_display(TEMPLATES['NoValid']) # Return Template Email, No Valid license found template. def get_template_to_display(template): # check for template in /usr/share/cloudlinux if os.path.isfile(template['template_file']): if check_license(): return None else: # set template text into License class attr. License.open_letter_template(template['template_file']) # Return Formatted Template return License.format_letter() else: return template['error_msg']
Upload File
Create Folder