git: 12c198cffd7a - 2025Q1 - security/crowdsec: Update 1.6.4 => 1.6.5

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Tue, 11 Feb 2025 14:05:02 UTC
The branch 2025Q1 has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=12c198cffd7adea0e442676f75ac5321be52f1f8

commit 12c198cffd7adea0e442676f75ac5321be52f1f8
Author:     Marco <marco@crowdsec.net>
AuthorDate: 2025-02-11 13:56:16 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-02-11 14:04:30 +0000

    security/crowdsec: Update 1.6.4 => 1.6.5
    
    Changelog:
    https://github.com/crowdsecurity/crowdsec/releases/tag/v1.6.5
    
    PR:     284730
    MFH:    2025Q1
    (cherry picked from commit 2c8fd6f3ca6182a08050a942d8d9b39695848770)
---
 security/crowdsec/Makefile                           |  7 +++----
 security/crowdsec/distinfo                           | 10 +++++-----
 security/crowdsec/files/crowdsec.in                  | 18 ++++++++++++++----
 security/crowdsec/files/patch-pkg_cwhub_hub.go       | 13 +++++++++++++
 security/crowdsec/files/patch-pkg_hubops_download.go | 13 +++++++++++++
 5 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/security/crowdsec/Makefile b/security/crowdsec/Makefile
index ebeec03d74c1..44d1e0f8290e 100644
--- a/security/crowdsec/Makefile
+++ b/security/crowdsec/Makefile
@@ -1,7 +1,6 @@
 PORTNAME=	crowdsec
 DISTVERSIONPREFIX=	v
-DISTVERSION=	1.6.4
-PORTREVISION=	1
+DISTVERSION=	1.6.5
 CATEGORIES=	security
 
 MAINTAINER=	marco@crowdsec.net
@@ -15,7 +14,7 @@ LIB_DEPENDS=	libabsl_base.so:devel/abseil \
 		libre2.so:devel/re2
 
 USES=		go:1.23,modules pkgconfig
-_COMMIT=	523164f6
+_COMMIT=	d8dcdc91
 _BUILD_DATE=	$$(date -u "+%F_%T")
 USE_RC_SUBR=	crowdsec
 
@@ -30,7 +29,7 @@ GO_TARGET=	./cmd/crowdsec \
 
 GO_BUILDFLAGS=	-v -trimpath -tags netgo,osusergo,sqlite_omit_load_extension,re2_cgo \
 		-ldflags="\
-		-a -s -w \
+		-a -s \
 		-X github.com/crowdsecurity/go-cs-lib/version.Version=${DISTVERSIONPREFIX}${PKGVERSION} \
 		-X github.com/crowdsecurity/go-cs-lib/version.BuildDate=${_BUILD_DATE} \
 		-X github.com/crowdsecurity/go-cs-lib/version.Tag=${_COMMIT} \
diff --git a/security/crowdsec/distinfo b/security/crowdsec/distinfo
index a38e4ac30d29..d060c226d846 100644
--- a/security/crowdsec/distinfo
+++ b/security/crowdsec/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1732708457
-SHA256 (go/security_crowdsec/crowdsec-v1.6.4/v1.6.4.mod) = 8494881f2c033d1becdbdc2be4230740874f0dca703f26a60f1e2108ca7419a1
-SIZE (go/security_crowdsec/crowdsec-v1.6.4/v1.6.4.mod) = 10240
-SHA256 (go/security_crowdsec/crowdsec-v1.6.4/v1.6.4.zip) = 075555e9ebb93d45dcfd144069fcbdfb791935965be265034880f4d335292755
-SIZE (go/security_crowdsec/crowdsec-v1.6.4/v1.6.4.zip) = 1570635
+TIMESTAMP = 1738941832
+SHA256 (go/security_crowdsec/crowdsec-v1.6.5/v1.6.5.mod) = f288295700dd0a49cd69d520167cd00826d974877450cc627f8f839850c0d617
+SIZE (go/security_crowdsec/crowdsec-v1.6.5/v1.6.5.mod) = 10932
+SHA256 (go/security_crowdsec/crowdsec-v1.6.5/v1.6.5.zip) = 1d9642ab9b6cdbc9dd8f1a1331d9d72da06f0b876b2970499e3f27443889cad5
+SIZE (go/security_crowdsec/crowdsec-v1.6.5/v1.6.5.zip) = 1669439
diff --git a/security/crowdsec/files/crowdsec.in b/security/crowdsec/files/crowdsec.in
index 9952ad5c4974..ac50c9d09da5 100644
--- a/security/crowdsec/files/crowdsec.in
+++ b/security/crowdsec/files/crowdsec.in
@@ -59,14 +59,24 @@ crowdsec_stop_precmd() {
 }
 
 crowdsec_stop_postcmd() {
-    # don't trust sbin/daemon to send the signal
-    kill -TERM "$_CROWDSECPID" 2>/dev/null
-    # wait for process to exit before restarting, or it will find the http port in use
     if [ -n "$_CROWDSECPID" ]; then
-        wait_for_pids "$_CROWDSECPID"
+        # don't trust sbin/daemon to send the signal
+        kill -TERM "$_CROWDSECPID" 2>/dev/null
     fi
     if [ -n "$_CROWDSEC_CHILDREN" ]; then
         kill -TERM $_CROWDSEC_CHILDREN 2>/dev/null
+    fi
+
+    sleep 5
+
+    if [ -n "$_CROWDSECPID" ]; then
+        # in case a datasource didn't respond
+        kill -KILL "$_CROWDSECPID" 2>/dev/null
+        # ensure the process is not running before restart, or it will find the http port in use
+        wait_for_pids "$_CROWDSECPID"
+    fi
+    if [ -n "$_CROWDSEC_CHILDREN" ]; then
+        kill -KILL $_CROWDSEC_CHILDREN 2>/dev/null
         wait_for_pids $_CROWDSEC_CHILDREN
     fi
 }
diff --git a/security/crowdsec/files/patch-pkg_cwhub_hub.go b/security/crowdsec/files/patch-pkg_cwhub_hub.go
new file mode 100644
index 000000000000..b87e90c287c8
--- /dev/null
+++ b/security/crowdsec/files/patch-pkg_cwhub_hub.go
@@ -0,0 +1,13 @@
+--- pkg/cwhub/hub.go.orig	2025-02-10 13:37:25 UTC
++++ pkg/cwhub/hub.go
+@@ -165,7 +165,9 @@ func (h *Hub) Update(ctx context.Context, indexProvide
+ 	}
+ 
+ 	if !downloaded {
+-		fmt.Println("Nothing to do, the hub index is up to date.")
++		// use logger and the message will be silenced in the cron job
++		// (no mail if nothing happened)
++		h.logger.Info("Nothing to do, the hub index is up to date.")
+ 	}
+ 
+ 	return nil
diff --git a/security/crowdsec/files/patch-pkg_hubops_download.go b/security/crowdsec/files/patch-pkg_hubops_download.go
new file mode 100644
index 000000000000..25fc210f1959
--- /dev/null
+++ b/security/crowdsec/files/patch-pkg_hubops_download.go
@@ -0,0 +1,13 @@
+--- pkg/hubops/download.go.orig	2025-02-10 13:37:39 UTC
++++ pkg/hubops/download.go
+@@ -114,6 +114,10 @@ func downloadDataSet(ctx context.Context, dataFolder s
+ 		}
+ 
+ 		for _, dataS := range data.Data {
++			if dataS.SourceURL == "" {
++				continue
++			}
++
+ 			// XXX: check context cancellation
+ 			destPath, err := cwhub.SafePath(dataFolder, dataS.DestPath)
+ 			if err != nil {