| Server IP : 185.143.234.238 / Your IP : 185.215.232.195 Web Server : Apache System : Linux 81-12-52-146.cprapid.com 4.18.0-553.76.1.lve.el8.x86_64 #1 SMP Wed Oct 1 16:05:07 UTC 2025 x86_64 User : noavaranesama ( 1039) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /sbin/ |
Upload File : |
#!/opt/cloudlinux/venv/bin/python3 -bb
import argparse
import os
import subprocess
import sys
# The following imports might cause an ImportError if there's no alt-python27-cllib in the CL venv.
# However, cllib is always installed during the installation of the CloudLinux OS, so that is very unlikely.
# alt-python27-cllib is not a direct dependency of the rhn-client-tools package, because during the installation
# of the CloudLinux OS, rhn-client-tools must be installed before alt-python27-cllib.
from clcommon.lib.cledition import CLEditions
# Invoke the edition watcher by ABSOLUTE path so it cannot be hijacked through
# the inherited PATH (this hook runs as root from the JWT-update flow), and run
# it under a fixed, trusted PATH as defense-in-depth for the watcher's own
# child-process lookups (mirrors the clnreg_ks PATH hardening).
_EDITION_WATCHER = '/usr/sbin/cloudlinux-edition-watcher'
_TRUSTED_PATH = '/usr/sbin:/usr/bin:/sbin:/bin'
def _run_edition_change_check(edition: str):
# run interactively
subprocess.run([_EDITION_WATCHER, 'check', '--pre', '--edition', edition],
env=dict(os.environ, PATH=_TRUSTED_PATH))
def main(jwt_token, transition_allowed: bool):
"""
You add your other actions here, but don't forget to handle errors.
@param transition_allowed:
True means that we expect transition to start and it won't
affect any system actions like another yum transaction.
"""
if transition_allowed:
edition = CLEditions.get_from_jwt(token=jwt_token)
_run_edition_change_check(edition)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--new-token',
help='New jwt token value that will be later saved to file')
parser.add_argument('--new-token-stdin', action='store_true', default=False,
help='Read JWT token from stdin instead of --new-token argument')
parser.add_argument('--allow-transition', action='store_true', default=False)
args = parser.parse_args()
if args.new_token_stdin:
args.new_token = sys.stdin.read().strip()
main(args.new_token, transition_allowed=args.allow_transition)