From: <los...@us...> - 2007-01-04 23:34:35
|
Revision: 515 http://svn.sourceforge.net/fail2ban/?rev=515&view=rev Author: lostcontrol Date: 2007-01-04 15:34:35 -0800 (Thu, 04 Jan 2007) Log Message: ----------- - Added signal handling in fail2ban-client - Added a wonderful visual effect when waiting on the server - Improved error message. Thanks to Yaroslav Halchenko Modified Paths: -------------- trunk/CHANGELOG trunk/fail2ban-client trunk/fail2ban-server Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-01-04 13:10:44 UTC (rev 514) +++ trunk/CHANGELOG 2007-01-04 23:34:35 UTC (rev 515) @@ -4,9 +4,14 @@ |_| \__,_|_|_/___|_.__/\__,_|_||_| ============================================================= -Fail2Ban (version 0.7.6) 2007/01/04 +Fail2Ban (version 0.7.7) 2007/??/?? ============================================================= +ver. 0.7.7 (2007/??/??) +---------- +- Added signal handling in fail2ban-client +- Added a wonderful visual effect when waiting on the server + ver. 0.7.6 (2007/01/04) - beta ---------- - Added a "sleep 1" in redhat-initd. Thanks to Jim Wight Modified: trunk/fail2ban-client =================================================================== --- trunk/fail2ban-client 2007-01-04 13:10:44 UTC (rev 514) +++ trunk/fail2ban-client 2007-01-04 23:34:35 UTC (rev 515) @@ -25,7 +25,7 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import sys, string, os, pickle, re, logging +import sys, string, os, pickle, re, logging, signal import getopt, time, readline, shlex, socket # Inserts our own modules path first in the list @@ -87,7 +87,7 @@ print " -i interactive mode" print " -v increase verbosity" print " -q decrease verbosity" - print " -x force execution of the server" + print " -x force execution of the server (remove socket file)" print " -h, --help display this help message" print " -V, --version print the version" print @@ -103,7 +103,13 @@ print "Fail2Ban v" + version + " reads log file that contains password failure report" print "and bans the corresponding IP addresses using firewall rules." print - + + def __sigTERMhandler(self, signum, frame): + # Print a new line because we probably come from wait + print + logSys.warn("Caught signal %d. Exiting" % signum) + sys.exit(-1) + def __getCmdLineOptions(self, optList): """ Gets the command line options """ @@ -180,7 +186,11 @@ self.__processCmd(self.__stream, False) return True except ServerExecutionException: - logSys.error("Could not start server. Try -x option") + logSys.error("Could not start server. Maybe an old " + + "socket file is still present. Try to " + + "remove " + self.__conf["socket"] + ". If " + + "you used fail2ban-client to start the " + + "server, adding the -x option will do it") return False elif len(cmd) == 1 and cmd[0] == "reload": if self.__ping(): @@ -229,18 +239,40 @@ def __waitOnServer(self): # Wait for the server to start cnt = 0 + if self.__conf["verbose"] > 1: + pos = 0 + delta = 1 + mask = "[ ]" while not self.__ping(): + # Wonderful visual :) + if self.__conf["verbose"] > 1: + pos += delta + sys.stdout.write("\rINFO " + mask[:pos] + '#' + mask[pos+1:] + + " Waiting on the server...") + sys.stdout.flush() + if pos > len(mask)-3: + delta = -1 + elif pos < 2: + delta = 1 # The server has 30 secondes to start. if cnt >= 300: + if self.__conf["verbose"] > 1: + sys.stdout.write('\n') raise ServerExecutionException("Failed to start server") time.sleep(0.1) cnt += 1 + if self.__conf["verbose"] > 1: + sys.stdout.write('\n') def start(self, argv): # Command line options self.__argv = argv + # Install signal handlers + signal.signal(signal.SIGTERM, self.__sigTERMhandler) + signal.signal(signal.SIGINT, self.__sigTERMhandler) + # Reads the command line options. try: cmdOpts = 'hc:s:xdviqV' Modified: trunk/fail2ban-server =================================================================== --- trunk/fail2ban-server 2007-01-04 13:10:44 UTC (rev 514) +++ trunk/fail2ban-server 2007-01-04 23:34:35 UTC (rev 515) @@ -78,7 +78,7 @@ print " -b start in background" print " -f start in foreground" print " -s <FILE> socket path" - print " -x force execution of the server" + print " -x force execution of the server (remove socket file)" print " -h, --help display this help message" print " -V, --version print the version" print This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |