| Summary: | net-analyzer/fail2ban init script does not detect stale socket | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | steveb <steeeeeveee> |
| Component: | New packages | Assignee: | Gentoo Linux bug wranglers <bug-wranglers> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | enhancement | ||
| Priority: | High | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
*** This bug has been marked as a duplicate of bug 168071 *** (In reply to comment #1) > > *** This bug has been marked as a duplicate of bug 168071 *** > Thanks |
fail2ban creates a socket (normally in /tmp/fail2ban.sock). If fail2ban crashes then it leaves a stale socket and restarting or starting fail2ban fails. Adding something like that fixes this issue: --- ./fail2ban 2007-12-04 23:23:51.907181347 +0100 +++ ./fail2ban.org 2007-12-04 23:28:19.145708460 +0100 @@ -29,7 +29,26 @@ after iptables } +del_stale_socket() { + if [ -f /etc/fail2ban/fail2ban.conf ] + then + local fail2ban_socket="$(sed -n "s:^[\t ]*socket[\t ]*=[\t ]*\([^\t ]*\).*:\1:Ip" /etc/fail2ban/fail2ban.conf)" + if [ "${fail2ban_socket}" != "" ] + then + if [ -S "${fail2ban_socket}" ] + then + if ( ! lsof "${fail2ban_socket}" >/dev/null 2>&1 ) + then + einfo "Removing stale socket: ${fail2ban_socket}" + rm -f ${fail2ban_socket} >/dev/null 2>&1 + fi + fi + fi + fi +} + start() { + del_stale_socket ebegin "Starting fail2ban" ${FAIL2BAN} start &> /dev/null eend $? "Failed to start fail2ban" Reproducible: Always