Skip to contentSkip to conversation

package/fail2ban: new package

PATCH Superseded Angelo Compagnucci 4 participants 8 messages Aug 22, 2018 – Nov 30, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/fail2ban: new package

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show malicious behaviours.

---
Changes:
v1->v2:
* Adding sha256 for license file
* getting service file for systemd from source directory

 package/Config.in              |  1 +
 package/fail2ban/Config.in     | 14 ++++++++++++++
 package/fail2ban/S60fail2ban   | 23 +++++++++++++++++++++++
 package/fail2ban/fail2ban.hash |  3 +++
 package/fail2ban/fail2ban.mk   | 28 ++++++++++++++++++++++++++++
 5 files changed, 69 insertions(+)
 create mode 100644 package/fail2ban/Config.in
 create mode 100644 package/fail2ban/S60fail2ban
 create mode 100644 package/fail2ban/fail2ban.hash
 create mode 100644 package/fail2ban/fail2ban.mk
package/Config.in +1 -0
index f5a1749..1783ab9 100644
@@ -1740,6 +1740,7 @@ menu "Networking applications"
 	source "package/ejabberd/Config.in"
 	source "package/ethtool/Config.in"
 	source "package/faifa/Config.in"
+	source "package/fail2ban/Config.in"
 	source "package/fastd/Config.in"
 	source "package/fcgiwrap/Config.in"
 	source "package/flannel/Config.in"
package/fail2ban/Config.in new file +14 -0
new file mode 100644
index 0000000..cf82526
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_FAIL2BAN
+	bool "fail2ban"
+	depends on BR2_PACKAGE_PYTHON
+	help
+	  Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs
+	  that show the malicious signs -- too many password failures, seeking
+	  for exploits, etc. Out of the box Fail2Ban comes with filters for
+	  various services (apache, courier, ssh, etc).
+
+	  Fail2Ban is able to reduce the rate of incorrect authentications
+	  attempts however it cannot eliminate the risk that weak authentication
+	  presents.
+
+	  https://www.fail2ban.org
package/fail2ban/S60fail2ban new file +23 -0
new file mode 100644
index 0000000..92559e9
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+case "$1" in
+	start)
+		printf "Starting fail2ban: "
+		start-stop-daemon -S -q -m -p /run/fail2ban.pid \
+			-b -x fail2ban-server -- -xf start
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	stop)
+		printf "Stopping fail2ban: "
+		start-stop-daemon -K -q -p /run/fail2ban.pid
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	restart)
+		"$0" stop
+		sleep 1
+		"$0" start
+		;;
+	*)
+		echo "Usage: $0 {start|stop|restart}"
+		;;
+esac
package/fail2ban/fail2ban.hash new file +3 -0
new file mode 100644
index 0000000..4b59091
@@ -0,0 +1,3 @@
+# sha256 locally computed
+sha256  7ee3fd0e94d58c94298718b25e6bcfa96932712b7aa683580e162403f68d40c8  fail2ban-0.10.3.1.tar.gz
+sha256  a75fec0260742fe6275d63ff6a5d97b924b28766558306b3fa4069763096929b  COPYING
package/fail2ban/fail2ban.mk new file +28 -0
new file mode 100644
index 0000000..cc6961f
@@ -0,0 +1,28 @@
+################################################################################
+#
+# fail2ban
+#
+################################################################################
+
+FAIL2BAN_VERSION = 0.10.3.1
+FAIL2BAN_SITE = $(call github,fail2ban,fail2ban,$(FAIL2BAN_VERSION))
+FAIL2BAN_LICENSE = GPL-2.0+
+FAIL2BAN_LICENSE_FILES = COPYING
+FAIL2BAN_SETUP_TYPE = setuptools
+FAIL2BAN_INSTALL_TARGET_OPTS = --root=$(TARGET_DIR) --prefix=/usr
+
+define FAIL2BAN_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 755 package/fail2ban/S60fail2ban \
+		$(TARGET_DIR)/etc/init.d/S60fail2ban
+endef
+
+define FAIL2BAN_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 0644 $(@D)/files/fail2ban.service.in \
+		$(TARGET_DIR)/usr/lib/systemd/system/fail2ban.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -fs ../../../../usr/lib//systemd/system/fail2ban.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/fail2ban.service
+	$(SED) 's/@BINDIR@/\/usr\/bin/g' $(TARGET_DIR)/usr/lib/systemd/system/fail2ban.service
+endef
+
+$(eval $(python-package))
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 package/fail2ban: new package

Hello,

+Yegor in Cc. Yegor: read all the way to the end, there is a question about the python-package infrastructure.

Quoted 4 lines · Angelo Compagnucci

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show malicious behaviours.

I was about to apply this patch (I even made a few minor fixes), but there is one thing that made me change my mind, see below. I will also list the minor issues.

Quoted 5 lines
 package/Config.in              |  1 +
 package/fail2ban/Config.in     | 14 ++++++++++++++
 package/fail2ban/S60fail2ban   | 23 +++++++++++++++++++++++
 package/fail2ban/fail2ban.hash |  3 +++
 package/fail2ban/fail2ban.mk   | 28 ++++++++++++++++++++++++++++

Entry in DEVELOPERS file missing.

package/fail2ban/Config.in line 3

Quoted 9 lines
package/fail2ban/Config.in new file +3 -0
new file mode 100644
index 0000000..cf82526
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_FAIL2BAN
+	bool "fail2ban"
+	depends on BR2_PACKAGE_PYTHON

Are you sure it doesn't work with Python 3.x ? The fail2ban github page says it does.

package/fail2ban/Config.in line 12

Quoted 9 lines
package/fail2ban/Config.in new file +9 -0
+	help
+	  Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs
+	  that show the malicious signs -- too many password failures, seeking
+	  for exploits, etc. Out of the box Fail2Ban comes with filters for
+	  various services (apache, courier, ssh, etc).
+
+	  Fail2Ban is able to reduce the rate of incorrect authentications
+	  attempts however it cannot eliminate the risk that weak authentication
+	  presents.

Aren't some of those lines too long? Could you verify with check-package

package/fail2ban/Config.in line 14

Quoted 2 lines
package/fail2ban/Config.in new file +2 -0
+
+	  https://www.fail2ban.org

Please add a Config.in comment about the Python dependency.

package/fail2ban/S60fail2ban line 6

Quoted 12 lines
package/fail2ban/S60fail2ban new file +6 -0
new file mode 100644
index 0000000..92559e9
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+case "$1" in
+	start)
+		printf "Starting fail2ban: "
+		start-stop-daemon -S -q -m -p /run/fail2ban.pid \

Put the PID file in /var/run, to be consistent with most of our other init scripts.

package/fail2ban/S60fail2ban line 12

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+			-b -x fail2ban-server -- -xf start
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	stop)
+		printf "Stopping fail2ban: "
+		start-stop-daemon -K -q -p /run/fail2ban.pid

Ditto.

package/fail2ban/S60fail2ban line 18

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+FAIL2BAN_VERSION = 0.10.3.1
+FAIL2BAN_SITE = $(call github,fail2ban,fail2ban,$(FAIL2BAN_VERSION))
+FAIL2BAN_LICENSE = GPL-2.0+
+FAIL2BAN_LICENSE_FILES = COPYING
+FAIL2BAN_SETUP_TYPE = setuptools
+FAIL2BAN_INSTALL_TARGET_OPTS = --root=$(TARGET_DIR) --prefix=/usr

So here is the one thing that made me change my mind. I was wondering:
why do we need to pass those options in the fail2ban package? Why aren't they passed by the python-package infrastructure?

Turns out that the Python package infrastructure is doing this:

PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
	--prefix=$(TARGET_DIR)/usr \
	--executable=/usr/bin/python \
	--single-version-externally-managed \
	--root=/
PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
	--prefix=$(STAGING_DIR)/usr \
	--executable=/usr/bin/python \
	--single-version-externally-managed \
	--root=/

This looks pretty wrong, and it seems like we should be using:

	--prefix=/usr \
	--root=$(TARGET_DIR)

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH v2 1/1 package/fail2ban: new package

Hi Thomas, Angelo,

Quoted 107 lines · Thomas Petazzoni

Hello,

+Yegor in Cc. Yegor: read all the way to the end, there is a question about the python-package infrastructure.

Quoted 4 lines · Angelo Compagnucci

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show malicious behaviours.

I was about to apply this patch (I even made a few minor fixes), but there is one thing that made me change my mind, see below. I will also list the minor issues.

Quoted 5 lines
 package/Config.in              |  1 +
 package/fail2ban/Config.in     | 14 ++++++++++++++
 package/fail2ban/S60fail2ban   | 23 +++++++++++++++++++++++
 package/fail2ban/fail2ban.hash |  3 +++
 package/fail2ban/fail2ban.mk   | 28 ++++++++++++++++++++++++++++

Entry in DEVELOPERS file missing.

package/fail2ban/Config.in line 3

Quoted 9 lines
package/fail2ban/Config.in new file +3 -0
new file mode 100644
index 0000000..cf82526
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_FAIL2BAN
+     bool "fail2ban"
+     depends on BR2_PACKAGE_PYTHON

Are you sure it doesn't work with Python 3.x ? The fail2ban github page says it does.

package/fail2ban/Config.in line 12

Quoted 9 lines
package/fail2ban/Config.in new file +9 -0
+     help
+       Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs
+       that show the malicious signs -- too many password failures, seeking
+       for exploits, etc. Out of the box Fail2Ban comes with filters for
+       various services (apache, courier, ssh, etc).
+
+       Fail2Ban is able to reduce the rate of incorrect authentications
+       attempts however it cannot eliminate the risk that weak authentication
+       presents.

Aren't some of those lines too long? Could you verify with check-package

package/fail2ban/Config.in line 14

Quoted 2 lines
package/fail2ban/Config.in new file +2 -0
+
+       https://www.fail2ban.org

Please add a Config.in comment about the Python dependency.

package/fail2ban/S60fail2ban line 6

Quoted 12 lines
package/fail2ban/S60fail2ban new file +6 -0
new file mode 100644
index 0000000..92559e9
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+case "$1" in
+     start)
+             printf "Starting fail2ban: "
+             start-stop-daemon -S -q -m -p /run/fail2ban.pid \

Put the PID file in /var/run, to be consistent with most of our other init scripts.

package/fail2ban/S60fail2ban line 12

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+                     -b -x fail2ban-server -- -xf start
+             [ $? = 0 ] && echo "OK" || echo "FAIL"
+             ;;
+     stop)
+             printf "Stopping fail2ban: "
+             start-stop-daemon -K -q -p /run/fail2ban.pid

Ditto.

package/fail2ban/S60fail2ban line 18

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+FAIL2BAN_VERSION = 0.10.3.1
+FAIL2BAN_SITE = $(call github,fail2ban,fail2ban,$(FAIL2BAN_VERSION))
+FAIL2BAN_LICENSE = GPL-2.0+
+FAIL2BAN_LICENSE_FILES = COPYING
+FAIL2BAN_SETUP_TYPE = setuptools
+FAIL2BAN_INSTALL_TARGET_OPTS = --root=$(TARGET_DIR) --prefix=/usr

So here is the one thing that made me change my mind. I was wondering:
why do we need to pass those options in the fail2ban package? Why aren't they passed by the python-package infrastructure?

Turns out that the Python package infrastructure is doing this:

PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
        --prefix=$(TARGET_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/
PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/

This looks pretty wrong, and it seems like we should be using:

Quoted 7 lines
        --prefix=/usr \
        --root=$(TARGET_DIR)

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

I've applied this hack:

package/pkg-python.mk +2 -2
index f57e486dad..fcb7309ef9 100644
@@ -66,10 +66,10 @@ PKG_PYTHON_SETUPTOOLS_ENV = \
        _python_exec_prefix=/usr
 
 PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
-       --prefix=$(TARGET_DIR)/usr \
+       --prefix=/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
-       --root=/
+       --root=$(TARGET_DIR)
 
 PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \

And performed some tests with following packages (both via python "console" and using packe own scripts like watchmedo or miniterm.py):

python-serial, python-watchdog, python-cryptography, python-pytablewriter

So far I haven't experienced any issues.

Regards,
Yegor

#3 lore raw

PATCH v2 1/1 package/fail2ban: new package

Hello,

Quoted 6 lines · Yegor Yefremov
Quoted 4 lines

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

I've applied this hack:

Why do you say "hack" ? It should be the right thing, compared to what we're doing today.

Quoted 7 lines
package/pkg-python.mk +0 -0
index f57e486dad..fcb7309ef9 100644
@@ -66,10 +66,10 @@ PKG_PYTHON_SETUPTOOLS_ENV = \
        _python_exec_prefix=/usr
 

package/pkg-python.mk PKG_PYTHON_SETUPTOOLS_ENV = \ · line 75

Quoted 10 lines
package/pkg-python.mk +2 -2
 PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
-       --prefix=$(TARGET_DIR)/usr \
+       --prefix=/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
-       --root=/
+       --root=$(TARGET_DIR)
 
 PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \

It should also be fixed in the staging installation commands, which have the same problem.

Quoted 6 lines

And performed some tests with following packages (both via python "console" and using packe own scripts like watchmedo or miniterm.py):

python-serial, python-watchdog, python-cryptography, python-pytablewriter

So far I haven't experienced any issues.

Great, thanks for doing this test! I think it would be a nice thing to fix.

Angelo: just curious, for fail2ban, what made you realize you had to override the --prefix and --root values ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 1/1 package/fail2ban: new package

Thomas, Yegor,

Quoted 40 lines · Thomas Petazzoni

Hello,

Quoted 6 lines · Yegor Yefremov
Quoted 4 lines

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

I've applied this hack:

Why do you say "hack" ? It should be the right thing, compared to what we're doing today.

Quoted 7 lines
package/pkg-python.mk +0 -0
index f57e486dad..fcb7309ef9 100644
@@ -66,10 +66,10 @@ PKG_PYTHON_SETUPTOOLS_ENV = \
        _python_exec_prefix=/usr
 

package/pkg-python.mk PKG_PYTHON_SETUPTOOLS_ENV = \ · line 75

Quoted 10 lines
package/pkg-python.mk +2 -2
 PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
-       --prefix=$(TARGET_DIR)/usr \
+       --prefix=/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
-       --root=/
+       --root=$(TARGET_DIR)
 
 PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \

It should also be fixed in the staging installation commands, which have the same problem.

Quoted 5 lines

And performed some tests with following packages (both via python "console" and using packe own scripts like watchmedo or miniterm.py):

python-serial, python-watchdog, python-cryptography, python-pytablewriter

Quoted 7 lines
Quoted 1 line

So far I haven't experienced any issues.

Great, thanks for doing this test! I think it would be a nice thing to fix.

Angelo: just curious, for fail2ban, what made you realize you had to override the --prefix and --root values ?

Python setuptools installs data_files into python_root, so the fail2ban setup.py failed blatantly in buildroot trying to writing something to /etc/fail2ban instead of $(TARGET_DIR)/etc/fail2ban.

I'm glad it will be fixed globally, I honestly thought it was like that for a reason!

Sincerely, Angelo

Quoted 8 lines

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#5 lore raw

PATCH v2 1/1 package/fail2ban: new package

In reply to Thomas Petazzoni

Hi Thomas,
Il giorno mar 11 set 2018 alle ore 00:05 Thomas Petazzoni <[email protected]> ha scritto:

Quoted 24 lines

Hello,

+Yegor in Cc. Yegor: read all the way to the end, there is a question about the python-package infrastructure.

Quoted 4 lines · Angelo Compagnucci

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show malicious behaviours.

I was about to apply this patch (I even made a few minor fixes), but there is one thing that made me change my mind, see below. I will also list the minor issues.

Quoted 5 lines
 package/Config.in              |  1 +
 package/fail2ban/Config.in     | 14 ++++++++++++++
 package/fail2ban/S60fail2ban   | 23 +++++++++++++++++++++++
 package/fail2ban/fail2ban.hash |  3 +++
 package/fail2ban/fail2ban.mk   | 28 ++++++++++++++++++++++++++++

Entry in DEVELOPERS file missing.

Quoted 12 lines

package/fail2ban/Config.in line 3

Quoted 9 lines
package/fail2ban/Config.in new file +3 -0
new file mode 100644
index 0000000..cf82526
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_FAIL2BAN
+     bool "fail2ban"
+     depends on BR2_PACKAGE_PYTHON

Are you sure it doesn't work with Python 3.x ? The fail2ban github page says it does.

Probably it say so, but simply trying to run the software with python3:

File "/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/fail2ban-0.10.4/fail2ban/__init__.py",
line 85, in _init
for i in xrange(50):
NameError: name 'xrange' is not defined

Quoted 90 lines

package/fail2ban/Config.in line 12

Quoted 10 lines
package/fail2ban/Config.in new file +9 -0
+     help
+       Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs
+       that show the malicious signs -- too many password failures, seeking
+       for exploits, etc. Out of the box Fail2Ban comes with filters for
+       various services (apache, courier, ssh, etc).
+
+       Fail2Ban is able to reduce the rate of incorrect authentications
+       attempts however it cannot eliminate the risk that weak authentication
+       presents.

Aren't some of those lines too long? Could you verify with check-package

package/fail2ban/Config.in line 14

Quoted 2 lines
package/fail2ban/Config.in new file +2 -0
+
+       https://www.fail2ban.org

Please add a Config.in comment about the Python dependency.

package/fail2ban/S60fail2ban line 6

Quoted 12 lines
package/fail2ban/S60fail2ban new file +6 -0
new file mode 100644
index 0000000..92559e9
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+case "$1" in
+     start)
+             printf "Starting fail2ban: "
+             start-stop-daemon -S -q -m -p /run/fail2ban.pid \

Put the PID file in /var/run, to be consistent with most of our other init scripts.

package/fail2ban/S60fail2ban line 12

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+                     -b -x fail2ban-server -- -xf start
+             [ $? = 0 ] && echo "OK" || echo "FAIL"
+             ;;
+     stop)
+             printf "Stopping fail2ban: "
+             start-stop-daemon -K -q -p /run/fail2ban.pid

Ditto.

package/fail2ban/S60fail2ban line 18

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+FAIL2BAN_VERSION = 0.10.3.1
+FAIL2BAN_SITE = $(call github,fail2ban,fail2ban,$(FAIL2BAN_VERSION))
+FAIL2BAN_LICENSE = GPL-2.0+
+FAIL2BAN_LICENSE_FILES = COPYING
+FAIL2BAN_SETUP_TYPE = setuptools
+FAIL2BAN_INSTALL_TARGET_OPTS = --root=$(TARGET_DIR) --prefix=/usr

So here is the one thing that made me change my mind. I was wondering:
why do we need to pass those options in the fail2ban package? Why aren't they passed by the python-package infrastructure?

Turns out that the Python package infrastructure is doing this:

PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
        --prefix=$(TARGET_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/
PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/

This looks pretty wrong, and it seems like we should be using:

        --prefix=/usr \
        --root=$(TARGET_DIR)

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 1 line
Profile: http://it.linkedin.com/in/compagnucciangelo
#6 lore raw

PATCH v2 1/1 package/fail2ban: new package

Hi Angelo,

Quoted 41 lines · Angelo Compagnucci

Hi Thomas,
Il giorno mar 11 set 2018 alle ore 00:05 Thomas Petazzoni <[email protected]> ha scritto:

Quoted 24 lines

Hello,

+Yegor in Cc. Yegor: read all the way to the end, there is a question about the python-package infrastructure.

Quoted 4 lines · Angelo Compagnucci

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show malicious behaviours.

I was about to apply this patch (I even made a few minor fixes), but there is one thing that made me change my mind, see below. I will also list the minor issues.

Quoted 5 lines
 package/Config.in              |  1 +
 package/fail2ban/Config.in     | 14 ++++++++++++++
 package/fail2ban/S60fail2ban   | 23 +++++++++++++++++++++++
 package/fail2ban/fail2ban.hash |  3 +++
 package/fail2ban/fail2ban.mk   | 28 ++++++++++++++++++++++++++++

Entry in DEVELOPERS file missing.

Quoted 12 lines

package/fail2ban/Config.in line 3

Quoted 9 lines
package/fail2ban/Config.in new file +3 -0
new file mode 100644
index 0000000..cf82526
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_FAIL2BAN
+     bool "fail2ban"
+     depends on BR2_PACKAGE_PYTHON

Are you sure it doesn't work with Python 3.x ? The fail2ban github page says it does.

Quoted 6 lines

Probably it say so, but simply trying to run the software with python3:

File "/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/fail2ban-0.10.4/fail2ban/__init__.py",
line 85, in _init
for i in xrange(50):
NameError: name 'xrange' is not defined

This was fixed in [1], but it seems like if you'll have wait till the next release.

[1] https://github.com/fail2ban/fail2ban/commit/657b147c0d7830f3600f3dc7feaa4815a7e19fde#diff-ac23116c0e156f1acc787e57fe98391c

Yegor

Quoted 99 lines
Quoted 81 lines

package/fail2ban/Config.in line 12

Quoted 10 lines
package/fail2ban/Config.in new file +9 -0
+     help
+       Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs
+       that show the malicious signs -- too many password failures, seeking
+       for exploits, etc. Out of the box Fail2Ban comes with filters for
+       various services (apache, courier, ssh, etc).
+
+       Fail2Ban is able to reduce the rate of incorrect authentications
+       attempts however it cannot eliminate the risk that weak authentication
+       presents.

Aren't some of those lines too long? Could you verify with check-package

package/fail2ban/Config.in line 14

Quoted 2 lines
package/fail2ban/Config.in new file +2 -0
+
+       https://www.fail2ban.org

Please add a Config.in comment about the Python dependency.

package/fail2ban/S60fail2ban line 6

Quoted 12 lines
package/fail2ban/S60fail2ban new file +6 -0
new file mode 100644
index 0000000..92559e9
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+case "$1" in
+     start)
+             printf "Starting fail2ban: "
+             start-stop-daemon -S -q -m -p /run/fail2ban.pid \

Put the PID file in /var/run, to be consistent with most of our other init scripts.

package/fail2ban/S60fail2ban line 12

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+                     -b -x fail2ban-server -- -xf start
+             [ $? = 0 ] && echo "OK" || echo "FAIL"
+             ;;
+     stop)
+             printf "Stopping fail2ban: "
+             start-stop-daemon -K -q -p /run/fail2ban.pid

Ditto.

package/fail2ban/S60fail2ban line 18

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+FAIL2BAN_VERSION = 0.10.3.1
+FAIL2BAN_SITE = $(call github,fail2ban,fail2ban,$(FAIL2BAN_VERSION))
+FAIL2BAN_LICENSE = GPL-2.0+
+FAIL2BAN_LICENSE_FILES = COPYING
+FAIL2BAN_SETUP_TYPE = setuptools
+FAIL2BAN_INSTALL_TARGET_OPTS = --root=$(TARGET_DIR) --prefix=/usr

So here is the one thing that made me change my mind. I was wondering:
why do we need to pass those options in the fail2ban package? Why aren't they passed by the python-package infrastructure?

Turns out that the Python package infrastructure is doing this:

PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
        --prefix=$(TARGET_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/
PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/

This looks pretty wrong, and it seems like we should be using:

        --prefix=/usr \
        --root=$(TARGET_DIR)

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

Thanks!

Quoted 9 lines

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

--
Profile: http://it.linkedin.com/in/compagnucciangelo
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#7 lore raw

PATCH v2 1/1 package/fail2ban: new package

Dear Yegor,
Il giorno ven 30 nov 2018 alle ore 09:54 Yegor Yefremov <[email protected]> ha scritto:

Quoted 48 lines

Hi Angelo,

Quoted 43 lines · Angelo Compagnucci

Hi Thomas,
Il giorno mar 11 set 2018 alle ore 00:05 Thomas Petazzoni <[email protected]> ha scritto:

Quoted 24 lines

Hello,

+Yegor in Cc. Yegor: read all the way to the end, there is a question about the python-package infrastructure.

Quoted 4 lines · Angelo Compagnucci

Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show malicious behaviours.

I was about to apply this patch (I even made a few minor fixes), but there is one thing that made me change my mind, see below. I will also list the minor issues.

Quoted 5 lines
 package/Config.in              |  1 +
 package/fail2ban/Config.in     | 14 ++++++++++++++
 package/fail2ban/S60fail2ban   | 23 +++++++++++++++++++++++
 package/fail2ban/fail2ban.hash |  3 +++
 package/fail2ban/fail2ban.mk   | 28 ++++++++++++++++++++++++++++

Entry in DEVELOPERS file missing.

Quoted 12 lines

package/fail2ban/Config.in line 3

Quoted 9 lines
package/fail2ban/Config.in new file +3 -0
new file mode 100644
index 0000000..cf82526
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_FAIL2BAN
+     bool "fail2ban"
+     depends on BR2_PACKAGE_PYTHON

Are you sure it doesn't work with Python 3.x ? The fail2ban github page says it does.

Probably it say so, but simply trying to run the software with python3:

Quoted 7 lines
Quoted 4 lines

File "/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/fail2ban-0.10.4/fail2ban/__init__.py",
line 85, in _init
for i in xrange(50):
NameError: name 'xrange' is not defined

This was fixed in [1], but it seems like if you'll have wait till the next release.

Yes I know and meanwhile I submitted a PR to disable installation of tests files hoping that the next release contains both fixes, but as far as I can tell the project has a load of backlog!

Thanks!

Quoted 104 lines

[1] https://github.com/fail2ban/fail2ban/commit/657b147c0d7830f3600f3dc7feaa4815a7e19fde#diff-ac23116c0e156f1acc787e57fe98391c

Yegor

Quoted 99 lines
Quoted 81 lines

package/fail2ban/Config.in line 12

Quoted 10 lines
package/fail2ban/Config.in new file +9 -0
+     help
+       Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs
+       that show the malicious signs -- too many password failures, seeking
+       for exploits, etc. Out of the box Fail2Ban comes with filters for
+       various services (apache, courier, ssh, etc).
+
+       Fail2Ban is able to reduce the rate of incorrect authentications
+       attempts however it cannot eliminate the risk that weak authentication
+       presents.

Aren't some of those lines too long? Could you verify with check-package

package/fail2ban/Config.in line 14

Quoted 2 lines
package/fail2ban/Config.in new file +2 -0
+
+       https://www.fail2ban.org

Please add a Config.in comment about the Python dependency.

package/fail2ban/S60fail2ban line 6

Quoted 12 lines
package/fail2ban/S60fail2ban new file +6 -0
new file mode 100644
index 0000000..92559e9
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+case "$1" in
+     start)
+             printf "Starting fail2ban: "
+             start-stop-daemon -S -q -m -p /run/fail2ban.pid \

Put the PID file in /var/run, to be consistent with most of our other init scripts.

package/fail2ban/S60fail2ban line 12

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+                     -b -x fail2ban-server -- -xf start
+             [ $? = 0 ] && echo "OK" || echo "FAIL"
+             ;;
+     stop)
+             printf "Stopping fail2ban: "
+             start-stop-daemon -K -q -p /run/fail2ban.pid

Ditto.

package/fail2ban/S60fail2ban line 18

Quoted 6 lines
package/fail2ban/S60fail2ban new file +6 -0
+FAIL2BAN_VERSION = 0.10.3.1
+FAIL2BAN_SITE = $(call github,fail2ban,fail2ban,$(FAIL2BAN_VERSION))
+FAIL2BAN_LICENSE = GPL-2.0+
+FAIL2BAN_LICENSE_FILES = COPYING
+FAIL2BAN_SETUP_TYPE = setuptools
+FAIL2BAN_INSTALL_TARGET_OPTS = --root=$(TARGET_DIR) --prefix=/usr

So here is the one thing that made me change my mind. I was wondering:
why do we need to pass those options in the fail2ban package? Why aren't they passed by the python-package infrastructure?

Turns out that the Python package infrastructure is doing this:

PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \
        --prefix=$(TARGET_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/
PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \
        --prefix=$(STAGING_DIR)/usr \
        --executable=/usr/bin/python \
        --single-version-externally-managed \
        --root=/

This looks pretty wrong, and it seems like we should be using:

        --prefix=/usr \
        --root=$(TARGET_DIR)

and ditto for the staging installation, of course. Yegor, do you see any drawback with doing this change in pkg-python.mk ? To me, it seems like the right thing to do, and would avoid the need to have a special case in fail2ban.mk.

Thanks!

Quoted 9 lines

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

--
Profile: http://it.linkedin.com/in/compagnucciangelo
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 1 line
Profile: http://it.linkedin.com/in/compagnucciangelo