From owner-freebsd-ports-bugs@freebsd.org Sat May 20 21:07:52 2017 Return-Path: Delivered-To: freebsd-ports-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F31ED760F9 for ; Sat, 20 May 2017 21:07:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 63CB7A35 for ; Sat, 20 May 2017 21:07:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v4KL7qc5078955 for ; Sat, 20 May 2017 21:07:52 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-ports-bugs@FreeBSD.org Subject: [Bug 219419] security/py-fail2ban: Command not found Date: Sat, 20 May 2017 21:07:52 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: lukasz@wasikowski.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-ports-bugs@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 May 2017 21:07:52 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D219419 --- Comment #2 from Lukasz Wasikowski --- (In reply to theis from comment #1) /usr/local/bin/fail2ban-python points to /usr/local/bin/python2.7, so that's ok. But you are missing the point - default FreeBSD installation (which I w= ill show you in a second) won't work with shabang set to #!/usr/bin/env fail2ban-python because there is no /usr/local/bin/ in PATH, so env can't f= ind fail2ban-python. man 8 service says: ENVIRONMENT When used to run rc.d scripts the service command sets HOME to / and P= ATH to /sbin:/bin:/usr/sbin:/usr/bin which is how they are set in /etc/rc = at boot time. I've created clean environment for fail2ban test. 1. FreeBSD 11.0-RELEASE was installed from official ISO - default settings (without IPv6) and updated via freebsd-update fetch install: root@fail2ban-test:~ # freebsd-version 11.0-RELEASE-p10 2. pkg was installed: root@fail2ban-test:~ # pkg version pkg-1.10.1 > 3. fail2ban was installed: root@fail2ban-test:~ # pkg install py27-fail2ban Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 9 package(s) will be affected (of 0 checked): [...] root@fail2ban-test:~ # pkg query %v py27-fail2ban 0.9.6 root@fail2ban-test:~ # ls -l `which fail2ban-python` lrwxr-xr-x 1 root wheel 24 Apr 30 10:24 /usr/local/bin/fail2ban-python -> /usr/local/bin/python2.7 4. fail2ban configuration: root@fail2ban-test:~ # cat /usr/local/etc/fail2ban/jail.local [DEFAULT] backend =3D auto ignorecommands_dir =3D /usr/local/etc/fail2ban/filter.d/ignorecommands [test-fakegb] enabled =3D true filter =3D apache-fakegooglebot action =3D pf[tablename=3Dfail2ban-www] logpath =3D /var/log/test-access.log maxretry =3D 1 ignorecommand =3D %(ignorecommands_dir)s/apache-fakegooglebot 5. Prepare fake apache log: root@fail2ban-test:~ # touch /var/log/test-access.log 6. Enable fail2ban and reboot. root@fail2ban-test:~ # echo 'fail2ban_enable=3D"YES"' >> /etc/rc.conf && re= boot 7. Start pf firewall (all open, doesn't matter in test case): root@fail2ban-test:~ # cat /etc/pf.conf table persist pass all root@fail2ban-test:~ # service pf onestart Enabling pf. 8. Check date (fail2ban by default will act on record from last 600 seconds= ): root@fail2ban-test:~ # date Sat May 20 23:04:47 CEST 2017 9. Simulate fake Googlebot: echo '10.10.100.111 [20/May/2017:23:04:00 +0200] Googlebot' >> /var/log/test-access.log 10. Look at fail2ban log: root@fail2ban-test:~ # cat /var/log/fail2ban.log 2017-05-20 23:03:36,588 fail2ban.server [552]: INFO Changed logg= ing target to /var/log/fail2ban.log for Fail2ban v0.9.6 2017-05-20 23:03:36,590 fail2ban.database [552]: INFO Connected to fail2ban persistent database '/var/db/fail2ban/fail2ban.sqlite3' 2017-05-20 23:03:36,592 fail2ban.database [552]: WARNING New database created. Version '2' 2017-05-20 23:03:36,593 fail2ban.jail [552]: INFO Creating new jail 'test-fakegb' 2017-05-20 23:03:36,596 fail2ban.jail [552]: INFO Jail 'test-fakegb' uses poller {} 2017-05-20 23:03:36,614 fail2ban.jail [552]: INFO Initiated 'polling' backend 2017-05-20 23:03:36,616 fail2ban.filter [552]: INFO Added logfil= e =3D /var/log/test-access.log 2017-05-20 23:03:36,616 fail2ban.filter [552]: INFO Set maxRetry= =3D 1 2017-05-20 23:03:36,617 fail2ban.filter [552]: INFO Set jail log file encoding to US-ASCII 2017-05-20 23:03:36,617 fail2ban.actions [552]: INFO Set banTime = =3D 600 2017-05-20 23:03:36,617 fail2ban.filter [552]: INFO Set findtime= =3D 600 2017-05-20 23:03:36,622 fail2ban.jail [552]: INFO Jail 'test-fakegb' started 2017-05-20 23:05:05,458 fail2ban.filter [552]: INFO Log rotation detected for /var/log/test-access.log 2017-05-20 23:05:05,570 fail2ban.action [552]: ERROR=20=20 /usr/local/etc/fail2ban/filter.d/ignorecommands/apache-fakegooglebot 10.10.100.111 -- stdout: '' 2017-05-20 23:05:05,570 fail2ban.action [552]: ERROR=20=20 /usr/local/etc/fail2ban/filter.d/ignorecommands/apache-fakegooglebot 10.10.100.111 -- stderr: 'env: fail2ban-python: No such file or directory\n' 2017-05-20 23:05:05,570 fail2ban.action [552]: ERROR=20=20 /usr/local/etc/fail2ban/filter.d/ignorecommands/apache-fakegooglebot 10.10.100.111 -- returned 127 2017-05-20 23:05:05,570 fail2ban.action [552]: INFO HINT on 127: "Command not found". Make sure that all commands in '/usr/local/etc/fail2ban/filter.d/ignorecommands/apache-fakegooglebot 10.10.100.111' are in the PATH of fail2ban-server process (grep -a PATH=3D /proc/`pidof -x fail2ban-server`/environ). You may want to start "fail2ban-server -f" separately, initiate it with "fail2ban-client reload" = in another shell session and observe if additional informative error messages appear in the terminals. 2017-05-20 23:05:05,571 fail2ban.filter [552]: INFO [test-fakegb] Found 10.10.100.111 2017-05-20 23:05:06,514 fail2ban.actions [552]: NOTICE [test-fakegb] Ban 10.10.100.111 As you can see this problem is not local to my FreeBSD servers. --=20 You are receiving this mail because: You are the assignee for the bug.=