/opt/imunify360/venv/bin
#!/opt/imunify360/venv/bin/python3 import argparse import os import re import subprocess from pam_i360.internals import logger_init PUREFTPD_CONFIG = "/etc/pure-ftpd.conf" CPANEL_CONFIG = "/var/cpanel/cpanel.config" IMUNIFY360_CONFIG = "/etc/sysconfig/imunify360/imunify360-merged.config" logger = logger_init() def is_pureftpd_enabled(): if not os.path.isfile(IMUNIFY360_CONFIG): return False ftp_protection = re.compile( rb"^(?!#).*ftp_protection:[^\S\r\n]*true", re.MULTILINE ) return ftp_protection.search( open(IMUNIFY360_CONFIG, "rb").read()) is not None def is_imunify360_pam_pureftpd_enabled(): imunify360_sock = re.compile( rb"^(?!#).*\/var\/run\/ftpd.imunify360.sock", re.MULTILINE ) return imunify360_sock.search( open(PUREFTPD_CONFIG, "rb").read()) is not None def enable_pureftpd(no_restart=False, timeout=60): cmd = [ "/usr/sbin/imunify360-pam", "enable-pureftpd", ] if no_restart: cmd.append("--no-restart-pureftpd") try: return subprocess.run(cmd, timeout=timeout, check=True) except subprocess.TimeoutExpired as e: return subprocess.CompletedProcess( e.cmd, returncode=None, stdout=e.stdout, stderr=e.stderr ) def main(): parser = argparse.ArgumentParser() parser.add_argument( "-n", "--no-restart", dest="norestart", action="store_true", help="Don't restart pureftpd", ) args = parser.parse_args() no_restart = args.norestart with open(CPANEL_CONFIG, "r") as cpcfg: data = cpcfg.read() if not "ftpserver=pure-ftpd" in data: return if not os.path.isfile(PUREFTPD_CONFIG): return imunify360_pam_pureftpd_enabled = is_imunify360_pam_pureftpd_enabled() pureftpd_enabled = is_pureftpd_enabled() if pureftpd_enabled and not imunify360_pam_pureftpd_enabled: enable_pureftpd(no_restart, timeout=60) if __name__ == "__main__": try: main() except Exception as e: logger.error("failed to check and enable pure-ftpd: %s", e)
.
Edit
..
Edit
Activate.ps1
Edit
__pycache__
Edit
activate
Edit
activate.csh
Edit
activate.fish
Edit
distro
Edit
docutils
Edit
imunify360-command-wrapper
Edit
imunify360_pam.py
Edit
jsonschema
Edit
normalizer
Edit
pam_pureftpd_hook.py
Edit
pip
Edit
pip3
Edit
pip3.11
Edit
pw-migrate
Edit
pw_migrate
Edit
pwiz.py
Edit
pybabel
Edit
python
Edit
python3
Edit
python3.11
Edit
rst2html.py
Edit
rst2html4.py
Edit
rst2html5.py
Edit
rst2latex.py
Edit
rst2man.py
Edit
rst2odt.py
Edit
rst2odt_prepstyles.py
Edit
rst2pseudoxml.py
Edit
rst2s5.py
Edit
rst2xetex.py
Edit
rst2xml.py
Edit
rstpep2html.py
Edit