[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: setup_cagefs.py
File is not writable. Editing disabled.
#!/opt/imunify360/venv/bin/python3 # coding: utf-8 """ WARNING cagefs --remount-all can cause high load on customers server and even temporary outage (See DEF-9491) Please only add anything to cagefs.mp only if absolutely nesassary """ import subprocess import sys from im360.subsys import clcagefs CAGEFSMP = '/etc/cagefs/cagefs.mp' CAGEFSCTL_TOOL = '/usr/sbin/cagefsctl' ACTUAL_DIRS = { b'/var/imunify360/files/sigs': { 'added_by': "imunify360", 'prefix': b'!' }, b'/etc/imunify360/user_config': { 'added_by': "imunify360", 'mode': 0o755, # every user has his own isolated dir in this dir 'prefix': b'%' }, b'/var/run/imunify360_user': { 'added_by': "imunify360", 'mode': 0o1755 }, } OBSOLETES_DIRS = [ b"/var/imunify360/malware/signatures", b"/var/imunify360/scan_report", b"/var/imunify360/web_quar", b"/var/lib/clamav", b"/var/run/defence360agent", ] def _cagefs_remountall(action_info): def _read_mp_file(): try: with open(CAGEFSMP) as f: return f.read() except FileNotFoundError: print("%s file was not found", CAGEFSMP) return "" def decorator(fun): def wrapper(*args, **kwargs): before = _read_mp_file() try: return fun(*args, **kwargs) finally: after = _read_mp_file() if before != after: print("CageFS for Imunify has been %s, remounting..." % action_info) try: subprocess.call([CAGEFSCTL_TOOL, "--remount-all"]) except Exception as e: print("Something went wrong while executing" " --remount-all command: %s", e) else: print("CageFS for Imunify: no update is required.") return wrapper return decorator def _add_imunify360_dirs(): for path, options in ACTUAL_DIRS.items(): try: clcagefs.setup_mount_dir_cagefs( path, remount_cagefs=False, **options) except (clcagefs.CagefsMpConflict, EnvironmentError) as e: sys.stderr.write("Failed to setup CageFS with " "Imunify for path %s: %s\n" % (path, e)) @_cagefs_remountall(action_info="set up") def _setup_cagefs(): _add_imunify360_dirs() _remove_obsoleted() @_cagefs_remountall(action_info="reset") def _revert_cagefs(): # here we assume that OBSOLETES_DIRS have been already removed # during the installation step for path in ACTUAL_DIRS.keys(): try: clcagefs.remove_mount_dir_cagefs(path, remount_cagefs=False) except Exception as e: sys.stderr.write( 'Error during removing %s from cagefs.mp: %s\n' % (path, e)) def _remove_obsoleted(): for path in OBSOLETES_DIRS: try: clcagefs.remove_mount_dir_cagefs(path, remount_cagefs=False) except Exception as e: sys.stderr.write( 'Error during removing %s from cagefs.mp: %s\n' % (path, e)) def _main(): if sys.argv[-1] == '--revert': _revert_cagefs() else: _setup_cagefs() def _is_removemountdircagefs_supported(): return hasattr(clcagefs, 'remove_mount_dir_cagefs') if __name__ == '__main__': if clcagefs.is_cagefs_present() and _is_removemountdircagefs_supported(): _main()
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.31 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A