PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
| Dir : /opt/imunify360/venv/lib64/python3.11/site-packages/im360/internals/core/firewall/ |
| Server: Linux cloud.virginhosting.lk 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64 IP: 128.140.68.198 |
| Dir : //opt/imunify360/venv/lib64/python3.11/site-packages/im360/internals/core/firewall/exe.py |
"""Resolve firewall binary paths to absolute locations."""
import logging
import os
from functools import lru_cache
logger = logging.getLogger(__name__)
_SEARCH_DIRS = ("/usr/sbin", "/usr/bin", "/sbin", "/bin")
@lru_cache(maxsize=None)
def _find_executable(name: str) -> str:
"""Resolve *name* to an absolute path by checking well-known directories
first, then ``$PATH``. Returns the bare *name* as a fallback."""
for dir_ in _SEARCH_DIRS:
path = os.path.join(dir_, name)
if os.path.isfile(path) and os.access(path, os.X_OK):
return path
for dir_ in os.environ.get("PATH", "").split(os.pathsep):
if not dir_:
continue
path = os.path.join(dir_, name)
if os.path.isfile(path) and os.access(path, os.X_OK):
return path
logger.error(
"Cannot find executable '%s' in PATH %s",
name,
os.environ.get("PATH"),
)
return name
def get_iptables_exe():
return _find_executable("iptables")
def get_ip6tables_exe():
return _find_executable("ip6tables")
def get_iptables_restore_exe():
return _find_executable("iptables-restore")
def get_ip6tables_restore_exe():
return _find_executable("ip6tables-restore")