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

(-)a/C4/SIP/ILS/Transaction/Checkout.pm (-1 / +1 lines)
Lines 47-53 sub new { Link Here
47
47
48
sub do_checkout {
48
sub do_checkout {
49
	my $self = shift;
49
	my $self = shift;
50
	siplog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
50
    siplog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
51
	my $shelf          = $self->{item}->hold_shelf;
51
	my $shelf          = $self->{item}->hold_shelf;
52
	my $barcode        = $self->{item}->id;
52
	my $barcode        = $self->{item}->id;
53
	my $patron_barcode = $self->{patron}->id;
53
	my $patron_barcode = $self->{patron}->id;
(-)a/C4/SIP/Logger.pm (+10 lines)
Lines 6-11 use Modern::Perl; Link Here
6
our $activeSIPServer;
6
our $activeSIPServer;
7
our $activeLogger;
7
our $activeLogger;
8
8
9
=head1 NAME
10
11
C4::SIP::Logger - Module for handling SIP server logging
12
9
=head2 get_SIPServer
13
=head2 get_SIPServer
10
14
11
    my $sipServer = C4::SIP::SIPServer::get_SIPServer()
15
    my $sipServer = C4::SIP::SIPServer::get_SIPServer()
Lines 36-41 sub get_logger { Link Here
36
    return $activeLogger;
40
    return $activeLogger;
37
}
41
}
38
42
43
=head2 set_logger
44
45
    my $logger = C4::SIP::SIPServer::set_logger($logger)
46
47
=cut
48
39
sub set_logger {
49
sub set_logger {
40
    my ($logger) = @_;
50
    my ($logger) = @_;
41
    $activeLogger = $logger;
51
    $activeLogger = $logger;
(-)a/C4/SIP/SIPServer.pm (-56 / +56 lines)
Lines 30-36 use base qw(Net::Server::PreFork); Link Here
30
use constant LOG_SIP => "local6"; # Local alias for the logging facility
30
use constant LOG_SIP => "local6"; # Local alias for the logging facility
31
31
32
#
32
#
33
# Main	# not really, since package SIPServer
33
# Main   # not really, since package SIPServer
34
#
34
#
35
# FIXME: Is this a module or a script?  
35
# FIXME: Is this a module or a script?  
36
# A script with no MAIN namespace?
36
# A script with no MAIN namespace?
Lines 75-81 foreach my $svc (keys %{$config->{listeners}}) { Link Here
75
#
75
#
76
if (defined($config->{'server-params'})) {
76
if (defined($config->{'server-params'})) {
77
    while (my ($key, $val) = each %{$config->{'server-params'}}) {
77
    while (my ($key, $val) = each %{$config->{'server-params'}}) {
78
		push @parms, $key . '=' . $val;
78
      push @parms, $key . '=' . $val;
79
    }
79
    }
80
}
80
}
81
81
Lines 125-141 sub process_request { Link Here
125
    $self->{service} = $config->find_service($sockaddr, $port, $proto);
125
    $self->{service} = $config->find_service($sockaddr, $port, $proto);
126
126
127
    if (!defined($self->{service})) {
127
    if (!defined($self->{service})) {
128
		siplog("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto);
128
      siplog("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto);
129
		die "process_request: Bad server connection";
129
      die "process_request: Bad server connection";
130
    }
130
    }
131
131
132
    $transport = $transports{$self->{service}->{transport}};
132
    $transport = $transports{$self->{service}->{transport}};
133
133
134
    if (!defined($transport)) {
134
    if (!defined($transport)) {
135
		siplog("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport});
135
      siplog("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport});
136
		return;
136
      return;
137
    } else {
137
    } else {
138
		&$transport($self);
138
      &$transport($self);
139
    }
139
    }
140
    return;
140
    return;
141
}
141
}
Lines 201-227 sub raw_transport { Link Here
201
}
201
}
202
202
203
sub get_clean_string {
203
sub get_clean_string {
204
	my $string = shift;
204
   my $string = shift;
205
	if (defined $string) {
205
   if (defined $string) {
206
		siplog("LOG_DEBUG", "get_clean_string  pre-clean(length %s): %s", length($string), $string);
206
      siplog("LOG_DEBUG", "get_clean_string  pre-clean(length %s): %s", length($string), $string);
207
		chomp($string);
207
      chomp($string);
208
		$string =~ s/^[^A-z0-9]+//;
208
      $string =~ s/^[^A-z0-9]+//;
209
		$string =~ s/[^A-z0-9]+$//;
209
      $string =~ s/[^A-z0-9]+$//;
210
		siplog("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string);
210
      siplog("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string);
211
	} else {
211
   } else {
212
		siplog("LOG_INFO", "get_clean_string called on undefined");
212
      siplog("LOG_INFO", "get_clean_string called on undefined");
213
	}
213
   }
214
	return $string;
214
   return $string;
215
}
215
}
216
216
217
sub get_clean_input {
217
sub get_clean_input {
218
	local $/ = "\012";
218
   local $/ = "\012";
219
	my $in = <STDIN>;
219
   my $in = <STDIN>;
220
	$in = get_clean_string($in);
220
   $in = get_clean_string($in);
221
	while (my $extra = <STDIN>){
221
   while (my $extra = <STDIN>){
222
		siplog("LOG_ERR", "get_clean_input got extra lines: %s", $extra);
222
      siplog("LOG_ERR", "get_clean_input got extra lines: %s", $extra);
223
	}
223
   }
224
	return $in;
224
   return $in;
225
}
225
}
226
226
227
sub telnet_transport {
227
sub telnet_transport {
Lines 235-281 sub telnet_transport { Link Here
235
    siplog("LOG_DEBUG", "telnet_transport: timeout is $timeout");
235
    siplog("LOG_DEBUG", "telnet_transport: timeout is $timeout");
236
236
237
    eval {
237
    eval {
238
	local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
238
   local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
239
	local $| = 1;			# Unbuffered output
239
   local $| = 1;         # Unbuffered output
240
	$/ = "\015";		# Internet Record Separator (lax version)
240
   $/ = "\015";      # Internet Record Separator (lax version)
241
    # Until the terminal has logged in, we don't trust it
241
    # Until the terminal has logged in, we don't trust it
242
    # so use a timeout to protect ourselves from hanging.
242
    # so use a timeout to protect ourselves from hanging.
243
243
244
	while ($strikes--) {
244
   while ($strikes--) {
245
	    print "login: ";
245
       print "login: ";
246
		alarm $timeout;
246
      alarm $timeout;
247
		# $uid = &get_clean_input;
247
      # $uid = &get_clean_input;
248
		$uid = <STDIN>;
248
      $uid = <STDIN>;
249
	    print "password: ";
249
       print "password: ";
250
	    # $pwd = &get_clean_input || '';
250
       # $pwd = &get_clean_input || '';
251
		$pwd = <STDIN>;
251
      $pwd = <STDIN>;
252
		alarm 0;
252
      alarm 0;
253
253
254
		siplog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd));
254
      siplog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd));
255
		$uid = get_clean_string ($uid);
255
      $uid = get_clean_string ($uid);
256
		$pwd = get_clean_string ($pwd);
256
      $pwd = get_clean_string ($pwd);
257
		siplog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd));
257
      siplog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd));
258
258
259
	    if (exists ($config->{accounts}->{$uid})
259
       if (exists ($config->{accounts}->{$uid})
260
		&& ($pwd eq $config->{accounts}->{$uid}->{password})) {
260
      && ($pwd eq $config->{accounts}->{$uid}->{password})) {
261
			$account = $config->{accounts}->{$uid};
261
         $account = $config->{accounts}->{$uid};
262
			if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) {
262
         if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) {
263
                last;
263
                last;
264
            }
264
            }
265
	    }
265
       }
266
		siplog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||''));
266
      siplog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||''));
267
		print("Invalid login$CRLF");
267
      print("Invalid login$CRLF");
268
	}
268
   }
269
    }; # End of eval
269
    }; # End of eval
270
270
271
    if ($@) {
271
    if ($@) {
272
		siplog("LOG_ERR", "telnet_transport: Login timed out");
272
      siplog("LOG_ERR", "telnet_transport: Login timed out");
273
		die "Telnet Login Timed out";
273
      die "Telnet Login Timed out";
274
    } elsif (!defined($account)) {
274
    } elsif (!defined($account)) {
275
		siplog("LOG_ERR", "telnet_transport: Login Failed");
275
      siplog("LOG_ERR", "telnet_transport: Login Failed");
276
		die "Login Failure";
276
      die "Login Failure";
277
    } else {
277
    } else {
278
		print "Login OK.  Initiating SIP$CRLF";
278
      print "Login OK.  Initiating SIP$CRLF";
279
    }
279
    }
280
280
281
    $self->{account} = $account;
281
    $self->{account} = $account;
(-)a/C4/SIP/Sip.pm (-2 / +2 lines)
Lines 68-74 sub add_field { Link Here
68
    my ($i, $ent);
68
    my ($i, $ent);
69
69
70
    if (!defined($value)) {
70
    if (!defined($value)) {
71
	siplog("LOG_DEBUG", "add_field: Undefined value being added to '%s'",
71
        siplog("LOG_DEBUG", "add_field: Undefined value being added to '%s'",
72
	       $field_id);
72
	       $field_id);
73
		$value = '';
73
		$value = '';
74
    }
74
    }
Lines 127-133 sub add_count { Link Here
127
127
128
    $count = sprintf("%04d", $count);
128
    $count = sprintf("%04d", $count);
129
    if (length($count) != 4) {
129
    if (length($count) != 4) {
130
		siplog("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'",
130
        siplog("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'",
131
	       $label, $count);
131
	       $label, $count);
132
		$count = ' ' x 4;
132
		$count = ' ' x 4;
133
    }
133
    }
(-)a/C4/SIP/Trapper.pm (-1 / +6 lines)
Lines 4-9 use Modern::Perl; Link Here
4
4
5
use Koha::Logger;
5
use Koha::Logger;
6
6
7
=head1 NAME
8
9
C4::SIP::Trapper - Trapper module to capture warnings to send to Koha::Logger
10
11
=cut
12
7
sub TIEHANDLE {
13
sub TIEHANDLE {
8
    my $class = shift;
14
    my $class = shift;
9
    bless [], $class;
15
    bless [], $class;
10
- 

Return to bug 15253