From 9e7a3b7a0454bc79e02b1bf1cda5454e840253bd Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 9 Nov 2012 08:57:33 -0500 Subject: [PATCH 1/2] 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 From 03b31398aac4ff4edab992b5c3969712bb35858b Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 9 Nov 2012 08:58:19 -0500 Subject: [PATCH 2/2] ENH: BF (forgotten import) for prev commit + removed duplicate Author, adjusted __ fields for that in fail2ban-* scripts --- fail2ban-client | 8 +------- fail2ban-regex | 10 ++-------- fail2ban-server | 10 ++-------- fail2ban-testcases | 6 +----- setup.py | 6 ------ 5 files changed, 6 insertions(+), 34 deletions(-) diff --git a/fail2ban-client b/fail2ban-client index 780efcfd..1d8eb15e 100755 --- a/fail2ban-client +++ b/fail2ban-client @@ -18,13 +18,7 @@ # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# Author: Cyril Jaquier -# -# $Revision$ - __author__ = "Cyril Jaquier" -__version__ = "$Revision$" -__date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" @@ -71,7 +65,7 @@ class Fail2banClient: def dispVersion(self): print "Fail2Ban v" + version print - print "Copyright (c) 2004-2008 Cyril Jaquier" + print "Copyright (c) 2004-2008 Cyril Jaquier, 2008- Fail2Ban Contributors" print "Copyright of modifications held by their respective authors." print "Licensed under the GNU General Public License v2 (GPL)." print diff --git a/fail2ban-regex b/fail2ban-regex index fb083c21..3900c909 100755 --- a/fail2ban-regex +++ b/fail2ban-regex @@ -15,14 +15,8 @@ # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# Author: Cyril Jaquier -# -# $Revision$ - -__author__ = "Cyril Jaquier" -__version__ = "$Revision$" -__date__ = "$Date$" -__copyright__ = "Copyright (c) 2004 Cyril Jaquier" +__author__ = "Cyril Jaquier, Yaroslav Halchenko" +__copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2012 Yaroslav Halchenko" __license__ = "GPL" import getopt, sys, time, logging, os diff --git a/fail2ban-server b/fail2ban-server index dab2d24e..bd86e6cd 100755 --- a/fail2ban-server +++ b/fail2ban-server @@ -18,17 +18,11 @@ # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# Author: Cyril Jaquier -# -# $Revision$ - __author__ = "Cyril Jaquier" -__version__ = "$Revision$" -__date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import getopt, sys, logging +import getopt, sys, logging, os # Inserts our own modules path first in the list # fix for bug #343821 @@ -63,7 +57,7 @@ class Fail2banServer: def dispVersion(self): print "Fail2Ban v" + version print - print "Copyright (c) 2004-2008 Cyril Jaquier" + print "Copyright (c) 2004-2008 Cyril Jaquier, 2008- Fail2Ban Contributors" print "Copyright of modifications held by their respective authors." print "Licensed under the GNU General Public License v2 (GPL)." print diff --git a/fail2ban-testcases b/fail2ban-testcases index 58ad7887..aaf78525 100755 --- a/fail2ban-testcases +++ b/fail2ban-testcases @@ -20,12 +20,8 @@ # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# Author: Cyril Jaquier - __author__ = "Cyril Jaquier" -__version__ = "$Revision$" -__date__ = "$Date$" -__copyright__ = "Copyright (c) 2004 Cyril Jaquier" +__copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2012- Yaroslav Halchenko" __license__ = "GPL" diff --git a/setup.py b/setup.py index 8cb17133..53b03f0f 100755 --- a/setup.py +++ b/setup.py @@ -18,13 +18,7 @@ # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# Author: Cyril Jaquier -# -# $Revision$ - __author__ = "Cyril Jaquier" -__version__ = "$Revision$" -__date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL"