From b4eef76783294ed9c0508af942dbbd1303392134 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org>
Date: Tue, 28 Apr 2020 10:47:41 +0200
Subject: [PATCH] ambulance: Use cryptographically secure random generator

FSA-0022

issue #6136
---
 contrib/bin/fusiondirectory-setup | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup
index 23d8a17ea..a511032fd 100644
--- a/contrib/bin/fusiondirectory-setup
+++ b/contrib/bin/fusiondirectory-setup
@@ -44,6 +44,7 @@ use MIME::Base64;
 # used to generate {SSHA} password (for LDAP)
 use Digest::SHA;
 use Crypt::CBC;
+use Bytes::Random::Secure qw(random_string_from);
 
 # used to uncompress tar.gz
 use Archive::Extract;
@@ -229,9 +230,7 @@ sub get_random_string {
   my ($size) = @_;
   $size = 32 if !$size;
   my @chars = ("A".."Z", "a".."z", '.', '/', 0..9);
-  my $string;
-  $string .= $chars[rand @chars] for 1..$size;
-  return $string;
+  return random_string_from(join('', @chars), $size);
 }
 
 sub encrypt_passwords {
-- 
GitLab