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
38c0f743c1

PR:		287222
Approved by:	Ivan <bsd@abinet.ru>
This commit is contained in:
Vladimir Druzenko 2025-06-15 16:32:19 +03:00
parent 78632a4040
commit db438743e3
2 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -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;