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 (-2 / +11 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 36-46 our ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
36
    }
39
    }
37
);
40
);
38
41
42
my $crypt = Koha::Encryption->new;
43
39
my $op = $input->param('op');
44
my $op = $input->param('op');
40
$op ||= 'display';
45
$op ||= 'display';
41
46
42
if ( $op eq 'acct_form' ) {
47
if ( $op eq 'acct_form' ) {
43
    show_account();
48
    show_account($crypt);
44
    $template->param( acct_form => 1 );
49
    $template->param( acct_form => 1 );
45
    my @vendors = $schema->resultset('Aqbookseller')->search(
50
    my @vendors = $schema->resultset('Aqbookseller')->search(
46
        undef,
51
        undef,
Lines 67-77 else { Link Here
67
72
68
        # validate & display
73
        # validate & display
69
        my $id     = $input->param('id');
74
        my $id     = $input->param('id');
75
        my $password = scalar $input->param('password');
76
        $password = $crypt->encrypt_hex($password);
70
        my $fields = {
77
        my $fields = {
71
            description        => scalar $input->param('description'),
78
            description        => scalar $input->param('description'),
72
            host               => scalar $input->param('host'),
79
            host               => scalar $input->param('host'),
73
            username           => scalar $input->param('username'),
80
            username           => scalar $input->param('username'),
74
            password           => scalar $input->param('password'),
81
            password           => $password,
75
            vendor_id          => scalar $input->param('vendor_id'),
82
            vendor_id          => scalar $input->param('vendor_id'),
76
            upload_directory   => scalar $input->param('upload_directory'),
83
            upload_directory   => scalar $input->param('upload_directory'),
77
            download_directory => scalar $input->param('download_directory'),
84
            download_directory => scalar $input->param('download_directory'),
Lines 153-161 sub get_account { Link Here
153
}
160
}
154
161
155
sub show_account {
162
sub show_account {
163
    my $crypt = shift;
156
    my $acct_id = $input->param('id');
164
    my $acct_id = $input->param('id');
157
    if ($acct_id) {
165
    if ($acct_id) {
158
        my $acct = $schema->resultset('VendorEdiAccount')->find($acct_id);
166
        my $acct = $schema->resultset('VendorEdiAccount')->find($acct_id);
167
        $acct->password( $crypt->decrypt_hex($acct->password) );
159
        if ($acct) {
168
        if ($acct) {
160
            $template->param( account => $acct );
169
            $template->param( account => $acct );
161
        }
170
        }
(-)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 5850-5856 CREATE TABLE `vendor_edi_accounts` ( Link Here
5850
  `description` mediumtext NOT NULL,
5850
  `description` mediumtext NOT NULL,
5851
  `host` varchar(40) DEFAULT NULL,
5851
  `host` varchar(40) DEFAULT NULL,
5852
  `username` varchar(40) DEFAULT NULL,
5852
  `username` varchar(40) DEFAULT NULL,
5853
  `password` varchar(40) DEFAULT NULL,
5853
  `password` varchar(256) DEFAULT NULL,
5854
  `last_activity` date DEFAULT NULL,
5854
  `last_activity` date DEFAULT NULL,
5855
  `vendor_id` int(11) DEFAULT NULL,
5855
  `vendor_id` int(11) DEFAULT NULL,
5856
  `download_directory` mediumtext DEFAULT NULL,
5856
  `download_directory` mediumtext DEFAULT NULL,
5857
- 

Return to bug 30649