404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.119.164.231: ~ $
# -*- coding: utf-8 -*-

# CLSETUP python lib

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

# Classes:
#
# Kernel
# check min kernel for securelinks

# Setup:
#
# setup apache gid for securelinks
# setup nagios

import grp
import os
import pwd
import subprocess
import sys

import cldetectlib
from cl_proc_hidepid import remount_proc
from clcommon.sysctl import SYSCTL_CL_CONF_FILE, SysCtlConf


# Kernel Version Class
class KernelVersion:
    _SECURELINKS_MIN_KERNEL = ['1','1','95']
    _system_kernel = ''
    _cl_kernel = True

    def __init__(self):
        with subprocess.Popen(
            ['uname', '-r'],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        ) as proc:
            out, _ = proc.communicate()
            if proc.returncode != 0:
                print('error: subprocess call error. Cant\'t get current kernel version')
                sys.exit(1)
            if out.find('lve') != -1:
                self._system_kernel = out.split('lve')[1].split('el')[0][:-1].strip().split('.')
                print(self._system_kernel)
            else:
                self._cl_kernel = False

    # Check if system kernel newer then securelinks min kernel
    def securelinks_kernel_requirement(self):
        if self._cl_kernel:
            return (
                self._system_kernel >= self._SECURELINKS_MIN_KERNEL
                and os.path.isfile('/proc/sys/fs/symlinkown_gid')
            )
        print('error: Feature is not supported on non CL kernel.')
        sys.exit(1)


    # return _SECURELINKS_MIN_KERNEL
    def get_securelinks_min_kernel(self):
        return 'lve' + '.'.join(self._SECURELINKS_MIN_KERNEL)


sysctl = SysCtlConf(config_file=SYSCTL_CL_CONF_FILE)


def set_securelinks_gid(apache_gid):
    """
    Change /etc/sysctl.conf for apache gid
    :param apache_gid: id of apache's group
    :return: None
    """

    symlink_command = 'fs.symlinkown_gid'
    sysctl.set(symlink_command, apache_gid)


def _add_to_super_gid(user):
    """
    Add user to the group specified by fs.proc_super_gid.
    If fs.proc_super_gid is 0 (means undefined) or group doesn't really exists
    then create "clsupergid" group, configure it as fs.proc_super_gid and
    add user to this group
    """
    sgid_key = 'fs.proc_super_gid'
    try:
        # sysctl.get may return empty string in some cases like cldeploy
        # when CL kernel is not loaded yet and proc has no such param
        proc_super_gid = int(sysctl.get(sgid_key))
    except ValueError:
        proc_super_gid = 0

    try:
        # Check that group with this gid really exists, and if not, then reset
        # it to undefined so it will be replaced with clsupergid below
        grp.getgrgid(proc_super_gid).gr_name
    except KeyError:
        proc_super_gid = 0

    if proc_super_gid == 0:
        # Create and configure group if it was undefined
        sgid_name = 'clsupergid'
        subprocess.run(f'groupadd -f {sgid_name}',
                       shell=True, executable='/bin/bash', check=False)
        proc_super_gid = grp.getgrnam(sgid_name).gr_gid
        sysctl.set(sgid_key, proc_super_gid)
    # If user already in this group or it's primary group == proc_super_gid
    # this will do nothing
    subprocess.run(f'usermod -a -G {proc_super_gid} {user}',
                   shell=True, executable='/bin/bash', check=False)


def setup_nagios(do_remount_proc=True):
    """
    Add nagios to configured fs.proc_super_gid group
    """
    if not cldetectlib.get_nagios():
        return  # Nothing to do

    _add_to_super_gid('nagios')

    # CAG-796: use hidepid=2 when mounting /proc
    if do_remount_proc:
        remount_proc()


def setup_mailman():
    """
    Detect "mailman" and add it to fs.proc_super_gid group
    """
    if not os.path.isdir('/usr/local/cpanel/3rdparty/mailman'):
        return

    try:
        pwd.getpwnam('mailman')
    except KeyError:
        return

    _add_to_super_gid('mailman')


def setup_supergids():
    """
    Configure "special" users to be in fs.proc_super_gid group, if it's
    necessary.
    If this GID was undefined(0) then create and setup special clsupergid group
    """
    setup_nagios(do_remount_proc=False)
    setup_mailman()

    # CAG-796: use hidepid=2 when mounting /proc
    remount_proc()

Filemanager

Name Type Size Permission Actions
GitPython-3.1.32.dist-info Folder 0755
Jinja2-3.0.3.dist-info Folder 0755
Mako-1.2.4.dist-info Folder 0755
MarkupSafe-2.1.3.dist-info Folder 0755
PyJWT-2.8.0.dist-info Folder 0755
PyMySQL-1.1.0.dist-info Folder 0755
PyVirtualDisplay-3.0.dist-info Folder 0755
PyYAML-6.0.1.dist-info Folder 0755
SQLAlchemy-1.3.24.dist-info Folder 0755
__pycache__ Folder 0755
_distutils_hack Folder 0755
_pytest Folder 0755
_yaml Folder 0755
aiohttp Folder 0755
aiohttp-3.9.2.dist-info Folder 0755
aiosignal Folder 0755
aiosignal-1.3.1.dist-info Folder 0755
alembic Folder 0755
alembic-1.11.1.dist-info Folder 0755
astroid Folder 0755
astroid-2.15.6.dist-info Folder 0755
async_timeout Folder 0755
async_timeout-4.0.3.dist-info Folder 0755
attr Folder 0755
attrs Folder 0755
attrs-23.1.0.dist-info Folder 0755
certifi Folder 0755
certifi-2023.7.22.dist-info Folder 0755
cffi Folder 0755
cffi-1.15.1.dist-info Folder 0755
chardet Folder 0755
chardet-5.2.0.dist-info Folder 0755
charset_normalizer Folder 0755
charset_normalizer-2.1.1.dist-info Folder 0755
cl_dom_collector Folder 0755
clcagefslib Folder 0755
clcommon Folder 0755
clconfig Folder 0755
clconfigure Folder 0755
cldashboard Folder 0755
clevents Folder 0755
clflags Folder 0755
cllicense Folder 0755
cllimits Folder 0755
cllimits_validator Folder 0755
cllimitslib_v2 Folder 0755
cllvectl Folder 0755
clpackages Folder 0755
clquota Folder 0755
clselect Folder 0755
clselector Folder 0755
clsentry Folder 0755
clsummary Folder 0755
clveconfig Folder 0755
clwizard Folder 0755
colorama Folder 0755
colorama-0.4.6.dist-info Folder 0755
contextlib2 Folder 0755
contextlib2-21.6.0.dist-info Folder 0755
coverage Folder 0755
coverage-7.2.7.dist-info Folder 0755
cryptography Folder 0755
cryptography-41.0.2.dist-info Folder 0755
ddt-1.4.4.dist-info Folder 0755
dill Folder 0755
dill-0.3.7.dist-info Folder 0755
distlib Folder 0755
distlib-0.3.8.dist-info Folder 0755
docopt-0.6.2.dist-info Folder 0755
dodgy Folder 0755
dodgy-0.2.1.dist-info Folder 0755
filelock Folder 0755
filelock-3.13.1.dist-info Folder 0755
flake8 Folder 0755
flake8-5.0.4.dist-info Folder 0755
flake8_polyfill Folder 0755
flake8_polyfill-1.0.2.dist-info Folder 0755
frozenlist Folder 0755
frozenlist-1.4.0.dist-info Folder 0755
future Folder 0755
future-0.18.3.dist-info Folder 0755
git Folder 0755
gitdb Folder 0755
gitdb-4.0.10.dist-info Folder 0755
guppy Folder 0755
guppy3-3.1.3.dist-info Folder 0755
idna Folder 0755
idna-3.4.dist-info Folder 0755
iniconfig Folder 0755
iniconfig-2.0.0.dist-info Folder 0755
isort Folder 0755
isort-5.12.0.dist-info Folder 0755
jinja2 Folder 0755
jsonschema Folder 0755
jsonschema-3.2.0.dist-info Folder 0755
jwt Folder 0755
lazy_object_proxy Folder 0755
lazy_object_proxy-1.9.0.dist-info Folder 0755
libfuturize Folder 0755
libpasteurize Folder 0755
lve_stats-2.0.dist-info Folder 0755
lve_utils Folder 0755
lvemanager Folder 0755
lvestats Folder 0755
lxml Folder 0755
lxml-4.9.2.dist-info Folder 0755
mako Folder 0755
markupsafe Folder 0755
mccabe-0.7.0.dist-info Folder 0755
mock Folder 0755
mock-5.1.0.dist-info Folder 0755
multidict Folder 0755
multidict-6.0.4.dist-info Folder 0755
numpy Folder 0755
numpy-1.25.1.dist-info Folder 0755
numpy.libs Folder 0755
packaging Folder 0755
packaging-23.1.dist-info Folder 0755
past Folder 0755
pep8_naming-0.10.0.dist-info Folder 0755
pip Folder 0755
pip-24.1.2.dist-info Folder 0755
pkg_resources Folder 0755
platformdirs Folder 0755
platformdirs-3.11.0.dist-info Folder 0755
pluggy Folder 0755
pluggy-1.2.0.dist-info Folder 0755
prettytable Folder 0755
prettytable-3.8.0.dist-info Folder 0755
prometheus_client Folder 0755
prometheus_client-0.8.0.dist-info Folder 0755
prospector Folder 0755
prospector-1.10.2.dist-info Folder 0755
psutil Folder 0755
psutil-5.9.5.dist-info Folder 0755
psycopg2 Folder 0755
psycopg2_binary-2.9.6.dist-info Folder 0755
psycopg2_binary.libs Folder 0755
pycodestyle-2.9.1.dist-info Folder 0755
pycparser Folder 0755
pycparser-2.21.dist-info Folder 0755
pydocstyle Folder 0755
pydocstyle-6.3.0.dist-info Folder 0755
pyfakefs Folder 0755
pyfakefs-5.2.3.dist-info Folder 0755
pyflakes Folder 0755
pyflakes-2.5.0.dist-info Folder 0755
pylint Folder 0755
pylint-2.17.4.dist-info Folder 0755
pylint_celery Folder 0755
pylint_celery-0.3.dist-info Folder 0755
pylint_django Folder 0755
pylint_django-2.5.3.dist-info Folder 0755
pylint_flask Folder 0755
pylint_flask-0.6.dist-info Folder 0755
pylint_plugin_utils Folder 0755
pylint_plugin_utils-0.7.dist-info Folder 0755
pylve-2.1-py3.11.egg-info Folder 0755
pymysql Folder 0755
pyparsing Folder 0755
pyparsing-3.0.9.dist-info Folder 0755
pyrsistent Folder 0755
pyrsistent-0.19.3.dist-info Folder 0755
pytest Folder 0755
pytest-7.4.0.dist-info Folder 0755
pytest_subprocess Folder 0755
pytest_subprocess-1.5.0.dist-info Folder 0755
pyvirtualdisplay Folder 0755
raven Folder 0755
raven-6.10.0.dist-info Folder 0755
requests Folder 0755
requests-2.31.0.dist-info Folder 0755
requirements_detector Folder 0755
requirements_detector-1.2.2.dist-info Folder 0755
schema-0.7.5.dist-info Folder 0755
semver Folder 0755
semver-3.0.1.dist-info Folder 0755
sentry_sdk Folder 0755
sentry_sdk-1.29.2.dist-info Folder 0755
setoptconf Folder 0755
setoptconf_tmp-0.3.1.dist-info Folder 0755
setuptools Folder 0755
setuptools-70.2.0.dist-info Folder 0755
simplejson Folder 0755
simplejson-3.19.1.dist-info Folder 0755
six-1.16.0.dist-info Folder 0755
smmap Folder 0755
smmap-5.0.0.dist-info Folder 0755
snowballstemmer Folder 0755
snowballstemmer-2.2.0.dist-info Folder 0755
sqlalchemy Folder 0755
ssa Folder 0755
svgwrite Folder 0755
svgwrite-1.4.3.dist-info Folder 0755
tap Folder 0755
tap.py-3.1.dist-info Folder 0755
testfixtures Folder 0755
testfixtures-7.1.0.dist-info Folder 0755
toml Folder 0755
toml-0.10.2.dist-info Folder 0755
tomlkit Folder 0755
tomlkit-0.11.8.dist-info Folder 0755
typing_extensions-4.7.1.dist-info Folder 0755
unshare-0.22.dist-info Folder 0755
urllib3 Folder 0755
urllib3-2.0.4.dist-info Folder 0755
vendors_api Folder 0755
virtualenv Folder 0755
virtualenv-20.21.1.dist-info Folder 0755
wcwidth Folder 0755
wcwidth-0.2.6.dist-info Folder 0755
wmt Folder 0755
wrapt Folder 0755
wrapt-1.15.0.dist-info Folder 0755
yaml Folder 0755
yarl Folder 0755
yarl-1.9.2.dist-info Folder 0755
_cffi_backend.cpython-311-x86_64-linux-gnu.so File 267.63 KB 0755
_pyrsistent_version.py File 23 B 0644
cl_proc_hidepid.py File 4.53 KB 0644
clcontrollib.py File 51.73 KB 0644
cldetectlib.py File 18.13 KB 0644
cldiaglib.py File 45.57 KB 0644
clhooklib.py File 1.27 KB 0644
cli_utils.py File 1.66 KB 0644
cllicenselib.py File 9.1 KB 0644
clsetuplib.py File 4.35 KB 0644
clsudo.py File 14.42 KB 0644
ddt.py File 12.43 KB 0644
distutils-precedence.pth File 151 B 0644
docopt.py File 19.48 KB 0644
lveapi.py File 19.53 KB 0644
lvectllib.py File 102.55 KB 0644
lvestat.py File 6.83 KB 0644
mccabe.py File 10.4 KB 0644
pep8ext_naming.py File 18.61 KB 0644
py.py File 263 B 0644
pycodestyle.py File 101.08 KB 0644
pylve.cpython-311-x86_64-linux-gnu.so File 25.48 KB 0755
remove_ubc.py File 5.73 KB 0755
schema.py File 29.51 KB 0644
secureio.py File 18.83 KB 0644
simple_rpm.so File 11.29 KB 0755
six.py File 33.74 KB 0644
typing_extensions.py File 108.48 KB 0644
unshare.cpython-311-x86_64-linux-gnu.so File 8.17 KB 0755