HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/xray_hooks.py
#!/opt/cloudlinux/venv/bin/python3 -bb
# -*- coding: utf-8 -*-

#
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2025 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENCE.TXT

import sys
from distutils.sysconfig import get_python_lib
from pathlib import Path


HOOKS_LISTENERS_DIR = '/usr/share/cloudlinux/hooks/listeners'
USER_DIRS_HOOK = 'xray_user_dirs_hook.py'
ALL_XRAY_HOOKS = (USER_DIRS_HOOK,)


def install_panel_hooks() -> None:
    """
    Install panel hooks for X-Ray
    """

    lve_utils_hooks_dir = Path(get_python_lib(), 'xray', 'hooks')
    for hook in ALL_XRAY_HOOKS:
        listeners_hook_path = Path(HOOKS_LISTENERS_DIR, hook)
        lve_utils_hook_path = Path(lve_utils_hooks_dir, hook)
        # remove old hook pointing to symlink to lve_utils
        if 'lve_utils' in str(listeners_hook_path.resolve()) or 'python3.7' in str(listeners_hook_path.resolve()):
            listeners_hook_path.unlink()
        if not listeners_hook_path.exists() and lve_utils_hook_path.exists():
            listeners_hook_path.symlink_to(lve_utils_hook_path)


def uninstall_panel_hooks() -> None:
    """
    Remove panel hooks for X-Ray
    """
    for hook in ALL_XRAY_HOOKS:
        listeners_hook_path = Path(HOOKS_LISTENERS_DIR, hook)
        if listeners_hook_path.is_symlink():
            listeners_hook_path.unlink()


def _install_hooks():
    """
    Install X-Ray hooks
    """
    install_panel_hooks()


def _uninstall_hooks():
    """
    Uninstall X-Ray hooks
    """
    uninstall_panel_hooks()


def main():
    """
    Install or uninstall X-Ray hooks
    """
    if '--install' in sys.argv:
        _install_hooks()
    elif '--uninstall' in sys.argv:
        _uninstall_hooks()


if __name__ == "__main__":
    main()