Submit
Path:
~
/
/
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
im360
/
subsys
/
panels
/
directadmin
/
File Content:
custombuild.py
import asyncio import logging import functools import os from defence360agent.subsys.panels.base import PanelException from defence360agent.subsys.panels.directadmin.config import ConfigOptions from defence360agent.utils import check_run, CheckRunError logger = logging.getLogger(__name__) BASEDIR = "/usr/local/directadmin/custombuild" BUILD = os.path.join(BASEDIR, "build") class CustomBuildOptions(ConfigOptions): DEFAULT_FILENAME = os.path.join(BASEDIR, "options.conf") async def build(option): MAX_RETRIES = 3 for attempt in range(MAX_RETRIES + 1): try: return await check_run([BUILD, option], cwd=BASEDIR) except CheckRunError as e: if attempt == MAX_RETRIES: raise PanelException( "Failed to run custombuild command '{} {}' after {}" " attempts: {}".format(BUILD, option, MAX_RETRIES, e) ) if "Another instance of custombuild" in str(e): logger.warning( "Failed to run custombuild command '%s %s': %s", BUILD, option, e, ) logger.info("Retrying custombuild command after delay...") await asyncio.sleep(5) else: raise PanelException( "Failed to run custombuild command '{} {}': {}".format( BUILD, option, e ) ) def custombuild2_only(fun): @functools.wraps(fun) async def wrapper(*args, **kwargs): try: out = await build("version") except (CheckRunError, FileNotFoundError, PermissionError): pass else: if out.startswith(b"2."): return await fun(*args, **kwargs) raise PanelException( "{} is only supported on installations " "with Custombuild 2.0".format(fun.__name__) ) return wrapper
Submit
FILE
FOLDER
Name
Size
Permission
Action
__pycache__
---
0755
__init__.py
58 bytes
0644
custombuild.py
2019 bytes
0644
mod_security.py
14132 bytes
0644
panel.py
3028 bytes
0644
remoteip.py
258 bytes
0644
N4ST4R_ID | Naxtarrr