/opt/cloudlinux/venv/lib/python3.11/site-packages
NameSizeModeActions
aiohttp/-0755rm
aiohttp-3.9.2.dist-info/-0755rm
aiosignal/-0755rm
aiosignal-1.3.1.dist-info/-0755rm
alembic/-0755rm
alembic-1.11.1.dist-info/-0755rm
astroid/-0755rm
astroid-2.15.6.dist-info/-0755rm
async_timeout/-0755rm
async_timeout-4.0.3.dist-info/-0755rm
attr/-0755rm
attrs/-0755rm
attrs-23.1.0.dist-info/-0755rm
certifi/-0755rm
certifi-2023.5.7.dist-info/-0755rm
chardet/-0755rm
chardet-5.2.0.dist-info/-0755rm
charset_normalizer/-0755rm
charset_normalizer-2.1.1.dist-info/-0755rm
clcagefslib/-0755rm
clcommon/-0755rm
clconfig/-0755rm
clconfigure/-0755rm
cldashboard/-0755rm
clevents/-0755rm
clflags/-0755rm
cllicense/-0755rm
cllimits/-0755rm
cllimitslib_v2/-0755rm
cllimits_validator/-0755rm
cllvectl/-0755rm
clpackages/-0755rm
clquota/-0755rm
clselect/-0755rm
clselector/-0755rm
clsentry/-0755rm
clsummary/-0755rm
clveconfig/-0755rm
clwizard/-0755rm
clwpos/-0755rm
cl_dom_collector/-0755rm
colorama/-0755rm
colorama-0.4.6.dist-info/-0755rm
contextlib2/-0755rm
contextlib2-21.6.0.dist-info/-0755rm
coverage/-0755rm
coverage-7.2.7.dist-info/-0755rm
Cython/-0755rm
Cython-0.29.35.dist-info/-0755rm
ddt-1.6.0.dist-info/-0755rm
dill/-0755rm
dill-0.3.6.dist-info/-0755rm
distlib/-0755rm
distlib-0.3.8.dist-info/-0755rm
docopt-0.6.2.dist-info/-0755rm
dodgy/-0755rm
dodgy-0.2.1.dist-info/-0755rm
filelock/-0755rm
filelock-3.13.1.dist-info/-0755rm
flake8/-0755rm
flake8-5.0.4.dist-info/-0755rm
flake8_polyfill/-0755rm
flake8_polyfill-1.0.2.dist-info/-0755rm
frozenlist/-0755rm
frozenlist-1.4.0.dist-info/-0755rm
future/-0755rm
future-0.18.3.dist-info/-0755rm
git/-0755rm
gitdb/-0755rm
gitdb-4.0.10.dist-info/-0755rm
GitPython-3.1.32.dist-info/-0755rm
guppy/-0755rm
guppy3-3.1.3.dist-info/-0755rm
idna/-0755rm
idna-3.4.dist-info/-0755rm
iniconfig/-0755rm
iniconfig-2.0.0.dist-info/-0755rm
isort/-0755rm
isort-5.12.0.dist-info/-0755rm
jinja2/-0755rm
Jinja2-3.1.2.dist-info/-0755rm
jsonschema/-0755rm
jsonschema-3.2.0.dist-info/-0755rm
jwt/-0755rm
lazy_object_proxy/-0755rm
lazy_object_proxy-1.9.0.dist-info/-0755rm
libfuturize/-0755rm
libpasteurize/-0755rm
lvemanager/-0755rm
lvestats/-0755rm
lve_stats-2.0.dist-info/-0755rm
lve_utils/-0755rm
lxml/-0755rm
lxml-4.9.2.dist-info/-0755rm
mako/-0755rm
Mako-1.2.4.dist-info/-0755rm
markupsafe/-0755rm
MarkupSafe-2.1.3.dist-info/-0755rm
mccabe-0.7.0.dist-info/-0755rm
mock/-0755rm
mock-5.1.0.dist-info/-0755rm
multidict/-0755rm
multidict-6.0.4.dist-info/-0755rm
numpy/-0755rm
numpy-1.24.3.dist-info/-0755rm
packaging/-0755rm
packaging-23.1.dist-info/-0755rm
past/-0755rm
pep8_naming-0.10.0.dist-info/-0755rm
pip/-0755rm
pip-24.1.2.dist-info/-0755rm
pkg_resources/-0755rm
platformdirs/-0755rm
platformdirs-3.11.0.dist-info/-0755rm
pluggy/-0755rm
pluggy-1.2.0.dist-info/-0755rm
prettytable/-0755rm
prettytable-3.8.0.dist-info/-0755rm
prometheus_client/-0755rm
prometheus_client-0.8.0.dist-info/-0755rm
prospector/-0755rm
prospector-1.10.2.dist-info/-0755rm
psutil/-0755rm
psutil-5.9.5.dist-info/-0755rm
psycopg2/-0755rm
psycopg2-2.6.2.dist-info/-0755rm
pycodestyle-2.9.1.dist-info/-0755rm
pydocstyle/-0755rm
pydocstyle-6.3.0.dist-info/-0755rm
pyfakefs/-0755rm
pyfakefs-5.2.3.dist-info/-0755rm
pyflakes/-0755rm
pyflakes-2.5.0.dist-info/-0755rm
PyJWT-2.8.0.dist-info/-0755rm
pylint/-0755rm
pylint-2.17.4.dist-info/-0755rm
pylint_celery/-0755rm
pylint_celery-0.3.dist-info/-0755rm
pylint_django/-0755rm
pylint_django-2.5.3.dist-info/-0755rm
pylint_flask/-0755rm
pylint_flask-0.6.dist-info/-0755rm
pylint_plugin_utils/-0755rm
pylint_plugin_utils-0.7.dist-info/-0755rm
pylve-2.1-py3.11.egg-info/-0755rm
pymysql/-0755rm
PyMySQL-0.7.11.dist-info/-0755rm
pyparsing/-0755rm
pyparsing-3.0.9.dist-info/-0755rm
pyrsistent/-0755rm
pyrsistent-0.19.3.dist-info/-0755rm
pytest/-0755rm
pytest-7.4.0.dist-info/-0755rm
pytest_subprocess/-0755rm
pytest_subprocess-1.5.0.dist-info/-0755rm
pyvirtualdisplay/-0755rm
PyVirtualDisplay-3.0.dist-info/-0755rm
pyximport/-0755rm
PyYAML-6.0.1.dist-info/-0755rm
raven/-0755rm
raven-6.10.0.dist-info/-0755rm
requests/-0755rm
requests-2.31.0.dist-info/-0755rm
requirements_detector/-0755rm
requirements_detector-1.2.2.dist-info/-0755rm
schema-0.7.5.dist-info/-0755rm
semver/-0755rm
semver-3.0.1.dist-info/-0755rm
sentry_sdk/-0755rm
sentry_sdk-1.29.2.dist-info/-0755rm
setoptconf/-0755rm
setoptconf_tmp-0.3.1.dist-info/-0755rm
setuptools/-0755rm
setuptools-70.2.0.dist-info/-0755rm
simplejson/-0755rm
simplejson-3.19.1.dist-info/-0755rm
six-1.16.0.dist-info/-0755rm
smmap/-0755rm
smmap-5.0.0.dist-info/-0755rm
snowballstemmer/-0755rm
snowballstemmer-2.2.0.dist-info/-0755rm
sqlalchemy/-0755rm
SQLAlchemy-1.3.24.dist-info/-0755rm
ssa/-0755rm
svgwrite/-0755rm
svgwrite-1.4.3.dist-info/-0755rm
tap/-0755rm
tap.py-3.1.dist-info/-0755rm
testfixtures/-0755rm
testfixtures-7.1.0.dist-info/-0755rm
toml/-0755rm
toml-0.10.2.dist-info/-0755rm
tomlkit/-0755rm
tomlkit-0.11.8.dist-info/-0755rm
typing_extensions-4.7.1.dist-info/-0755rm
unshare-0.22.dist-info/-0755rm
urllib3/-0755rm
urllib3-2.0.3.dist-info/-0755rm
vendors_api/-0755rm
virtualenv/-0755rm
virtualenv-20.21.1.dist-info/-0755rm
wcwidth/-0755rm
wcwidth-0.2.6.dist-info/-0755rm
wheel/-0755rm
wheel-0.37.0.dist-info/-0755rm
wmt/-0755rm
wrapt/-0755rm
wrapt-1.15.0.dist-info/-0755rm
xray/-0755rm
yaml/-0755rm
yarl/-0755rm
yarl-1.9.2.dist-info/-0755rm
_distutils_hack/-0755rm
_pytest/-0755rm
_yaml/-0755rm
__pycache__/-0755rm
clcontrollib.py531400644editdlrm
cldetectlib.py188700644editdlrm
cldiaglib.py468720644editdlrm
clhooklib.py14320644editdlrm
cli_utils.py17780644editdlrm
cllicenselib.py80980644editdlrm
clsetuplib.py44220644editdlrm
clsudo.py150490644editdlrm
cl_proc_hidepid.py46790644editdlrm
cython.py5200644editdlrm
ddt.py152730644editdlrm
distutils-precedence.pth1510644editdlrm
docopt.py199460644editdlrm
lveapi.py199760644editdlrm
lvectllib.py1045690644editdlrm
lvestat.py71060644editdlrm
mccabe.py106540644editdlrm
pep8ext_naming.py190520644editdlrm
py.py2630644editdlrm
pycodestyle.py1035010644editdlrm
pylve.cpython-311-x86_64-linux-gnu.so209280755editdlrm
remove_ubc.py56730755editdlrm
schema.py302210644editdlrm
secureio.py192500644editdlrm
simple_rpm.so72800755editdlrm
six.py345490644editdlrm
typing_extensions.py1110820644editdlrm
unshare.cpython-311-x86_64-linux-gnu.so184640755editdlrm
_pyrsistent_version.py230644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/clsudo.py (15049B)
# coding=utf-8 # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import pwd import grp import re import subprocess import tempfile from stat import S_IRUSR, S_IRGRP class NoSuchUser(Exception): def __init__(self, user): #message = 'No such user (%s)' % user Exception.__init__(self, 'No such user (%s)' % (user,)) class NoSuchGroup(Exception): def __init__(self, group): message = 'No such group (%s)' % group Exception.__init__(self, message) class UnableToReadFile(Exception): def __init__(self): Exception.__init__(self, 'Cannot read sudoers file') class UnableToWriteFile(Exception): def __init__(self): Exception.__init__(self, 'Cannot modify sudoers file') SUDOERS_FILE = '/etc/sudoers' ALIAS_LVECTL_CMDS = ["/bin/ps", "/bin/grep", "/sbin/service", "/usr/bin/getcontrolpaneluserspackages", "/usr/sbin/lvectl", "/usr/local/directadmin/plugins/new_lvemanager/admin/GetDomains", "/usr/share/l.v.e-manager/utils/cloudlinux-cli.py"] ALIAS_LVECTL_USER_CMDS = ["/usr/share/l.v.e-manager/utils/cloudlinux-cli-user.py"] ALIAS_SELECTOR_CMDS = ["/usr/bin/cl-selector", "/usr/bin/piniset", "/usr/sbin/lveps", "/usr/bin/selectorctl"] DEFAULTS_REQUIRETTY = 'Defaults:%s !requiretty' # Patterns for group GROUP_LVECTL_SELECTOR = '%%%s ALL=NOPASSWD: LVECTL_CMDS, SELECTOR_CMDS' GROUP_DEFAULTS_REQUIRETTY = 'Defaults:%%%s !requiretty' class Clsudo: """ Adds CloudLinux users to sudoers file """ filepath = None sudoers_list = [] has_action = False has_group_action = False has_alias = False has_user_alias = False has_rights = False has_user_rights = False has_selector_alias = False has_selector_rights = False has_cagefs_alias = False has_cagefs_rights = False @staticmethod def add_user(user, sudoers_file=SUDOERS_FILE): """ Adds username to sudoers file (for lvemanager) """ # Update command lists for lvemanager Clsudo.update_commands_list(sudoers_file) Clsudo._check_user(user) Clsudo._get_contents(user) if not Clsudo.has_alias: Clsudo.sudoers_list.append('Cmnd_Alias LVECTL_CMDS = ' + ", ".join(ALIAS_LVECTL_CMDS)) if not Clsudo.has_user_alias: Clsudo.sudoers_list.append('Cmnd_Alias LVECTL_USER_CMDS = ' + ", ".join(ALIAS_LVECTL_USER_CMDS)) if not Clsudo.has_selector_alias: Clsudo.sudoers_list.append('Cmnd_Alias SELECTOR_CMDS = ' + ", ".join(ALIAS_SELECTOR_CMDS)) if not Clsudo.has_rights: Clsudo.sudoers_list.append('%s ALL=NOPASSWD: LVECTL_CMDS' % (user,)) if not Clsudo.has_user_rights: Clsudo.sudoers_list.append('%s ALL=(ALL) NOPASSWD: LVECTL_USER_CMDS' % (user,)) if not Clsudo.has_selector_rights: Clsudo.sudoers_list.append('%s ALL=NOPASSWD: SELECTOR_CMDS' % (user,)) if not Clsudo.has_action: Clsudo.sudoers_list.append(DEFAULTS_REQUIRETTY % (user,)) Clsudo._write_contents() @staticmethod def add_cagefs_user(user, sudoers_file=SUDOERS_FILE): """ Adds username to sudoers file (for cagefs) """ Clsudo.filepath = sudoers_file Clsudo._check_user(user) Clsudo._get_contents(user) if not Clsudo.has_cagefs_alias: Clsudo.sudoers_list.append('Cmnd_Alias CAGEFS_CMDS = /usr/sbin/cagefsctl, ' '/bin/ps, /bin/grep, /sbin/service') if not Clsudo.has_cagefs_rights: Clsudo.sudoers_list.append('%s ALL=NOPASSWD: CAGEFS_CMDS' % (user,)) if not Clsudo.has_action: Clsudo.sudoers_list.append(DEFAULTS_REQUIRETTY % (user,)) Clsudo._write_contents() @staticmethod def add_lvemanager_group(group_name, sudoers_file=SUDOERS_FILE): """ Adds group to sudoers file, grants access to LVE Manager """ # Update command lists for lvemanager Clsudo.update_commands_list(sudoers_file) Clsudo._check_group(group_name) Clsudo._get_contents_group(group_name) if not Clsudo.has_alias: Clsudo.sudoers_list.append('Cmnd_Alias LVECTL_CMDS = ' + ", ".join(ALIAS_LVECTL_CMDS)) if not Clsudo.has_selector_alias: Clsudo.sudoers_list.append('Cmnd_Alias SELECTOR_CMDS = ' + ", ".join(ALIAS_SELECTOR_CMDS)) if not Clsudo.has_action: Clsudo.sudoers_list.append(GROUP_LVECTL_SELECTOR % (group_name,)) if not Clsudo.has_group_action: Clsudo.sudoers_list.append(GROUP_DEFAULTS_REQUIRETTY % (group_name,)) # writes file Clsudo._write_contents() @staticmethod def remove_user(user, sudoers_file=SUDOERS_FILE): """ Removes username from sudoers file """ Clsudo.filepath = sudoers_file try: f = open(Clsudo.filepath) Clsudo.sudoers_list = f.read().splitlines() f.close() idx = 0 removed = False while idx < len(Clsudo.sudoers_list): line = Clsudo.sudoers_list[idx] if (('%s ALL=NOPASSWD:' % (user,)) in line) or ((DEFAULTS_REQUIRETTY % (user,))in line): Clsudo.sudoers_list.remove(line) removed = True continue idx += 1 if removed: Clsudo._write_contents() except (IOError, OSError): raise UnableToReadFile() @staticmethod def update_user(user, sudoers_file=SUDOERS_FILE): """ updates username in sudoers file :param user: username for caching :param sudoers_file: path to /etc/sudoers (only for tests) :return: None """ # Update command lists Clsudo.update_commands_list(sudoers_file) # For backward compatibility # Check user presence in system Clsudo._check_user(user) Clsudo._get_contents(user) @staticmethod def update_commands_list(sudoers_file=SUDOERS_FILE): """ Update command lists for lvemanager plugin If any required command absent in file, add it :param sudoers_file: path to /etc/sudoers :return: None """ # Read /etc/sudoers Clsudo.filepath = sudoers_file Clsudo.temp_dir = os.path.dirname(Clsudo.filepath) Clsudo._read_sudoers() cmnd_dict = {"Cmnd_Alias LVECTL_CMDS": ALIAS_LVECTL_CMDS, "Cmnd_Alias SELECTOR_CMDS": ALIAS_SELECTOR_CMDS} is_sudoer_change = False for idx in range(len(Clsudo.sudoers_list)): command_string = Clsudo.sudoers_list[idx] for aliase_key, aliase_list in cmnd_dict.items(): if aliase_key in command_string: command_string = command_string.replace(aliase_key, "").strip() cmnd_list = command_string.split(",") for aliase_cmnd_item in aliase_list: if aliase_cmnd_item not in cmnd_list: is_sudoer_change = True Clsudo.sudoers_list[idx] = "{0} = {1}".format( aliase_key, ", ".join(aliase_list) ) break if is_sudoer_change: Clsudo._write_contents() @staticmethod def _check_user(user): """ Checks passwd database for username presence @param user: string """ try: pwd.getpwnam(user) except KeyError: raise NoSuchUser(user) @staticmethod def _check_group(group_name): """ Checks grp database for group_name presence @param group_name: string """ try: grp.getgrnam(group_name) except KeyError: raise NoSuchGroup(group_name) @staticmethod def _read_sudoers(): i = open(Clsudo.filepath) Clsudo.sudoers_list = i.read().splitlines() i.close() @staticmethod def _get_contents(user): """ Reads file into list of strings @param user: string """ # Clear all status flags Clsudo.has_action = False Clsudo.has_group_action = False Clsudo.has_alias = False Clsudo.has_user_alias = False Clsudo.has_rights = False Clsudo.has_user_rights = False Clsudo.has_selector_alias = False Clsudo.has_selector_rights = False Clsudo.has_cagefs_alias = False Clsudo.has_cagefs_rights = False require_tty_pattern = re.compile(r'Defaults:\s*%s\s*!requiretty' % user) try: # Read sudoers file Clsudo._read_sudoers() for idx in range(len(Clsudo.sudoers_list)): if "Cmnd_Alias LVECTL_CMDS" in Clsudo.sudoers_list[idx]: Clsudo.has_alias = True continue if "Cmnd_Alias LVECTL_USER_CMDS" in Clsudo.sudoers_list[idx]: Clsudo.has_user_alias = True continue if "Cmnd_Alias CAGEFS_CMDS" in Clsudo.sudoers_list[idx]: Clsudo.has_cagefs_alias = True continue if "%s ALL=NOPASSWD: LVECTL_CMDS" % (user,) in Clsudo.sudoers_list[idx]: Clsudo.has_rights = True continue if "%s ALL=(ALL) NOPASSWD: LVECTL_USER_CMDS" % (user,) in Clsudo.sudoers_list[idx]: Clsudo.has_user_rights = True continue if "%s ALL=NOPASSWD: CAGEFS_CMDS" % (user,) in Clsudo.sudoers_list[idx]: Clsudo.has_cagefs_rights = True continue if "requiretty" in Clsudo.sudoers_list[idx]: pattern_match = require_tty_pattern.search(Clsudo.sudoers_list[idx]) if pattern_match: Clsudo.has_action = True continue if "Cmnd_Alias SELECTOR_CMDS" in Clsudo.sudoers_list[idx]: if 'piniset' not in Clsudo.sudoers_list[idx]: Clsudo.sudoers_list[idx] = Clsudo.sudoers_list[idx].replace( '/usr/bin/cl-selector', '/usr/bin/cl-selector, /usr/bin/piniset') if 'lveps' not in Clsudo.sudoers_list[idx]: Clsudo.sudoers_list[idx] = Clsudo.sudoers_list[idx].replace( '/usr/bin/cl-selector, /usr/bin/piniset', '/usr/bin/cl-selector, /usr/bin/piniset, /usr/sbin/lveps') Clsudo.has_selector_alias = True continue if "%s ALL=NOPASSWD: SELECTOR_CMDS" % (user,) in Clsudo.sudoers_list[idx]: Clsudo.has_selector_rights = True continue except (IOError, OSError): raise UnableToReadFile() @staticmethod def _get_contents_group(group_name): """ Reads file into list of strings @param group_name: string """ # Clear all status flags Clsudo.has_action = False Clsudo.has_group_action = False Clsudo.has_alias = False Clsudo.has_rights = False Clsudo.has_selector_alias = False Clsudo.has_selector_rights = False Clsudo.has_cagefs_alias = False Clsudo.has_cagefs_rights = False group_prefix = "%%%s" % group_name group_action = "Defaults:%%%s" % group_name group_pattern = re.compile(r'%s\s*ALL=NOPASSWD:\s*LVECTL_CMDS,\s*SELECTOR_CMDS' % (group_name,)) try: # Read sudoers file Clsudo._read_sudoers() for idx in range(len(Clsudo.sudoers_list)): if "Cmnd_Alias SELECTOR_CMDS" in Clsudo.sudoers_list[idx]: if 'piniset' not in Clsudo.sudoers_list[idx]: Clsudo.sudoers_list[idx] = Clsudo.sudoers_list[idx].replace( '/usr/bin/cl-selector', '/usr/bin/cl-selector, /usr/bin/piniset') if 'lveps' not in Clsudo.sudoers_list[idx]: Clsudo.sudoers_list[idx] = Clsudo.sudoers_list[idx].replace( '/usr/bin/cl-selector, /usr/bin/piniset', '/usr/bin/cl-selector, /usr/bin/piniset, /usr/sbin/lveps') Clsudo.has_selector_alias = True continue if "Cmnd_Alias LVECTL_CMDS" in Clsudo.sudoers_list[idx]: Clsudo.has_alias = True continue if "Cmnd_Alias CAGEFS_CMDS" in Clsudo.sudoers_list[idx]: Clsudo.has_cagefs_alias = True continue if Clsudo.sudoers_list[idx].startswith(group_prefix): pattern_match = group_pattern.search(Clsudo.sudoers_list[idx]) if pattern_match: Clsudo.has_action = True if Clsudo.sudoers_list[idx].startswith(group_action): Clsudo.has_group_action = True except (IOError, OSError): raise UnableToReadFile() @staticmethod def _write_contents(): """ Writes data to temporary file then checks it and rewrites sudoers file """ try: temp_dir = os.path.dirname(Clsudo.filepath) temp_prefix = 'lve_sudoers_' fd, temp_path = tempfile.mkstemp(prefix=temp_prefix, dir=temp_dir) fo = os.fdopen(fd, 'w') fo.write('\n'.join(Clsudo.sudoers_list) + '\n') fo.close() mask = S_IRUSR | S_IRGRP os.chmod(temp_path, mask) if not Clsudo._is_file_valid(temp_path): raise IOError except (IOError, OSError): try: if os.path.exists(temp_path): os.unlink(temp_path) except: pass raise UnableToWriteFile() try: os.rename(temp_path, Clsudo.filepath) except OSError: raise UnableToWriteFile() @staticmethod def _is_file_valid(filename): cmd = [ '/usr/sbin/visudo', '-c', '-f', filename ] rv = subprocess.Popen( cmd, stdin=open('/dev/null'), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) rv.communicate() if rv.returncode != 0: return False return True