From d1bd2e9c036db439d969aa470410abaf8e727f08 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 27 Feb 2024 11:08:59 +0000 Subject: [PATCH] Bug 35724: (QA follow-up) Also account for port in FTP We were only passing port into SFTP connections.. now that we allow defining it, we should also pass it to FTP connections just in case someone is still using those. This patch adds such functionality and defaults to port 21 in this case when the port isn't defined. Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- Koha/Edifact/Transport.pm | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm index 80f6cc9ecf..ebc5d801c8 100644 --- a/Koha/Edifact/Transport.pm +++ b/Koha/Edifact/Transport.pm @@ -219,13 +219,17 @@ sub ftp_download { my $msg_hash = $self->message_hash(); my @downloaded_files; - my $ftp = Net::FTP->new( + my $port = $self->{account}->download_port ? $self->{account}->download_port : '21'; + my $ftp = Net::FTP->new( $self->{account}->host, + Port => $port, Timeout => 10, Passive => 1 - ) - or return $self->_abort_download( undef, - "Cannot connect to $self->{account}->host: $EVAL_ERROR" ); + ) + or return $self->_abort_download( + undef, + "Cannot connect to $self->{account}->host: $EVAL_ERROR" + ); $ftp->login( $self->{account}->username, Koha::Encryption->new->decrypt_hex($self->{account}->password) ) or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); $ftp->cwd( $self->{account}->download_directory ) @@ -260,13 +264,17 @@ sub ftp_download { sub ftp_upload { my ( $self, @messages ) = @_; - my $ftp = Net::FTP->new( + my $port = $self->{account}->upload_port ? $self->{account}->upload_port : '21'; + my $ftp = Net::FTP->new( $self->{account}->host, + Port => $port, Timeout => 10, Passive => 1 - ) - or return $self->_abort_download( undef, - "Cannot connect to $self->{account}->host: $EVAL_ERROR" ); + ) + or return $self->_abort_download( + undef, + "Cannot connect to $self->{account}->host: $EVAL_ERROR" + ); $ftp->login( $self->{account}->username, Koha::Encryption->new->decrypt_hex($self->{account}->password) ) or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); $ftp->cwd( $self->{account}->upload_directory ) -- 2.39.5