!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/hooks/   drwxr-xr-x
Free 222.22 GB of 981.82 GB (22.63%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     wpos_modify_user_hook.py (4.21 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# 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/LICENSE.TXT

from __future__ import absolute_import, print_function

import os
import subprocess
import sys
import shutil

from clcommon.clpwd import drop_privileges
from clcommon.lib.cledition import is_cl_solo_edition
from clcommon.public_hooks.lib import ModifyUserHook
from clwpos.cl_wpos_exceptions import WposError
from clwpos.optimization_features import OBJECT_CACHE_FEATURE
from clwpos.feature_suites import get_admin_config_directory
from clwpos.user.config import UserConfig
from clwpos.utils import WposUser, update_redis_conf, update_wp_config, user_uid
from clwpos.constants import SUITES_MARKERS
from cpanel import reload_redis


class WposModifyUserHook(ModifyUserHook):
    """
    Update user's data in Redis and WP configs.
    """

    def post_modify_user(self, username: str, new_name: str = None, **kwargs):
        """
        Update the name of the user's home directory in:
        - ~/.clwpos/redis.conf,
        - wp-config.php for Wordpresses with enabled object caching.
        """
        if new_name is None:
            return

        new_user = WposUser(new_name)
        if not new_user.home_dir.endswith(new_name):
            raise WposError('Internal Error. Contact CloudLinux support')
        old_user_homedir = os.path.join(new_user.home_dir[:-len(new_name)], username)
        old_user = WposUser(username, homedir=old_user_homedir)

        with drop_privileges(new_name):
            # Update ~/.clwpos/redis.conf
            if not os.path.exists(new_user.redis_conf):
                # we don't continue if redis.conf is missing
                # because it means that user has never enabled the module
                return

            update_redis_conf(new_user, old_user)

            # Update wp-config.php files
            # use user's WPOS config to get paths to Wordpresses with WPOS object caching enabled
            user_config = UserConfig(new_name)
            for abs_wp_path in user_config.wp_paths_with_enabled_module(OBJECT_CACHE_FEATURE):
                update_wp_config(abs_wp_path, new_user, old_user)

            try:
                reload_redis()
            except Exception as e:
                print(f'Error occurred during daemon reload: {e}', file=sys.stderr)

    def post_create_user(self, username, owner, **kwargs):
        subprocess.run(["/opt/alt/python37/bin/python3", "/usr/sbin/clwpos_collect_information.py", username])

        if os.path.isfile(SUITES_MARKERS['accelerate_wp_premium']) and \
                os.path.isfile(SUITES_MARKERS['accelerate_wp']):

            print('Allowing both AWP and AWP Premium for user', username)
            subprocess.run(['/usr/bin/cloudlinux-awp-admin', 'set-suite', '--suites',
                            'accelerate_wp_premium,accelerate_wp',
                            '--user', username, '--allowed'])

        elif os.path.isfile(SUITES_MARKERS['accelerate_wp_premium']):

            print('Allowing only AWP Premium for user', username)
            subprocess.run(['/usr/bin/cloudlinux-awp-admin', 'set-suite', '--suites', 'accelerate_wp_premium',
                            '--user', username, '--allowed'])
        elif os.path.isfile(SUITES_MARKERS['accelerate_wp']):

            print('Allowing only AWP for user', username)
            subprocess.run(['/usr/bin/cloudlinux-awp-admin', 'set-suite', '--suites', 'accelerate_wp',
                            '--user', username, '--allowed'])

    def pre_delete_user(self, username, **kwargs):
        """
        Triggered before deleting user.
        Cleans up garbage left in /var/clwpos/uids/{user_uid}
        Not run on Solo edition
        :param username: account name
        """
        if is_cl_solo_edition():
            print(f'CL Solo edition detected, skipping hook actions')
            return

        cfg_dir = get_admin_config_directory(user_uid(username=username))
        print(f'Checking {cfg_dir}')
        if os.path.isdir(cfg_dir):
            print(f'{cfg_dir} exists, must be cleaned')
            shutil.rmtree(cfg_dir)
        else:
            print(f'{cfg_dir} does not exist, nothing to be done')

:: 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.0108 ]--