From 114d3421a0e931061e36c6c05174fa926e2afd69 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Tue, 7 Nov 2017 16:26:07 +0100
Subject: [PATCH] use local filehandle

---
 lib/IdPAccountManager/WebRequest.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index 8b64b1d..697131d 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -365,11 +365,11 @@ sub req_generate_token {
     my $sender    = $self->{configuration}->{notice_from};
     my $recipient = $self->{in}->{email_address};
 
-    unless (open(SENDMAIL, "|/usr/sbin/sendmail -f $sender $recipient")) {
+    open(my $handle, '|-', "/usr/sbin/sendmail -f $sender $recipient") or do {
         push @{ $self->{out}->{errors} }, "mail_notification_error";
-        $self->{logger}->errorf("Mail notification error: %s", $ERRNO);
+        $self->{logger}->errorf("Unable to run sendmail executable: %s", $ERRNO);
         return undef;
-    }
+    };
 
     my $tt2 = Template->new({
         INCLUDE_PATH => $self->{configuration}->{templates_dir}
@@ -391,13 +391,13 @@ sub req_generate_token {
         authentication_token => $token->token(),
     };
 
-    unless ($tt2->process($template, $data, \*SENDMAIL)) {
+    unless ($tt2->process($template, $data, $handle)) {
         push @{ $self->{out}->{errors} }, "mail_notification_error";
         $self->{logger}->errorf("Mail notification error: %s", $EVAL_ERROR);
         return undef;
     }
 
-    close SENDMAIL;
+    close $handle;
 
     $self->{logger}->infof(
         "Token send to %s for sp_entityid=%s;token=%s",
-- 
GitLab