Commit Graph

101 Commits (749e5b46946df6533d2c4b29cf421b640c13b3d1)

Author SHA1 Message Date
Sylvestre Ledru 42ade49724 New upstream version 1.0.1 2022-09-27 07:28:37 -10:00
Sylvestre Ledru d422bceb0e New upstream version 0.11.2 2020-11-26 13:47:25 +01:00
Sylvestre Ledru ad3e0d97c4 New upstream version 0.11.1 2020-01-12 23:22:54 +01:00
sebres f8f01d5ab7 introduced new option `ignorecache` to improve performance of ignore failure check (using caching of `ignoreip`, `ignoreself` and `ignorecommand`) 2018-07-09 14:58:39 +02:00
sebres 1b4ba602ba normalize bool conversion, introduced common helper function `_as_bool` 2018-04-26 16:48:23 +02:00
sebres e786dbf132 New logging parameter `padding`, default enabled, excepting the SYSLOG (for backwards compatibility purposes);
Closes gh-2099.
2018-04-03 17:58:17 +02:00
sebres a3739bbf27 trim name and add one space after padding 2018-03-07 16:25:54 +01:00
sebres bf6667d4da better (sane) stop server handling, AsyncServer.stop_communication back-ported to 0.10 (cherry-picked from 0.11); 2017-12-06 01:38:39 +01:00
sebres aa9cefc3f8 proper stop server in the test cases (quit should stop all server-side threads, also if server was not really started);
fix-up for run_with_except_hook: avoid very sporadic error "'NoneType' object has no attribute 'exc_info'" (https://bugs.python.org/issue7336),
only extremely fast systems are affected ATM (2.x / 3.x), if thread ends nothing is available in .
2017-12-06 01:09:04 +01:00
sebres 1bf6636446 Introduced new parameters for logging within fail2ban-server;
Usage `logtarget = target[facility=..., datetime=on|off, format="..."]`:
  - `facility` - specify syslog facility (default `daemon`, see https://docs.python.org/2/library/logging.handlers.html#sysloghandler
     for the list of facilities);
  - `datetime` - add date-time to the message (default on, ignored if `format` specified);
  - `format` - specify own format how it will be logged, for example for short-log into STDOUT:
      `fail2ban-server -f --logtarget 'stdout[format="%(relativeCreated)5d | %(message)s"]' start`;
Closes gh-1980
2017-12-05 18:54:21 +01:00
sebres af0f7e93ce better handling by start/stop of server in foreground mode;
don't call logging.shutdown because part of exit in fail2bancmdline.
2017-11-26 23:06:35 +01:00
sebres f31195a4fc added new logtarget "SYSOUT" to log from fail2ban working in foreground as systemd-service (in opposite to "STDOUT" don't log time-stamps). 2017-11-26 23:03:29 +01:00
Georges Racinet e8f2173904 New logtimezone jail option
This new option allows to force the time zone on log lines
that don't bear a time zone indication (GitHub issue #1773), so it behaves
actually with respect to log line contents as a default time zone.

For the time being, only fixed offset timezones (UTC or UTC[+-]hhmm) are
supported, but the implementation is designed to later on treat the case
of logical timezones with DST, e.g., Europe/Paris etc.

In particular, the timezone name gets passed all the way to the strptime
module, and the resulting offset is computed for the given log line, even
though for now, it doesn't actually depend on it.

Also, the DateTemplate subclass gets to choose whether to use it or not.
For instance, it doesn't make sense to apply a time zone offset to
Unix timestamps.

The drawback is to introduce an API change for DateTemplate. I hope it's
internal enough for that not being a problem.
2017-05-23 17:39:37 +02:00
Sander Hoentjen 2a4dafce5b don't call setLogTarget from setSyslogSocket when holding the lock
If we do, setLogTarget will wait for the lock, but it will never be released
2017-05-08 14:11:07 +02:00
sebres 5e93bf9bd3 Introduced new option "ignoreself", specifies whether the local resp. own IP addresses should be ignored (default is true).
Fail2ban will not ban a host which matches such addresses.

Option "ignoreip" affects additionally to "ignoreself" and don't need to include the DNS resp. IPs of the host self.
2017-03-23 15:52:31 +01:00
sebres 4ff8d051f4 Introduced new filter option `prefregex` for pre-filtering using single regular expression;
Some filters extended with user name;
[filter.d/pam-generic.conf]: grave fix injection on user name to host fixed;
test-cases in testSampleRegexsFactory can now check the captured groups (using additionally fields in failJSON structure)
2017-02-20 16:54:17 +01:00
sebres 45174c5eaf if fail2ban running as systemd-service, for logging to the systemd-journal, the `logtarget` could be set to STDOUT
small fixes by logging in stdout (+ system targets also allowed in lowercase now)
2016-11-24 12:13:47 +01:00
sebres 7f8c48d59e code review (e. g. remove code duplication) and coverage 2016-10-15 00:39:25 +02:00
sebres 1ef367e77a fixes log format by starting server with `--loglevel=debug` without specifying of verbosity level 2016-10-14 23:30:12 +02:00
sebres 98f87a1a52 better server-ready event: notify waiting thread if server really ready (communication ready) or failed to start 2016-10-14 22:50:30 +02:00
sebres 2cfaf845ca standardize and normalize logging and verbosity formats, logging level etc between command lines (server, client, test-cases);
test cases could pass (so increase) verbosity to the client (and furthermore client to the server also), usable for debug purposes resp. simplifying read of the log-file;
custom and precise numeric log-levels can be given in test cases now;
2016-09-29 21:23:37 +02:00
sebres ab0c28260b switch down log level for some annoying messages to tracedebug or heavydebug (to 7 or even 5);
added verification of specified log-level before transmitting to the server;
numeric log-level allowed now in server (resp. fail2ban.conf);
2016-09-22 22:44:46 +02:00
sebres d153555a07 increase default wait operation (sleep time, threshold interval) - avowedly greater inertance, but fewer system load by many jails resp. log files;
waiting with `wait_for` extended with verifying of active flag;
implemented better error handling in some multi-threaded routines;
shutdown of jails rewritten (faster and safer, does not breaks shutdown process if some error occurred);
2016-09-22 18:10:42 +02:00
sebres 8c4eebc3e3 reload actions amend, code review and test cases extended for update/start/stop of actions by reloading 2016-09-09 10:45:09 +02:00
sebres 4fb511294e temp commit: reload now supported actions and action reloading (parameters, unban obsolete removed actions, etc.) 2016-09-08 23:56:32 +02:00
sebres b12a3acb06 temp commit: reload not ready... 2016-09-07 21:07:50 +02:00
sebres ae38b626d1 Merge branch '_0.9/fix-systemd-convert-gh-1341' into 0.10 2016-09-06 15:30:08 +02:00
sebres 57458a462e allow to set default or preferred encoding for other filters (e.g. to decode bytes from journal)
# Conflicts:
#	fail2ban/server/filter.py
2016-09-06 15:26:10 +02:00
Yaroslav Halchenko 87acd7a0fc RF: Replace old fashioned "except E , e" with "except E as e" (Closes #1537)
0.10 specific
supplement to b875e51cd7 in master AKA 0.9
2016-09-06 08:18:34 -04:00
Yaroslav Halchenko b875e51cd7 RF: Replace old fashioned "except E , e" with "except E as e" (Closes #1537) 2016-09-04 23:25:09 -04:00
Yaroslav Halchenko dfcf6f1963 BF+TST: isStarted was not checking __asyncServer for exist before checking it 2016-07-12 22:53:37 -04:00
Yaroslav Halchenko 52cd8a9a96 RF: _rebindSignal helper to centralize assignment of new signal handlers + minor PEP8ing 2016-07-12 22:24:56 -04:00
sebres 4180cc362e code review 2016-07-11 13:22:58 +02:00
sebres 4c1bcac0c7 Merge branch '0.10' into f2b-perfom-prepare-716-cs-0.10 2016-07-11 11:28:34 +02:00
sebres cb280b817f csocket multi-set fix: prevent to convert `list`, `dict`, `set` during transfer (send), this offers a sending of 'multi-set' arrays
(missed by cherry-picking from multi-set branch)
2016-05-13 22:43:02 +02:00
sebres 53956501da increase readability and details level by increased verbosity 2016-05-12 11:53:12 +02:00
sebres 0b4143730d some compatibility fixes (prevent forking of testcase-process, code review), wait 4 server ready, test cases fixed (py2/py3) 2016-05-12 11:52:02 +02:00
sebres 2fcb6358ff several bug fixed: fork in client-server test cases prohibited, all worker threads daemonized (to prevent hanging on exit). 2016-05-12 11:51:59 +02:00
sebres afa1cdc3ae client/server (bin) test cases introduced, ultimate closes #1121, closes #1139
small code review and fixing of some bugs during client-server communication process (in the test cases);
2016-05-12 11:51:56 +02:00
sebres 5a053f4b74 starting of the server (and client/server communication behavior during start and daemonize) completely rewritten:
- client/server functionality moved away from bin and using now the common interface (introduced in fail2bancmdline);
  - start in foreground fixed;
  - server can act as client corresponding command line;
  - command "restart" added: in opposite to "reload" in reality restarts the server (new process);
  - several client/server bugs during starting process fixed.
2016-05-12 11:51:53 +02:00
sebres 4ce240ed40 try to start server in foreground
# Conflicts:
#	fail2ban/server/server.py
2016-05-12 11:51:47 +02:00
sebres 1a6450643d partially cherry pick from branch 'multi-set', prepare for conditional config parameters logic:
- new readers logic (group some by multiple parameters 'set' -> 'multi-set';
- prevent to add 'known/' parameters twice (by merge section etc);
- test cases fixed;

# Conflicts:
#	fail2ban/client/actionreader.py
2016-05-11 16:54:20 +02:00
sebres f143ae479c code and config review after rebase to current master 2015-12-29 12:49:37 +01:00
sebres 6faffe3201 test cases extended, code review (+ python 3.x compatibility);
database test cases extended - enable deleted (disabled) jail in addJail;
2015-12-29 12:49:27 +01:00
Yaroslav Halchenko 78eb4d95eb RF: is_alive -> isAlive to stay consistent in camelCasing 2015-12-29 12:49:21 +01:00
sebres 59bf5013c0 - performance of fail2ban optimized
-- cache dnsToIp, ipToName to prevent long wait during retrieving of ip/name for wrong dns or lazy dns-system;
   -- instead of simple "sleep" used conditional wait "wait_for", that internal increases sleep interval up to sleeptime;
   -- ticket / banmanager / failmanager modules are performance optimized;
   -- api of filter (log files), jail, etc. rewritten and extended for performance purposes;
- performance of test cases optimized:
   -- added option "--fast" to decrease wait intervals, avoid passive waiting, and skip few very slow test cases;
- code review after partially cherry pick of branch 'ban-time-incr' (see gh-716)
   -- ticket module prepared to easy merge with newest version of 'ban-time-incr', now additionally holds banTime, banCount and json-data;
   -- executeCmd partially moved from action to new module utils, etc.
   -- python 2.6 compatibility;
- testExecuteTimeoutWithNastyChildren: test case repaired - wait for pid file inside bash, kill tree in any case (gh-1155);
- testSocket: test case repaired - wait for server thread starts a socket (listener)
2015-12-29 12:49:19 +01:00
sebres 410f9d7c10 filter, datedetector, datetemplate: performance optimizing of combination datedetector.matchTime/getTime2, because early getTime search a template and call template.matchTime again (so the date parsing was really executed twice, now just once);
debug logging optimized;
added info line log "Start Fail2ban ..." after changed logging target;
2015-12-29 12:49:06 +01:00
Yaroslav Halchenko dd9d1912e8 RF: Filter.getLogPaths -> getLogs
Since it returns log containers not paths per se
2015-12-02 22:49:47 -05:00
sebres 8a37a46fbb bug fix: option 'dbpurgeage' was never set (always default) by start of fail2ban, because of invalid sorting of options ('dbfile' should be always set before other database options) / closes #1048, closes #1050 2015-07-27 10:59:14 +02:00
Lee Clemens fdc3172aec Fix PEP8 E302 expected 2 blank lines, found X 2015-07-04 13:47:40 -04:00