From 9e7a3b7a0454bc79e02b1bf1cda5454e840253bd Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 9 Nov 2012 08:57:33 -0500 Subject: [PATCH] ENH: until we make it proper module -- adjust sys.path only if system-wide run --- fail2ban-client | 4 +++- fail2ban-regex | 4 +++- fail2ban-server | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fail2ban-client b/fail2ban-client index 66b90333..780efcfd 100755 --- a/fail2ban-client +++ b/fail2ban-client @@ -33,7 +33,9 @@ import getopt, time, shlex, socket # Inserts our own modules path first in the list # fix for bug #343821 -sys.path.insert(1, "/usr/share/fail2ban") +if os.path.abspath(__file__).startswith('/usr/'): + # makes sense to use system-wide library iff -client is also under /usr/ + sys.path.insert(1, "/usr/share/fail2ban") # Now we can import our modules from common.version import version diff --git a/fail2ban-regex b/fail2ban-regex index 0d634b70..fb083c21 100755 --- a/fail2ban-regex +++ b/fail2ban-regex @@ -29,7 +29,9 @@ import getopt, sys, time, logging, os # Inserts our own modules path first in the list # fix for bug #343821 -sys.path.insert(1, "/usr/share/fail2ban") +if os.path.abspath(__file__).startswith('/usr/'): + # makes sense to use system-wide library iff -regex is also under /usr/ + sys.path.insert(1, "/usr/share/fail2ban") from client.configparserinc import SafeConfigParserWithIncludes from ConfigParser import NoOptionError, NoSectionError, MissingSectionHeaderError diff --git a/fail2ban-server b/fail2ban-server index f6f1dac4..dab2d24e 100755 --- a/fail2ban-server +++ b/fail2ban-server @@ -32,7 +32,9 @@ import getopt, sys, logging # Inserts our own modules path first in the list # fix for bug #343821 -sys.path.insert(1, "/usr/share/fail2ban") +if os.path.abspath(__file__).startswith('/usr/'): + # makes sense to use system-wide library iff -server is also under /usr/ + sys.path.insert(1, "/usr/share/fail2ban") from common.version import version from server.server import Server