ÿØÿà JFIF ÿþ; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 157.90.209.209 / Your IP : 216.73.216.185 [ Web Server : Apache System : Linux hcomm124.dns-wk.info 4.18.0-553.64.1.el8_10.x86_64 #1 SMP Mon Jul 28 12:01:56 EDT 2025 x86_64 User : evidenciarevista ( 1049) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Domains : 216 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /opt/imunify360/venv/share/imunify360/scripts/migrate_csf/ |
Upload File : |
import re from logger_config import get_logger def get_csf_config_value( var_name: str, config_file="/etc/csf/csf.conf" ) -> str | None: logger = get_logger() try: with open(config_file, "r") as f: for line in f: # Strip whitespace and skip empty lines and comments line = line.strip() if not line or line.startswith("#"): continue # Match pattern: VAR_NAME = "value" (with flexible whitespace) # This regex handles: # - Optional whitespace around = (e.g. VAR_NAME="value" or VAR_NAME= "value") # - Quoted values (double quotes, single quotes are not valid in CSF config) # - Captures the value inside quotes (e.g. "value") pattern = rf'^{re.escape(var_name)}\s*=\s*["]([^"]*)["]' match = re.match(pattern, line) if match: return match.group(1) # Variable not found return None except FileNotFoundError: logger.error(f"Config file {config_file} not found") return None except PermissionError: logger.error(f"Permission denied reading {config_file}") return None except Exception as e: logger.error(f"Error reading config file: {e}") return None