View | Details | Raw Unified | Return to bug 30649
Collapse All | Expand All

(-)a/Koha/Edifact/Transport.pm (-10 / +13 lines)
Lines 17-35 package Koha::Edifact::Transport; Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
21
22
use utf8;
22
use utf8;
23
use DateTime;
23
24
use Carp qw( carp );
24
use Carp qw( carp );
25
use DateTime;
26
use Encode qw( from_to );
25
use English qw{ -no_match_vars };
27
use English qw{ -no_match_vars };
28
use File::Copy qw( copy move );
29
use File::Slurp qw( read_file );
26
use Net::FTP;
30
use Net::FTP;
27
use Net::SFTP::Foreign;
31
use Net::SFTP::Foreign;
28
use File::Slurp qw( read_file );
32
29
use File::Copy qw( copy move );
30
use Koha::Database;
33
use Koha::Database;
31
use Koha::DateUtils qw( dt_from_string );
34
use Koha::DateUtils qw( dt_from_string );
32
use Encode qw( from_to );
35
use Koha::Encryption;
33
36
34
sub new {
37
sub new {
35
    my ( $class, $account_id ) = @_;
38
    my ( $class, $account_id ) = @_;
Lines 136-142 sub sftp_download { Link Here
136
    my $sftp = Net::SFTP::Foreign->new(
139
    my $sftp = Net::SFTP::Foreign->new(
137
        host     => $self->{account}->host,
140
        host     => $self->{account}->host,
138
        user     => $self->{account}->username,
141
        user     => $self->{account}->username,
139
        password => $self->{account}->password,
142
        password => Koha::Encryption->new->decrypt_hex($self->{account}->password),
140
        timeout  => 10,
143
        timeout  => 10,
141
    );
144
    );
142
    if ( $sftp->error ) {
145
    if ( $sftp->error ) {
Lines 221-227 sub ftp_download { Link Here
221
      )
224
      )
222
      or return $self->_abort_download( undef,
225
      or return $self->_abort_download( undef,
223
        "Cannot connect to $self->{account}->host: $EVAL_ERROR" );
226
        "Cannot connect to $self->{account}->host: $EVAL_ERROR" );
224
    $ftp->login( $self->{account}->username, $self->{account}->password )
227
    $ftp->login( $self->{account}->username, Koha::Encryption->new->decrypt_hex($self->{account}->password) )
225
      or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" );
228
      or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" );
226
    $ftp->cwd( $self->{account}->download_directory )
229
    $ftp->cwd( $self->{account}->download_directory )
227
      or return $self->_abort_download( $ftp,
230
      or return $self->_abort_download( $ftp,
Lines 262-268 sub ftp_upload { Link Here
262
      )
265
      )
263
      or return $self->_abort_download( undef,
266
      or return $self->_abort_download( undef,
264
        "Cannot connect to $self->{account}->host: $EVAL_ERROR" );
267
        "Cannot connect to $self->{account}->host: $EVAL_ERROR" );
265
    $ftp->login( $self->{account}->username, $self->{account}->password )
268
    $ftp->login( $self->{account}->username, Koha::Encryption->new->decrypt_hex($self->{account}->password) )
266
      or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" );
269
      or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" );
267
    $ftp->cwd( $self->{account}->upload_directory )
270
    $ftp->cwd( $self->{account}->upload_directory )
268
      or return $self->_abort_download( $ftp,
271
      or return $self->_abort_download( $ftp,
Lines 293-299 sub sftp_upload { Link Here
293
    my $sftp = Net::SFTP::Foreign->new(
296
    my $sftp = Net::SFTP::Foreign->new(
294
        host     => $self->{account}->host,
297
        host     => $self->{account}->host,
295
        user     => $self->{account}->username,
298
        user     => $self->{account}->username,
296
        password => $self->{account}->password,
299
        password => Koha::Encryption->new->decrypt_hex($self->{account}->password),
297
        timeout  => 10,
300
        timeout  => 10,
298
    );
301
    );
299
    $sftp->die_on_error("Cannot ssh to $self->{account}->host");
302
    $sftp->die_on_error("Cannot ssh to $self->{account}->host");
(-)a/admin/edi_accounts.pl (-1 / +8 lines)
Lines 18-27 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
use CGI;
22
use CGI;
23
22
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
23
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
24
use Koha::Database;
26
use Koha::Database;
27
use Koha::Encryption;
25
use Koha::Plugins;
28
use Koha::Plugins;
26
29
27
our $input = CGI->new();
30
our $input = CGI->new();
Lines 67-77 else { Link Here
67
70
68
        # validate & display
71
        # validate & display
69
        my $id     = $input->param('id');
72
        my $id     = $input->param('id');
73
        my $password = scalar $input->param('password');
74
        $password = Koha::Encryption->new->encrypt_hex($password);
70
        my $fields = {
75
        my $fields = {
71
            description        => scalar $input->param('description'),
76
            description        => scalar $input->param('description'),
72
            host               => scalar $input->param('host'),
77
            host               => scalar $input->param('host'),
73
            username           => scalar $input->param('username'),
78
            username           => scalar $input->param('username'),
74
            password           => scalar $input->param('password'),
79
            password           => $password,
75
            vendor_id          => scalar $input->param('vendor_id'),
80
            vendor_id          => scalar $input->param('vendor_id'),
76
            upload_directory   => scalar $input->param('upload_directory'),
81
            upload_directory   => scalar $input->param('upload_directory'),
77
            download_directory => scalar $input->param('download_directory'),
82
            download_directory => scalar $input->param('download_directory'),
Lines 95-100 else { Link Here
95
            )->update_all($fields);
100
            )->update_all($fields);
96
        }
101
        }
97
        else {    # new record
102
        else {    # new record
103
            $fields->{password} = Koha::Encryption->new->encrypt_hex($fields->{password});
98
            $schema->resultset('VendorEdiAccount')->create($fields);
104
            $schema->resultset('VendorEdiAccount')->create($fields);
99
        }
105
        }
100
    }
106
    }
Lines 156-161 sub show_account { Link Here
156
    my $acct_id = $input->param('id');
162
    my $acct_id = $input->param('id');
157
    if ($acct_id) {
163
    if ($acct_id) {
158
        my $acct = $schema->resultset('VendorEdiAccount')->find($acct_id);
164
        my $acct = $schema->resultset('VendorEdiAccount')->find($acct_id);
165
        $acct->password( Koha::Encryption->new->decrypt_hex($acct->password) );
159
        if ($acct) {
166
        if ($acct) {
160
            $template->param( account => $acct );
167
            $template->param( account => $acct );
161
        }
168
        }
(-)a/installer/data/mysql/atomicupdate/bug_30649.pl (+25 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "30649",
5
    description => "Increase the vendor EDI account password field to 256 characters",
6
    up => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        $dbh->do(q{
10
            ALTER TABLE vendor_edi_accounts CHANGE COLUMN `password` `password` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL
11
        });
12
13
        require Koha::Encryption;
14
        my $e = Koha::Encryption->new;
15
16
        my $schema = Koha::Database->new()->schema();
17
        my $rs     = $schema->resultset('VendorEdiAccount')->search();
18
        while ( my $a = $rs->next() ) {
19
            my $password = $a->password;
20
            $password = $e->encrypt_hex($password);
21
            $a->password($password);
22
            $a->update();
23
        }
24
    },
25
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +1 lines)
Lines 5459-5465 CREATE TABLE `vendor_edi_accounts` ( Link Here
5459
  `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5459
  `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5460
  `host` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5460
  `host` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5461
  `username` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5461
  `username` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5462
  `password` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5462
  `password` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5463
  `last_activity` date DEFAULT NULL,
5463
  `last_activity` date DEFAULT NULL,
5464
  `vendor_id` int(11) DEFAULT NULL,
5464
  `vendor_id` int(11) DEFAULT NULL,
5465
  `download_directory` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5465
  `download_directory` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5466
- 

Return to bug 30649