BF: do not rely on scripts being under /usr -- might differ eg on Fedora -- rely on import of common.version (Closes gh-112)

This is also not ideal, since if there happens to be some systemwide common.version -- we are doomed

but otherwise, we cannot keep extending comparison check to /bin, /sbin whatelse
pull/142/head
Yaroslav Halchenko 12 years ago committed by Orion Poplawski
parent 7fc83196b9
commit 1eb23cf8af

@ -27,12 +27,13 @@ import getopt, time, shlex, socket
# Inserts our own modules path first in the list # Inserts our own modules path first in the list
# fix for bug #343821 # fix for bug #343821
if os.path.abspath(__file__).startswith('/usr/'): try:
# makes sense to use system-wide library iff -client is also under /usr/ from common.version import version
except ImportError, e:
sys.path.insert(1, "/usr/share/fail2ban") sys.path.insert(1, "/usr/share/fail2ban")
from common.version import version
# Now we can import our modules # Now we can import the rest of modules
from common.version import version
from common.protocol import printFormatted from common.protocol import printFormatted
from client.csocket import CSocket from client.csocket import CSocket
from client.configurator import Configurator from client.configurator import Configurator

@ -26,13 +26,14 @@ import getopt, sys, time, logging, os
# Inserts our own modules path first in the list # Inserts our own modules path first in the list
# fix for bug #343821 # fix for bug #343821
if os.path.abspath(__file__).startswith('/usr/'): try:
# makes sense to use system-wide library iff -regex is also under /usr/ from common.version import version
sys.path.insert(1, "/usr/share/fail2ban") except ImportError, e:
sys.path.insert(1, "/usr/share/fail2ban")
from common.version import version
from client.configparserinc import SafeConfigParserWithIncludes from client.configparserinc import SafeConfigParserWithIncludes
from ConfigParser import NoOptionError, NoSectionError, MissingSectionHeaderError from ConfigParser import NoOptionError, NoSectionError, MissingSectionHeaderError
from common.version import version
from server.filter import Filter from server.filter import Filter
from server.failregex import RegexException from server.failregex import RegexException

@ -26,11 +26,12 @@ import getopt, sys, logging, os
# Inserts our own modules path first in the list # Inserts our own modules path first in the list
# fix for bug #343821 # fix for bug #343821
if os.path.abspath(__file__).startswith('/usr/'): try:
# makes sense to use system-wide library iff -server is also under /usr/ from common.version import version
except ImportError, e:
sys.path.insert(1, "/usr/share/fail2ban") sys.path.insert(1, "/usr/share/fail2ban")
from common.version import version
from common.version import version
from server.server import Server from server.server import Server
# Gets the instance of the logger. # Gets the instance of the logger.

Loading…
Cancel
Save