Sunday, February 17, 2013

Fail2ban-client ImportError

Fedora has proposed compacting the linux filesystem hierarchy by moving some of the top level directories to usr. I am currently in the process of upgrading my home server from Fedora 16 to 18. Recently, I encountered a problem with fail2ban-client. I get the following error
# fail2ban-client -h
Traceback (most recent call last):
  File "/bin/fail2ban-client", line 35, in 
    from common.version import version
ImportError: No module named common.version
also described here with full patch given here. Once this patch was manually applied it worked perfect. However, the changes were reseted when the next fail2ban update. Until Fedora fixes this problem, a better temporary workaround is to add the python path to sys.path by adding it to PYTHONPATH environment. Create the following file /etc/profile.d/fail2ban.sh containing:
if [ -z "${PYTHONPATH}" ]; then
   PYTHONPATH="/usr/share/fail2ban"
else
   PYTHONPATH="/usr/share/fail2ban:${PYTHONPATH}"
fi
export PYTHONPATH
Alternatively, swap the the order of /bin and /usr/bin in PATH by editing /etc/profile.

1 comment:

  1. This would be more useful for beginners with a bit of context. What does creating that sh file do? How is it run? Do you run it manually or does it become active on server restart?

    ReplyDelete