!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/5.6.40 

uname -a: Linux cpanel06wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.80.el6.x86_64 #1 SMP Thu Sep 24
01:42:00 EDT 2020 x86_64
 

uid=851(cp949260) gid=853(cp949260) groups=853(cp949260) 

Safe-mode: OFF (not secure)

/opt/alt/python37/lib/python3.7/site-packages/clwpos/   drwxr-xr-x
Free 233.83 GB of 981.82 GB (23.82%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     wpos_hooks.py (3.89 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/opt/alt/python37/bin/python3 -bb
# -*- coding: utf-8 -*-

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

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

from clcommon.lib.cledition import is_cl_solo_edition
from clwpos.constants import (
    ALT_PHP_REDIS_ENABLE_UTILITY,
    INSTALL_CPANEL_CACHING_HOOKS_UTILITY,
)
from clwpos.optimization_features import OBJECT_CACHE_FEATURE
from clwpos.feature_suites import (
    any_suite_allowed_on_server,
    is_module_allowed_for_user
)
from clwpos.utils import is_wpos_supported

UNIVERSAL_HOOK_PATH_DNF = '/etc/dnf/universal-hooks/multi_pkgs/transaction'
UNIVERSAL_HOOK_PATH_YUM = '/etc/yum/universal-hooks/multi_pkgs/posttrans'
HOOKS_LISTENERS_DIR = '/usr/share/cloudlinux/hooks/listeners'

wpos_hooks = ('wpos_modify_user_hook.py',)


def get_yum_universal_hook_alt_php_path() -> Path:
    """
    Get path to yum universal hooks directory
    with alt-php*-pecl-ext hooks.
    """
    dir_name = 'alt-php__WILDCARD__-pecl-ext'
    if Path('/etc/dnf/').exists():
        return Path(UNIVERSAL_HOOK_PATH_DNF, dir_name)
    return Path(UNIVERSAL_HOOK_PATH_YUM, dir_name)


def install_yum_universal_hook_alt_php() -> None:
    """
    Install yum universal hook for configuring PHP redis
    after alt-php*-pecl-ext package is installed/updated.
    """
    hook_dir_path = get_yum_universal_hook_alt_php_path()
    hook_dir_path.mkdir(parents=True, exist_ok=True)
    hook_name = Path(ALT_PHP_REDIS_ENABLE_UTILITY).name
    hook_full_path = Path(hook_dir_path, hook_name)
    if not hook_full_path.exists():
        hook_full_path.symlink_to(ALT_PHP_REDIS_ENABLE_UTILITY)


def uninstall_yum_universal_hook_alt_php() -> None:
    """
    Remove yum universal hook for configuring PHP redis ext.
    """
    hook_dir_path = get_yum_universal_hook_alt_php_path()
    hook_name = Path(ALT_PHP_REDIS_ENABLE_UTILITY).name
    hook_full_path = Path(hook_dir_path, hook_name)
    # check is_symlink because we want to delete link even if it's broken
    if hook_full_path.is_symlink():
        hook_full_path.unlink()


def install_panel_hooks() -> None:
    """
    Install panel WPOS hooks.
    """
    subprocess.run([INSTALL_CPANEL_CACHING_HOOKS_UTILITY, '-i'], capture_output=True)

    lve_utils_hooks_dir = Path(get_python_lib(), 'clwpos', 'hooks')
    for hook in wpos_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()):
            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 WPOS hooks.
    """
    subprocess.run([INSTALL_CPANEL_CACHING_HOOKS_UTILITY, '-d'], capture_output=True)

    for hook in wpos_hooks:
        listeners_hook_path = Path(HOOKS_LISTENERS_DIR, hook)
        if listeners_hook_path.is_symlink():
            listeners_hook_path.unlink()


def _install_hooks():
    if is_wpos_supported() and any_suite_allowed_on_server():
        if not is_cl_solo_edition(skip_jwt_check=True) \
                and is_module_allowed_for_user(OBJECT_CACHE_FEATURE):
            install_yum_universal_hook_alt_php()
        install_panel_hooks()


def _uninstall_hooks():
    if not is_cl_solo_edition(skip_jwt_check=True):
        uninstall_yum_universal_hook_alt_php()
    uninstall_panel_hooks()


def main():
    """
    Install or uninstall panel and yum/dnf universal hooks.
    """
    if '--install' in sys.argv:
        _install_hooks()
    elif '--uninstall' in sys.argv:
        _uninstall_hooks()


if __name__ == "__main__":
    main()

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0092 ]--