Fail2ban python regex issue

pathiaki2 pathiaki2 at
Sat Jul 23 21:07:02 UTC 2016


I'm extending fail2ban to catch things on FreeBSD.

Right now I'm looking at dovecot.

This is the standard file.

# Fail2Ban filter Dovecot authentication and pop3/imap server


before = common.conf


_daemon = (auth|dovecot(-auth)?|auth-worker)

failregex = 
failure; logname=\S* uid=\S* euid=\S* tty=dovecot ruser=\S* 
             ^%(__prefix_line)s(pop3|imap)-login: (Info: )?(Aborted 
login|Disconnected)(: Inactivity)? \(((auth failed, \d+ attempts)( in 
\d+ secs)?|tried to use (disabled|disallowed) \S+ auth)\):( 
user=<\S*>,)?( method=\S+,)? rip=<HOST>(, lip=(\d{1,3}\.){3}\d{1,3})?(, 
TLS( handshaking(: SSL_accept\(\) failed: error:[\dA-F]+:SSL 
routines:[TLS\d]+_GET_CLIENT_HELLO:unknown protocol)?)?(: 
Disconnected)?)?(, session=<\S+>)?\s*$
auth\(default\)|auth-worker\(\d+\)): pam\(\S+,<HOST>\): 
pam_authenticate\(\) failed: (User not known to the underlying 
authentication module: \d+ Time\(s\)|Authentication failure \(password 
(pam|passwd-file)\(\S+,<HOST>\): unknown user\s*$
             ^%(__prefix_line)s(auth|auth-worker\(\d+\)): Info: 
ldap\(\S*,<HOST>,\S*\): invalid credentials\s*$

ignoreregex =


journalmatch = _SYSTEMD_UNIT=dovecot.service

I have a line I want to match.  However, every python interpreter that I 
hit says this works....  However, fail2ban doesn't catch the line.

The line:

Jul 23 00:02:48 <machine FQDN> dovecot: auth: 
ldap(valeria, unknown user (SHA1 of given password: 

I'm trying this:

^%(__prefix_line)s(: auth: ldap\(\S+,<HOST>\):) unknown user\s*$

What am I missing?  There's no error with the interpreter, it's just not 
matching the line.

More information about the freebsd-questions mailing list