Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:danci1973
denyhosts
DenyHosts-2.6-foreground_mode.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File DenyHosts-2.6-foreground_mode.patch of Package denyhosts
Index: DenyHosts-2.6/DenyHosts/deny_hosts.py =================================================================== --- DenyHosts-2.6.orig/DenyHosts/deny_hosts.py +++ DenyHosts-2.6/DenyHosts/deny_hosts.py @@ -41,7 +41,7 @@ error = logging.getLogger("denyhosts").e class DenyHosts: def __init__(self, logfile, prefs, lock_file, ignore_offset=0, first_time=0, - noemail=0, daemon=0): + noemail=0, daemon=0, foreground=0): self.__denied_hosts = {} self.__prefs = prefs self.__lock_file = lock_file @@ -49,6 +49,7 @@ class DenyHosts: self.__noemail = noemail self.__report = Report(prefs.get("HOSTNAME_LOOKUP"), is_true(prefs['SYSLOG_REPORT'])) self.__daemon = daemon + self.__foreground = foreground self.__sync_server = prefs.get('SYNC_SERVER') self.__sync_upload = is_true(prefs.get("SYNC_UPLOAD")) self.__sync_download = is_true(prefs.get("SYNC_DOWNLOAD")) @@ -87,7 +88,7 @@ class DenyHosts: info("Log file size has not changed. Nothing to do.") - if daemon: + if daemon and not foreground: info("launching DenyHosts daemon (version %s)..." % VERSION) #logging.getLogger().setLevel(logging.WARN) @@ -101,6 +102,10 @@ class DenyHosts: self.runDaemon(logfile, last_offset) else: die("Error creating daemon: %s (%d)" % (retCode[1], retCode[0])) + elif foreground: + info("launching DenyHosts (version %s)..." % VERSION) + self.__lock_file.remove() + self.runDaemon(logfile, last_offset) def killDaemon(self, signum, frame): Index: DenyHosts-2.6/denyhosts.py =================================================================== --- DenyHosts-2.6.orig/denyhosts.py +++ DenyHosts-2.6/denyhosts.py @@ -33,6 +33,7 @@ def usage(): print " --migrate: migrate your HOSTS_DENY file so that it is suitable for --purge" print " --purge: expire entries older than your PURGE_DENY setting" print " --daemon: run DenyHosts in daemon mode" + print " --foreground: run DenyHosts in foreground mode" print " --sync: run DenyHosts synchronization mode" print " --version: Prints the version of DenyHosts and exits" @@ -62,6 +63,7 @@ if __name__ == '__main__': purge = 0 sync_mode = 0 daemon = 0 + foreground = 0 enable_debug = 0 upgrade099 = 0 args = sys.argv[1:] @@ -69,8 +71,8 @@ if __name__ == '__main__': (opts, getopts) = getopt.getopt(args, 'f:c:dinuvps?hV', ["file=", "ignore", "verbose", "debug", "help", "noemail", "config=", "version", - "migrate", "purge", "daemon", "sync", - "upgrade099"]) + "migrate", "purge", "daemon", "foreground", + "sync", "upgrade099"]) except: print "\nInvalid command line option detected." usage() @@ -100,6 +102,8 @@ if __name__ == '__main__': sync_mode = 1 if opt == '--daemon': daemon = 1 + if opt == '--foreground': + foreground = 1 if opt == '--upgrade099': upgrade099 = 1 if opt == '--version': @@ -130,21 +134,21 @@ if __name__ == '__main__': lock_file.create() - if upgrade099 and not daemon: + if upgrade099 and not (daemon or foreground): if not prefs.get('PURGE_DENY'): lock_file.remove() die("You have supplied the --upgrade099 flag, however you have not set PURGE_DENY in your configuration file") else: u = UpgradeTo099(prefs.get("HOSTS_DENY")) - if migrate and not daemon: + if migrate and not (daemon or foreground): if not prefs.get('PURGE_DENY'): lock_file.remove() die("You have supplied the --migrate flag however you have not set PURGE_DENY in your configuration file.") else: m = Migrate(prefs.get("HOSTS_DENY")) - if purge and not daemon: + if purge and not (daemon or foreground): purge_time = prefs.get('PURGE_DENY') if not purge_time: lock_file.remove() @@ -161,7 +165,9 @@ if __name__ == '__main__': try: for f in logfiles: dh = DenyHosts(f, prefs, lock_file, ignore_offset, - first_time, noemail, daemon) + first_time, noemail, daemon, foreground) + except KeyboardInterrupt: + pass except SystemExit, e: pass except Exception, e: @@ -169,7 +175,7 @@ if __name__ == '__main__': print "\nDenyHosts exited abnormally" - if sync_mode and not daemon: + if sync_mode and not (daemon or foreground): if not prefs.get('SYNC_SERVER'): lock_file.remove() die("You have provided the --sync flag however your configuration file is missing a value for SYNC_SERVER.")
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor