git: db438743e3d8 - main - multimedia/zoneminder: Replace usage of Data::Entropy (security/p5-Data-Entropy) for undeprecate

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Sun, 15 Jun 2025 13:49:53 UTC
The branch main has been updated by vvd:

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

commit db438743e3d8013cb2b3f735d476ccccaf75502c
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2025-06-15 13:32:19 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-06-15 13:47:24 +0000

    multimedia/zoneminder: Replace usage of Data::Entropy (security/p5-Data-Entropy) for undeprecate
    
    Aadd adopted upstream patch "Use Bytes::Random::Secure instead of
    deprecated Data-Entropy.  Fall back to Data-Entropy. Fixes #4333":
    https://github.com/ZoneMinder/zoneminder/issues/4333
    https://github.com/ZoneMinder/zoneminder/commit/38c0f743c1c4c97a8ac35f829bf236ddd8006ce8
    
    PR:             287222
    Approved by:    Ivan <bsd@abinet.ru>
---
 multimedia/zoneminder/Makefile                     |  6 ++--
 .../zoneminder/files/patch-scripts_zmupdate.pl.in  | 39 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/multimedia/zoneminder/Makefile b/multimedia/zoneminder/Makefile
index 5059d270d9b5..47ba2e280d88 100644
--- a/multimedia/zoneminder/Makefile
+++ b/multimedia/zoneminder/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	zoneminder
 DISTVERSION=	1.36.35
+PORTREVISION=	1
 CATEGORIES=	multimedia
 PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}
 
@@ -12,9 +13,6 @@ WWW=		https://www.zoneminder.com/
 
 LICENSE=	GPLv2
 
-DEPRECATED=	Depends on expired security/p5-Data-Entropy
-EXPIRATION_DATE=2025-09-01
-
 ZM_DEPENDS=	p5-DBI>=0:databases/p5-DBI \
 		${DBD_MYSQL} \
 		p5-Date-Manip>=0:devel/p5-Date-Manip \
@@ -38,7 +36,7 @@ RUN_DEPENDS=	${ZM_DEPENDS} \
 		sudo:security/sudo \
 		p5-Device-SerialPort>=0:comms/p5-Device-SerialPort \
 		p5-Crypt-Eksblowfish>=0:security/p5-Crypt-Eksblowfish \
-		p5-Data-Entropy>=0:security/p5-Data-Entropy \
+		p5-Bytes-Random-Secure>=0:security/p5-Bytes-Random-Secure \
 		p5-XML-LibXML>=0:textproc/p5-XML-LibXML \
 		zip:archivers/zip
 
diff --git a/multimedia/zoneminder/files/patch-scripts_zmupdate.pl.in b/multimedia/zoneminder/files/patch-scripts_zmupdate.pl.in
new file mode 100644
index 000000000000..8bd3db5ac6ec
--- /dev/null
+++ b/multimedia/zoneminder/files/patch-scripts_zmupdate.pl.in
@@ -0,0 +1,39 @@
+--- scripts/zmupdate.pl.in.orig	2025-06-13 23:01:03 UTC
++++ scripts/zmupdate.pl.in
+@@ -52,8 +52,6 @@ use version;
+ use strict;
+ use bytes;
+ use version;
+-use Crypt::Eksblowfish::Bcrypt;
+-use Data::Entropy::Algorithms qw(rand_bits);
+ 
+ # ==========================================================================
+ #
+@@ -1035,6 +1033,18 @@ sub migratePasswords {
+ } # end sub patchDB
+ 
+ sub migratePasswords {
++  use Crypt::Eksblowfish::Bcrypt;
++  my $random;
++  eval {
++    require Bytes::Random::Secure;
++    $random = Bytes::Random::Secure->new( Bits        => 16*8);
++  };
++  if ($@ or !$random) {
++    eval {
++      require Data::Entropy::Algorithms;
++      $random = Data::Entropy::Algorithms::rand_bits(16*8);
++    };
++  }
+   print ("Migratings passwords, if any...\n");
+   my $sql = 'SELECT * FROM `Users`';
+   my $sth = $dbh->prepare_cached($sql) or die( "Can't prepare '$sql': ".$dbh->errstr() );
+@@ -1043,7 +1053,7 @@ sub migratePasswords {
+     my $scheme = substr($user->{Password}, 0, 1);
+     if ($scheme eq '*') {
+       print ('-->'.$user->{Username}." password will be migrated\n");
+-      my $salt = Crypt::Eksblowfish::Bcrypt::en_base64(rand_bits(16*8));
++      my $salt = Crypt::Eksblowfish::Bcrypt::en_base64($random);
+       my $settings = '$2a$10$'.$salt;
+       my $pass_hash = Crypt::Eksblowfish::Bcrypt::bcrypt($user->{Password},$settings);
+       my $new_pass_hash = '-ZM-'.$pass_hash;