mirror of https://github.com/fail2ban/fail2ban
improve fix with fallback to local async libraries - add path to compat folder (pyinotify module may have dependency to asyncore module, see https://github.com/fail2ban/fail2ban/issues/3487#issuecomment-2133529081);
amend to 054e1d89ca
pull/3407/head
parent
7d2fffbe19
commit
304c3cd566
|
@ -40,6 +40,14 @@ except:
|
|||
_libcap = None
|
||||
|
||||
|
||||
# some modules (like pyinotify, see #3487) may have dependency to asyncore, so ensure we've a path
|
||||
# to compat folder, otherwise python 3.12+ could miss them:
|
||||
def __extend_compat_path():
|
||||
cp = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'compat')
|
||||
if cp not in sys.path:
|
||||
sys.path.append(cp)
|
||||
__extend_compat_path()
|
||||
|
||||
PREFER_ENC = locale.getpreferredencoding()
|
||||
# correct preferred encoding if lang not set in environment:
|
||||
if PREFER_ENC.startswith('ANSI_'): # pragma: no cover
|
||||
|
|
|
@ -25,14 +25,6 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
|||
__license__ = "GPL"
|
||||
|
||||
from pickle import dumps, loads, HIGHEST_PROTOCOL
|
||||
try:
|
||||
import asynchat
|
||||
except ImportError:
|
||||
from ..compat import asynchat
|
||||
try:
|
||||
import asyncore
|
||||
except ImportError:
|
||||
from ..compat import asyncore
|
||||
import errno
|
||||
import fcntl
|
||||
import os
|
||||
|
@ -45,6 +37,13 @@ from .utils import Utils
|
|||
from ..protocol import CSPROTO
|
||||
from ..helpers import logging, getLogger, formatExceptionInfo
|
||||
|
||||
# load asyncore and asynchat after helper to ensure we've a path to compat folder:
|
||||
import asynchat
|
||||
if asynchat.asyncore:
|
||||
asyncore = asynchat.asyncore
|
||||
else: # pragma: no cover - normally unreachable
|
||||
import asyncore
|
||||
|
||||
# Gets the instance of the logger.
|
||||
logSys = getLogger(__name__)
|
||||
|
||||
|
|
|
@ -27,14 +27,15 @@ import logging
|
|||
import os
|
||||
from os.path import dirname, sep as pathsep
|
||||
|
||||
import pyinotify
|
||||
|
||||
from .failmanager import FailManagerEmpty
|
||||
from .filter import FileFilter
|
||||
from .mytime import MyTime, time
|
||||
from .utils import Utils
|
||||
from ..helpers import getLogger
|
||||
|
||||
# pyinotify may have dependency to asyncore, so import it after helper to ensure
|
||||
# we've a path to compat folder:
|
||||
import pyinotify
|
||||
|
||||
# Verify that pyinotify is functional on this system
|
||||
# Even though imports -- might be dysfunctional, e.g. as on kfreebsd
|
||||
|
|
Loading…
Reference in New Issue