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

(-)a/C4/SIP/ILS.pm (-15 / +4 lines)
Lines 6-12 package C4::SIP::ILS; Link Here
6
6
7
use warnings;
7
use warnings;
8
use strict;
8
use strict;
9
use Sys::Syslog qw(syslog);
10
use Data::Dumper;
9
use Data::Dumper;
11
10
12
use C4::SIP::ILS::Item;
11
use C4::SIP::ILS::Item;
Lines 48-54 sub new { Link Here
48
    my $self = {};
47
    my $self = {};
49
	$debug and warn "new ILS: INSTITUTION: " . Dumper($institution);
48
	$debug and warn "new ILS: INSTITUTION: " . Dumper($institution);
50
    C4::SIP::SIPServer::get_logger()->debug("new ILS $institution->{id}");
49
    C4::SIP::SIPServer::get_logger()->debug("new ILS $institution->{id}");
51
    syslog("LOG_DEBUG", "new ILS '%s'", $institution->{id});
52
    $self->{institution} = $institution;
50
    $self->{institution} = $institution;
53
    return bless $self, $type;
51
    return bless $self, $type;
54
}
52
}
Lines 84-90 sub check_inst_id { Link Here
84
    my ($self, $id, $whence) = @_;
82
    my ($self, $id, $whence) = @_;
85
    if ($id ne $self->{institution}->{id}) {
83
    if ($id ne $self->{institution}->{id}) {
86
        C4::SIP::SIPServer::get_logger()->warn("$whence: received institution '$id', expected '$self->{institution}->{id}'");
84
        C4::SIP::SIPServer::get_logger()->warn("$whence: received institution '$id', expected '$self->{institution}->{id}'");
87
        syslog("LOG_WARNING", "%s: received institution '%s', expected '%s'", $whence, $id, $self->{institution}->{id});
88
        # Just an FYI check, we don't expect the user to change location from that in SIPconfig.xml
85
        # Just an FYI check, we don't expect the user to change location from that in SIPconfig.xml
89
    }
86
    }
90
}
87
}
Lines 169-182 sub checkout { Link Here
169
            push( @{ $patron->{items} }, $item_id );
166
            push( @{ $patron->{items} }, $item_id );
170
            $circ->desensitize( !$item->magnetic_media );
167
            $circ->desensitize( !$item->magnetic_media );
171
168
172
            syslog(
169
            C4::SIP::SIPServer::get_logger()->debug("ILS::Checkout: patron '$patron_id' has checked out '".
173
                "LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s",
170
                                                     join( ', ', @{ $patron->{items} } ).
174
                $patron_id, join( ', ', @{ $patron->{items} } )
171
                                                    "' items");
175
            );
176
        }
172
        }
177
        else {
173
        else {
178
            C4::SIP::SIPServer::get_logger()->debug("ILS::Checkout: patron $patron_id has checked out " . join(', ', @{$patron->{items}}) );
174
            C4::SIP::SIPServer::get_logger()->error("ILS::Checkout Issue failed");
179
            syslog( "LOG_ERR", "ILS::Checkout Issue failed" );
180
        }
175
        }
181
    }
176
    }
182
177
Lines 221-232 sub checkin { Link Here
221
    # or it was not checked out but the checked_in_ok flag was set
216
    # or it was not checked out but the checked_in_ok flag was set
222
    $circ->ok( ( $checked_in_ok && $item ) || ( $item && $item->{patron} ) );
217
    $circ->ok( ( $checked_in_ok && $item ) || ( $item && $item->{patron} ) );
223
    C4::SIP::SIPServer::get_logger()->debug("C4::SIP::ILS::checkin - using checked_in_ok") if $checked_in_ok;
218
    C4::SIP::SIPServer::get_logger()->debug("C4::SIP::ILS::checkin - using checked_in_ok") if $checked_in_ok;
224
    syslog("LOG_DEBUG", "C4::SIP::ILS::checkin - using checked_in_ok") if $checked_in_ok;
225
219
226
    if ( !defined( $item->{patron} ) ) {
220
    if ( !defined( $item->{patron} ) ) {
227
        $circ->screen_msg("Item not checked out") unless $checked_in_ok;
221
        $circ->screen_msg("Item not checked out") unless $checked_in_ok;
228
        C4::SIP::SIPServer::get_logger()->debug("C4::SIP::ILS::checkin - item not checked out");
222
        C4::SIP::SIPServer::get_logger()->debug("C4::SIP::ILS::checkin - item not checked out");
229
	syslog("LOG_DEBUG", "C4::SIP::ILS::checkin - item not checked out");
230
    }
223
    }
231
    else {
224
    else {
232
        if ( $circ->ok ) {
225
        if ( $circ->ok ) {
Lines 450-460 sub renew { Link Here
450
		foreach my $i (@{$patron->{items}}) {
443
		foreach my $i (@{$patron->{items}}) {
451
            unless (defined $i->{barcode}) {    # FIXME: using data instead of objects may violate the abstraction layer
444
            unless (defined $i->{barcode}) {    # FIXME: using data instead of objects may violate the abstraction layer
452
                C4::SIP::SIPServer::get_logger()->error("No barcode for item " . $j+1 . " of $count: $item_id");
445
                C4::SIP::SIPServer::get_logger()->error("No barcode for item " . $j+1 . " of $count: $item_id");
453
                syslog("LOG_ERR", "No barcode for item %s of %s: $item_id", $j+1, $count);
454
                next;
446
                next;
455
            }
447
            }
456
            C4::SIP::SIPServer::get_logger()->debug("checking item ". $j + 1 . " of $count: $item_id vs. $i->{barcode} " );
448
            C4::SIP::SIPServer::get_logger()->debug("checking item ". $j + 1 . " of $count: $item_id vs. $i->{barcode} " );
457
            syslog("LOG_DEBUG", "checking item %s of %s: $item_id vs. %s", ++$j, $count, $i->{barcode});
458
            if ($i->{barcode} eq $item_id) {
449
            if ($i->{barcode} eq $item_id) {
459
				# We have it checked out
450
				# We have it checked out
460
				$item = C4::SIP::ILS::Item->new( $item_id );
451
				$item = C4::SIP::ILS::Item->new( $item_id );
Lines 489-498 sub renew_all { Link Here
489
    $trans->patron($patron = C4::SIP::ILS::Patron->new( $patron_id ));
480
    $trans->patron($patron = C4::SIP::ILS::Patron->new( $patron_id ));
490
    if (defined $patron) {
481
    if (defined $patron) {
491
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: patron '$patron->name': renew_ok: $patron->renew_ok");
482
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: patron '$patron->name': renew_ok: $patron->renew_ok");
492
        syslog("LOG_DEBUG", "ILS::renew_all: patron '%s': renew_ok: %s", $patron->name, $patron->renew_ok);
493
    } else {
483
    } else {
494
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: Invalid patron id: '$patron_id'");
484
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: Invalid patron id: '$patron_id'");
495
        syslog("LOG_DEBUG", "ILS::renew_all: Invalid patron id: '%s'", $patron_id);
496
    }
485
    }
497
486
498
    if (!defined($patron)) {
487
    if (!defined($patron)) {
(-)a/C4/SIP/ILS/Item.pm (-4 lines)
Lines 9-15 package C4::SIP::ILS::Item; Link Here
9
use strict;
9
use strict;
10
use warnings;
10
use warnings;
11
11
12
use Sys::Syslog qw(syslog);
13
use Carp;
12
use Carp;
14
use Template;
13
use Template;
15
14
Lines 78-84 sub new { Link Here
78
77
79
    unless ( $item ) {
78
    unless ( $item ) {
80
        C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): not found");
79
        C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): not found");
81
        syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id);
82
        warn "new ILS::Item($item_id) : No item '$item_id'.";
80
        warn "new ILS::Item($item_id) : No item '$item_id'.";
83
        return;
81
        return;
84
    }
82
    }
Lines 108-114 sub new { Link Here
108
	bless $self, $type;
106
	bless $self, $type;
109
107
110
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): found with title '$self->{title}'");
108
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): found with title '$self->{title}'");
111
    syslog("LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'",
112
	   $item_id, $self->{title});
109
	   $item_id, $self->{title});
113
110
114
    return $self;
111
    return $self;
Lines 183-189 sub hold_patron_name { Link Here
183
    my $holder = Koha::Patrons->find( $borrowernumber );
180
    my $holder = Koha::Patrons->find( $borrowernumber );
184
    unless ($holder) {
181
    unless ($holder) {
185
        C4::SIP::SIPServer::get_logger()->debug("While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'");
182
        C4::SIP::SIPServer::get_logger()->debug("While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'");
186
        syslog("LOG_ERR", "While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'");
187
        return;
183
        return;
188
    }
184
    }
189
    my $email = $holder->email || '';
185
    my $email = $holder->email || '';
(-)a/C4/SIP/ILS/Patron.pm (-6 lines)
Lines 12-18 use warnings; Link Here
12
use Exporter;
12
use Exporter;
13
use Carp;
13
use Carp;
14
14
15
use Sys::Syslog qw(syslog);
16
use Data::Dumper;
15
use Data::Dumper;
17
16
18
use C4::Debug;
17
use C4::Debug;
Lines 37-43 sub new { Link Here
37
    $debug and warn "new Patron: " . Dumper($kp->unblessed) if $kp;
36
    $debug and warn "new Patron: " . Dumper($kp->unblessed) if $kp;
38
    unless ($kp) {
37
    unless ($kp) {
39
        C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): no such patron");
38
        C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): no such patron");
40
        syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
41
        return;
39
        return;
42
    }
40
    }
43
    $kp = $kp->unblessed;
41
    $kp = $kp->unblessed;
Lines 125-131 sub new { Link Here
125
    $self = \%ilspatron;
123
    $self = \%ilspatron;
126
    $debug and warn Dumper($self);
124
    $debug and warn Dumper($self);
127
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): found patron '$self->{id}'");
125
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): found patron '$self->{id}'");
128
    syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
129
    bless $self, $type;
126
    bless $self, $type;
130
    return $self;
127
    return $self;
131
}
128
}
Lines 382-390 sub enable { Link Here
382
    }
379
    }
383
    C4::SIP::SIPServer::get_logger()->debug("Patron($self->{id})->enable: charge: $self->{charge_ok}, ".
380
    C4::SIP::SIPServer::get_logger()->debug("Patron($self->{id})->enable: charge: $self->{charge_ok}, ".
384
                                            "renew:$self->{renew_ok}, recall:$self->{recall_ok}, hold:$self->{hold_ok}");
381
                                            "renew:$self->{renew_ok}, recall:$self->{recall_ok}, hold:$self->{hold_ok}");
385
    syslog("LOG_DEBUG", "Patron(%s)->enable: charge: %s, renew:%s, recall:%s, hold:%s",
386
       $self->{id}, $self->{charge_ok}, $self->{renew_ok},
387
       $self->{recall_ok}, $self->{hold_ok});
388
    $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored.";   # TODO: not really affecting patron record
382
    $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored.";   # TODO: not really affecting patron record
389
    return $self;
383
    return $self;
390
}
384
}
(-)a/C4/SIP/ILS/Transaction/Checkout.pm (-3 lines)
Lines 8-14 use warnings; Link Here
8
use strict;
8
use strict;
9
9
10
use POSIX qw(strftime);
10
use POSIX qw(strftime);
11
use Sys::Syslog qw(syslog);
12
use Data::Dumper;
11
use Data::Dumper;
13
use CGI qw ( -utf8 );
12
use CGI qw ( -utf8 );
14
13
Lines 48-54 sub new { Link Here
48
sub do_checkout {
47
sub do_checkout {
49
	my $self = shift;
48
	my $self = shift;
50
	C4::SIP::SIPServer::get_logger()->debug("ILS::Transaction::Checkout performing checkout...");
49
	C4::SIP::SIPServer::get_logger()->debug("ILS::Transaction::Checkout performing checkout...");
51
	syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
52
	my $pending        = $self->{item}->pending_queue;
50
	my $pending        = $self->{item}->pending_queue;
53
	my $shelf          = $self->{item}->hold_shelf;
51
	my $shelf          = $self->{item}->hold_shelf;
54
	my $barcode        = $self->{item}->id;
52
	my $barcode        = $self->{item}->id;
Lines 100-106 sub do_checkout { Link Here
100
                $self->screen_msg($needsconfirmation->{$confirmation});
98
                $self->screen_msg($needsconfirmation->{$confirmation});
101
                $noerror = 0;
99
                $noerror = 0;
102
                C4::SIP::SIPServer::get_logger()->debug("Blocking checkout Reason:$confirmation");
100
                C4::SIP::SIPServer::get_logger()->debug("Blocking checkout Reason:$confirmation");
103
                syslog('LOG_DEBUG', "Blocking checkout Reason:$confirmation");
104
            }
101
            }
105
        }
102
        }
106
    }
103
    }
(-)a/C4/SIP/ILS/Transaction/RenewAll.pm (-8 lines)
Lines 6-13 package C4::SIP::ILS::Transaction::RenewAll; Link Here
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
8
9
use Sys::Syslog qw(syslog);
10
11
use C4::SIP::ILS::Item;
9
use C4::SIP::ILS::Item;
12
10
13
use Koha::Patrons;
11
use Koha::Patrons;
Lines 43-54 sub do_renew_all { Link Here
43
        my $item    = C4::SIP::ILS::Item->new($item_id);
41
        my $item    = C4::SIP::ILS::Item->new($item_id);
44
        if ( !defined($item) ) {
42
        if ( !defined($item) ) {
45
            C4::SIP::SIPServer::get_logger()->debug("renew_all: Invalid item id '$item_id' associated with patron '$patron->id'");
43
            C4::SIP::SIPServer::get_logger()->debug("renew_all: Invalid item id '$item_id' associated with patron '$patron->id'");
46
            syslog(
47
                'LOG_WARNING',
48
                q|renew_all: Invalid item id '%s' associated with patron '%s'|,
49
                $item_id,
50
                $patron->id
51
            );
52
44
53
            # $all_ok = 0; Do net set as still ok
45
            # $all_ok = 0; Do net set as still ok
54
            push @{ $self->unrenewed }, $item_id;
46
            push @{ $self->unrenewed }, $item_id;
(-)a/C4/SIP/README (-3 / +5 lines)
Lines 14-24 perl modules to run: Link Here
14
14
15
LOGGING
15
LOGGING
16
16
17
SIPServer uses syslog() for status and debugging messages.  All
17
By default, SIPServer uses syslog via log4perl for status and debugging messages.
18
syslog messages are logged using the syslog facility 'local6'.
18
All syslog messages are logged using the syslog facility 'local6'.
19
If you need to change this, because something else on your system
19
If you need to change this, because something else on your system
20
is already using that facililty, just change the definition of
20
is already using that facililty, just change the definition of
21
'LOG_SIP' at the top of the file SIPServer.pm
21
'ident' and/or 'facility' in the SIP section of file log4perl.conf.
22
22
23
Make sure to update your syslog configuration to capture facility
23
Make sure to update your syslog configuration to capture facility
24
'local6' and record it.
24
'local6' and record it.
25
26
See the log4perl documenation for logging to a file or other services.
(-)a/C4/SIP/SIPServer.pm (-33 / +1 lines)
Lines 5-11 use strict; Link Here
5
use warnings;
5
use warnings;
6
use FindBin qw($Bin);
6
use FindBin qw($Bin);
7
use lib "$Bin";
7
use lib "$Bin";
8
use Sys::Syslog qw(syslog);
9
use Net::Server::PreFork;
8
use Net::Server::PreFork;
10
use IO::Socket::INET;
9
use IO::Socket::INET;
11
use Socket qw(:DEFAULT :crlf);
10
use Socket qw(:DEFAULT :crlf);
Lines 118-124 sub process_request { Link Here
118
117
119
    if (!defined($self->{service})) {
118
    if (!defined($self->{service})) {
120
                C4::SIP::SIPServer::get_logger()->error("process_request: Unknown recognized server connection: $sockaddr:$port/$proto");
119
                C4::SIP::SIPServer::get_logger()->error("process_request: Unknown recognized server connection: $sockaddr:$port/$proto");
121
		syslog("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto);
122
		die "process_request: Bad server connection";
120
		die "process_request: Bad server connection";
123
    }
121
    }
124
122
Lines 126-132 sub process_request { Link Here
126
124
127
    if (!defined($transport)) {
125
    if (!defined($transport)) {
128
                C4::SIP::SIPServer::get_logger()->warn("Unknown transport '$service->{transport}', dropping");
126
                C4::SIP::SIPServer::get_logger()->warn("Unknown transport '$service->{transport}', dropping");
129
		syslog("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport});
130
		return;
127
		return;
131
    } else {
128
    } else {
132
		&$transport($self);
129
		&$transport($self);
Lines 153-166 sub raw_transport { Link Here
153
    local $SIG{ALRM} = sub { die 'raw transport Timed Out!' };
150
    local $SIG{ALRM} = sub { die 'raw transport Timed Out!' };
154
    my $timeout = $self->get_timeout({ transport => 1 });
151
    my $timeout = $self->get_timeout({ transport => 1 });
155
    C4::SIP::SIPServer::get_logger()->debug("raw_transport: timeout is $service->{timeout}");
152
    C4::SIP::SIPServer::get_logger()->debug("raw_transport: timeout is $service->{timeout}");
156
    syslog('LOG_DEBUG', "raw_transport: timeout is $timeout");
157
    alarm $timeout;
153
    alarm $timeout;
158
    while (!$self->{account}) {
154
    while (!$self->{account}) {
159
        $input = read_request();
155
        $input = read_request();
160
        if (!$input) {
156
        if (!$input) {
161
            # EOF on the socket
157
            # EOF on the socket
162
            C4::SIP::SIPServer::get_logger()->info("raw_transport: shutting down: EOF during login");
158
            C4::SIP::SIPServer::get_logger()->info("raw_transport: shutting down: EOF during login");
163
            syslog("LOG_INFO", "raw_transport: shutting down: EOF during login");
164
            return;
159
            return;
165
        }
160
        }
166
        $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s)
161
        $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s)
Lines 176-193 sub raw_transport { Link Here
176
    Log::Log4perl::MDC->put("peeraddr", $self->{server}->{peeraddr});
171
    Log::Log4perl::MDC->put("peeraddr", $self->{server}->{peeraddr});
177
172
178
    C4::SIP::SIPServer::get_logger()->debug("raw_transport: uname/inst: '$self->{account}->{id}/$self->{account}->{institution}'");
173
    C4::SIP::SIPServer::get_logger()->debug("raw_transport: uname/inst: '$self->{account}->{id}/$self->{account}->{institution}'");
179
    syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'",
180
        $self->{account}->{id},
181
        $self->{account}->{institution});
182
    if (! $self->{account}->{id}) {
174
    if (! $self->{account}->{id}) {
183
        syslog("LOG_ERR","Login failed shutting down");
175
        C4::SIP::SIPServer::get_logger()->error("Login failed shutting down");
184
        return;
176
        return;
185
    }
177
    }
186
178
187
    $self->sip_protocol_loop();
179
    $self->sip_protocol_loop();
188
180
189
    C4::SIP::SIPServer::get_logger()->info("raw_transport: shutting down");
181
    C4::SIP::SIPServer::get_logger()->info("raw_transport: shutting down");
190
    syslog("LOG_INFO", "raw_transport: shutting down");
191
    return;
182
    return;
192
}
183
}
193
184
Lines 195-209 sub get_clean_string { Link Here
195
	my $string = shift;
186
	my $string = shift;
196
	if (defined $string) {
187
	if (defined $string) {
197
                C4::SIP::SIPServer::get_logger()->debug("get_clean_string  pre-clean(length " . length($string) . "): $string");
188
                C4::SIP::SIPServer::get_logger()->debug("get_clean_string  pre-clean(length " . length($string) . "): $string");
198
		syslog("LOG_DEBUG", "get_clean_string  pre-clean(length %s): %s", length($string), $string);
199
		chomp($string);
189
		chomp($string);
200
		$string =~ s/^[^A-z0-9]+//;
190
		$string =~ s/^[^A-z0-9]+//;
201
		$string =~ s/[^A-z0-9]+$//;
191
		$string =~ s/[^A-z0-9]+$//;
202
                C4::SIP::SIPServer::get_logger()->debug("get_clean_string post-clean(length " . length($string) . "): $string)");
192
                C4::SIP::SIPServer::get_logger()->debug("get_clean_string post-clean(length " . length($string) . "): $string)");
203
		syslog("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string);
204
	} else {
193
	} else {
205
                C4::SIP::SIPServer::get_logger()->info("get_clean_string called on undefined");
194
                C4::SIP::SIPServer::get_logger()->info("get_clean_string called on undefined");
206
		syslog("LOG_INFO", "get_clean_string called on undefined");
207
	}
195
	}
208
	return $string;
196
	return $string;
209
}
197
}
Lines 214-220 sub get_clean_input { Link Here
214
	$in = get_clean_string($in);
202
	$in = get_clean_string($in);
215
	while (my $extra = <STDIN>){
203
	while (my $extra = <STDIN>){
216
                C4::SIP::SIPServer::get_logger()->error("get_clean_input got extra lines: $extra");
204
                C4::SIP::SIPServer::get_logger()->error("get_clean_input got extra lines: $extra");
217
		syslog("LOG_ERR", "get_clean_input got extra lines: %s", $extra);
218
	}
205
	}
219
	return $in;
206
	return $in;
220
}
207
}
Lines 228-234 sub telnet_transport { Link Here
228
    my $config  = $self->{config};
215
    my $config  = $self->{config};
229
    my $timeout = $self->get_timeout({ transport => 1 });
216
    my $timeout = $self->get_timeout({ transport => 1 });
230
    C4::SIP::SIPServer::get_logger()->debug("telnet_transport: timeout is $timeout");
217
    C4::SIP::SIPServer::get_logger()->debug("telnet_transport: timeout is $timeout");
231
    syslog("LOG_DEBUG", "telnet_transport: timeout is $timeout");
232
218
233
    eval {
219
    eval {
234
	local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
220
	local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
Lines 248-258 sub telnet_transport { Link Here
248
		alarm 0;
234
		alarm 0;
249
235
250
                C4::SIP::SIPServer::get_logger()->debug("telnet_transport 1: uid length " . length($uid) . ", pwd length " . length($pwd));
236
                C4::SIP::SIPServer::get_logger()->debug("telnet_transport 1: uid length " . length($uid) . ", pwd length " . length($pwd));
251
		syslog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd));
252
		$uid = get_clean_string ($uid);
237
		$uid = get_clean_string ($uid);
253
		$pwd = get_clean_string ($pwd);
238
		$pwd = get_clean_string ($pwd);
254
                C4::SIP::SIPServer::get_logger()->debug("telnet_transport 2: uid length " . length($uid) . ", pwd length " . length($pwd));
239
                C4::SIP::SIPServer::get_logger()->debug("telnet_transport 2: uid length " . length($uid) . ", pwd length " . length($pwd));
255
		syslog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd));
256
240
257
	    if (exists ($config->{accounts}->{$uid})
241
	    if (exists ($config->{accounts}->{$uid})
258
		&& ($pwd eq $config->{accounts}->{$uid}->{password})) {
242
		&& ($pwd eq $config->{accounts}->{$uid}->{password})) {
Lines 262-279 sub telnet_transport { Link Here
262
            }
246
            }
263
	    }
247
	    }
264
		C4::SIP::SIPServer::get_logger()->warn("Invalid login attempt: ' . ($uid||'')  . '");
248
		C4::SIP::SIPServer::get_logger()->warn("Invalid login attempt: ' . ($uid||'')  . '");
265
		syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||''));
266
		print("Invalid login$CRLF");
249
		print("Invalid login$CRLF");
267
	}
250
	}
268
    }; # End of eval
251
    }; # End of eval
269
252
270
    if ($@) {
253
    if ($@) {
271
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login timed out");
254
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login timed out");
272
		syslog("LOG_ERR", "telnet_transport: Login timed out");
273
		die "Telnet Login Timed out";
255
		die "Telnet Login Timed out";
274
    } elsif (!defined($account)) {
256
    } elsif (!defined($account)) {
275
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login Failed");
257
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login Failed");
276
		syslog("LOG_ERR", "telnet_transport: Login Failed");
277
		die "Login Failure";
258
		die "Login Failure";
278
    } else {
259
    } else {
279
		print "Login OK.  Initiating SIP$CRLF";
260
		print "Login OK.  Initiating SIP$CRLF";
Lines 282-291 sub telnet_transport { Link Here
282
    $self->{account} = $account;
263
    $self->{account} = $account;
283
    $self->{logger} = _set_logger( Koha::Logger->get( { interface => 'sip', category => $self->{account}->{id} } ) ); # Add id to namespace
264
    $self->{logger} = _set_logger( Koha::Logger->get( { interface => 'sip', category => $self->{account}->{id} } ) ); # Add id to namespace
284
    C4::SIP::SIPServer::get_logger()->debug("telnet_transport: uname/inst: '$account->{id}/$account->{institution}'");
265
    C4::SIP::SIPServer::get_logger()->debug("telnet_transport: uname/inst: '$account->{id}/$account->{institution}'");
285
    syslog("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", $account->{id}, $account->{institution});
286
    $self->sip_protocol_loop();
266
    $self->sip_protocol_loop();
287
    C4::SIP::SIPServer::get_logger()->info("telnet_transport: shutting down");
267
    C4::SIP::SIPServer::get_logger()->info("telnet_transport: shutting down");
288
    syslog("LOG_INFO", "telnet_transport: shutting down");
289
    return;
268
    return;
290
}
269
}
291
270
Lines 316-322 sub sip_protocol_loop { Link Here
316
    eval {
295
    eval {
317
        local $SIG{ALRM} = sub {
296
        local $SIG{ALRM} = sub {
318
            C4::SIP::SIPServer::get_logger()->debug("Inactive: timed out");
297
            C4::SIP::SIPServer::get_logger()->debug("Inactive: timed out");
319
            syslog( 'LOG_DEBUG', 'Inactive: timed out' );
320
            die "Timed Out!\n";
298
            die "Timed Out!\n";
321
        };
299
        };
322
        my $previous_alarm = alarm($timeout);
300
        my $previous_alarm = alarm($timeout);
Lines 329-335 sub sip_protocol_loop { Link Here
329
307
330
            unless ($inputbuf) {
308
            unless ($inputbuf) {
331
                C4::SIP::SIPServer::get_logger()->error("sip_protocol_loop: empty input skipped");
309
                C4::SIP::SIPServer::get_logger()->error("sip_protocol_loop: empty input skipped");
332
                syslog( "LOG_ERR", "sip_protocol_loop: empty input skipped" );
333
                print("96$CR");
310
                print("96$CR");
334
                next;
311
                next;
335
            }
312
            }
Lines 337-347 sub sip_protocol_loop { Link Here
337
            my $status = C4::SIP::Sip::MsgType::handle( $inputbuf, $self, q{} );
314
            my $status = C4::SIP::Sip::MsgType::handle( $inputbuf, $self, q{} );
338
            if ( !$status ) {
315
            if ( !$status ) {
339
                C4::SIP::SIPServer::get_logger()->error("sip_protocol_loop: failed to handle " . substr( $inputbuf, 0, 2 ) );
316
                C4::SIP::SIPServer::get_logger()->error("sip_protocol_loop: failed to handle " . substr( $inputbuf, 0, 2 ) );
340
                syslog(
341
                    "LOG_ERR",
342
                    "sip_protocol_loop: failed to handle %s",
343
                    substr( $inputbuf, 0, 2 )
344
                );
345
            }
317
            }
346
            next if $status eq REQUEST_ACS_RESEND;
318
            next if $status eq REQUEST_ACS_RESEND;
347
        }
319
        }
Lines 377-394 sub read_request { Link Here
377
      }
349
      }
378
      else {
350
      else {
379
          C4::SIP::SIPServer::get_logger()->debug('EOF returned on read');
351
          C4::SIP::SIPServer::get_logger()->debug('EOF returned on read');
380
          syslog( 'LOG_DEBUG', 'EOF returned on read' );
381
          return;
352
          return;
382
      }
353
      }
383
      my $len = length $buffer;
354
      my $len = length $buffer;
384
      if ( $len != $raw_length ) {
355
      if ( $len != $raw_length ) {
385
          my $trim = $raw_length - $len;
356
          my $trim = $raw_length - $len;
386
          C4::SIP::SIPServer::get_logger()->debug("read_request trimmed $trim character(s) ");
357
          C4::SIP::SIPServer::get_logger()->debug("read_request trimmed $trim character(s) ");
387
          syslog( 'LOG_DEBUG', "read_request trimmed $trim character(s) " );
388
      }
358
      }
389
359
390
      C4::SIP::SIPServer::get_logger()->info("INPUT MSG: '$buffer'");
360
      C4::SIP::SIPServer::get_logger()->info("INPUT MSG: '$buffer'");
391
      syslog( 'LOG_INFO', "INPUT MSG: '$buffer'" );
392
      return $buffer;
361
      return $buffer;
393
}
362
}
394
363
Lines 425-431 sub get_timeout { Link Here
425
        my $rv = sprintf( "%03d", $policy->{timeout} // 0 );
394
        my $rv = sprintf( "%03d", $policy->{timeout} // 0 );
426
        if( length($rv) != 3 ) {
395
        if( length($rv) != 3 ) {
427
            C4::SIP::SIPServer::get_logger()->error("LOG_ERR", "Policy timeout has wrong size: '$rv'");
396
            C4::SIP::SIPServer::get_logger()->error("LOG_ERR", "Policy timeout has wrong size: '$rv'");
428
            syslog( "LOG_ERR", "Policy timeout has wrong size: '%s'", $rv );
429
            return '000';
397
            return '000';
430
        }
398
        }
431
        return $rv;
399
        return $rv;
(-)a/C4/SIP/Sip.pm (-7 lines)
Lines 8-14 use strict; Link Here
8
use warnings;
8
use warnings;
9
use Exporter;
9
use Exporter;
10
use Encode;
10
use Encode;
11
use Sys::Syslog qw(syslog);
12
use POSIX qw(strftime);
11
use POSIX qw(strftime);
13
use Socket qw(:crlf);
12
use Socket qw(:crlf);
14
use IO::Handle;
13
use IO::Handle;
Lines 62-70 sub add_field { Link Here
62
61
63
    if (!defined($value)) {
62
    if (!defined($value)) {
64
        C4::SIP::SIPServer::get_logger()->debug("add_field: Undefined value being added to '$field_id'");
63
        C4::SIP::SIPServer::get_logger()->debug("add_field: Undefined value being added to '$field_id'");
65
	syslog("LOG_DEBUG", "add_field: Undefined value being added to '%s'",
66
	       $field_id);
67
		$value = '';
68
    }
64
    }
69
    $value=~s/\r/ /g; # CR terminates a sip message
65
    $value=~s/\r/ /g; # CR terminates a sip message
70
                      # Protect against them in sip text fields
66
                      # Protect against them in sip text fields
Lines 118-125 sub add_count { Link Here
118
    $count = sprintf("%04d", $count);
114
    $count = sprintf("%04d", $count);
119
    if (length($count) != 4) {
115
    if (length($count) != 4) {
120
		C4::SIP::SIPServer::get_logger()->debug("handle_patron_info: $label wrong size: '$count'");
116
		C4::SIP::SIPServer::get_logger()->debug("handle_patron_info: $label wrong size: '$count'");
121
		syslog("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'",
122
	       $label, $count);
123
		$count = ' ' x 4;
117
		$count = ' ' x 4;
124
    }
118
    }
125
    return $count;
119
    return $count;
Lines 190-196 sub write_msg { Link Here
190
        STDOUT->autoflush(1);
184
        STDOUT->autoflush(1);
191
        print $msg, $terminator;
185
        print $msg, $terminator;
192
        C4::SIP::SIPServer::get_logger()->info("OUTPUT MSG: '$msg'");
186
        C4::SIP::SIPServer::get_logger()->info("OUTPUT MSG: '$msg'");
193
        syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
194
    }
187
    }
195
188
196
    $last_response = $msg;
189
    $last_response = $msg;
(-)a/C4/SIP/Sip/Configuration.pm (-2 lines)
Lines 64-71 sub find_service { Link Here
64
    foreach my $addr ( '', '*:', "$sockaddr:", "[$sockaddr]:" ) {
64
    foreach my $addr ( '', '*:', "$sockaddr:", "[$sockaddr]:" ) {
65
        $portstr = sprintf( "%s%s/%s", $addr, $port, lc $proto );
65
        $portstr = sprintf( "%s%s/%s", $addr, $port, lc $proto );
66
        C4::SIP::SIPServer::get_logger()->debug("Configuration::find_service: Trying $portstr");
66
        C4::SIP::SIPServer::get_logger()->debug("Configuration::find_service: Trying $portstr");
67
        Sys::Syslog::syslog( "LOG_DEBUG",
68
            "Configuration::find_service: Trying $portstr" );
69
        last if ( exists( ( $self->{listeners} )->{$portstr} ) );
67
        last if ( exists( ( $self->{listeners} )->{$portstr} ) );
70
    }
68
    }
71
    return $self->{listeners}->{$portstr};
69
    return $self->{listeners}->{$portstr};
(-)a/C4/SIP/Sip/MsgType.pm (-35 lines)
Lines 9-15 package C4::SIP::Sip::MsgType; Link Here
9
use strict;
9
use strict;
10
use warnings;
10
use warnings;
11
use Exporter;
11
use Exporter;
12
use Sys::Syslog qw(syslog);
13
12
14
use C4::SIP::Sip qw(:all);
13
use C4::SIP::Sip qw(:all);
15
use C4::SIP::Sip::Constants qw(:all);
14
use C4::SIP::Sip::Constants qw(:all);
Lines 267-282 sub new { Link Here
267
    C4::SIP::SIPServer::get_logger()->debug("Sip::MsgType::new('$class', '".
266
    C4::SIP::SIPServer::get_logger()->debug("Sip::MsgType::new('$class', '".
268
                                             substr($msg, 0, 10).
267
                                             substr($msg, 0, 10).
269
                                            "...', '$msgtag'): seq.no '$seqno', protocol $protocol_version");
268
                                            "...', '$msgtag'): seq.no '$seqno', protocol $protocol_version");
270
    syslog( "LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", $class, substr( $msg, 0, 10 ), $msgtag, $seqno, $protocol_version );
271
269
272
    # warn "SIP PROTOCOL: $protocol_version";
270
    # warn "SIP PROTOCOL: $protocol_version";
273
    if ( !exists( $handlers{$msgtag} ) ) {
271
    if ( !exists( $handlers{$msgtag} ) ) {
274
        C4::SIP::SIPServer::get_logger()->warn("new Sip::MsgType: Skipping message of unknown type '$msgtag' in '$msg'");
272
        C4::SIP::SIPServer::get_logger()->warn("new Sip::MsgType: Skipping message of unknown type '$msgtag' in '$msg'");
275
        syslog( "LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", $msgtag, $msg );
276
        return;
273
        return;
277
    } elsif ( !exists( $handlers{$msgtag}->{protocol}->{$protocol_version} ) ) {
274
    } elsif ( !exists( $handlers{$msgtag}->{protocol}->{$protocol_version} ) ) {
278
        C4::SIP::SIPServer::get_logger()->warn("new Sip::MsgType: Skipping message '$msgtag' unsupported by protocol rev. '$protocol_version'");
275
        C4::SIP::SIPServer::get_logger()->warn("new Sip::MsgType: Skipping message '$msgtag' unsupported by protocol rev. '$protocol_version'");
279
        syslog( "LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", $msgtag, $protocol_version );
280
        return;
276
        return;
281
    }
277
    }
282
278
Lines 309-315 sub _initialize { Link Here
309
    }
305
    }
310
306
311
    C4::SIP::SIPServer::get_logger()->debug("Sip::MsgType::_initialize('$self->{name}', '$msg', '$proto->{template}', '$proto->{template_len}', ...)");
307
    C4::SIP::SIPServer::get_logger()->debug("Sip::MsgType::_initialize('$self->{name}', '$msg', '$proto->{template}', '$proto->{template_len}', ...)");
312
    syslog( "LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", $self->{name}, $msg, $proto->{template}, $proto->{template_len} );
313
308
314
    $self->{fixed_fields} = [ unpack( $proto->{template}, $msg ) ];    # see http://perldoc.perl.org/5.8.8/functions/unpack.html
309
    $self->{fixed_fields} = [ unpack( $proto->{template}, $msg ) ];    # see http://perldoc.perl.org/5.8.8/functions/unpack.html
315
310
Lines 320-329 sub _initialize { Link Here
320
315
321
        if ( !exists( $self->{fields}->{$fn} ) ) {
316
        if ( !exists( $self->{fields}->{$fn} ) ) {
322
            C4::SIP::SIPServer::get_logger()->warn("Unsupported field '$fn' in $self->{name}, message '$msg'");
317
            C4::SIP::SIPServer::get_logger()->warn("Unsupported field '$fn' in $self->{name}, message '$msg'");
323
            syslog( "LOG_WARNING", "Unsupported field '%s' in %s message '%s'", $fn, $self->{name}, $msg );
324
        } elsif ( defined( $self->{fields}->{$fn} ) ) {
318
        } elsif ( defined( $self->{fields}->{$fn} ) ) {
325
            C4::SIP::SIPServer::get_logger()->warn("Duplicate field '$fn' (previous value '$self->{fields}->{$fn}') in $self->{name} message '$msg'");
319
            C4::SIP::SIPServer::get_logger()->warn("Duplicate field '$fn' (previous value '$self->{fields}->{$fn}') in $self->{name} message '$msg'");
326
            syslog( "LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", $fn, $self->{fields}->{$fn}, $self->{name}, $msg );
327
        } else {
320
        } else {
328
            $self->{fields}->{$fn} = substr( $field, 2 );
321
            $self->{fields}->{$fn} = substr( $field, 2 );
329
        }
322
        }
Lines 360-366 sub handle { Link Here
360
353
361
        if ( !verify_cksum($msg) ) {
354
        if ( !verify_cksum($msg) ) {
362
            C4::SIP::SIPServer::get_logger()->warn("Checksum failed on message '$msg'");
355
            C4::SIP::SIPServer::get_logger()->warn("Checksum failed on message '$msg'");
363
            syslog( "LOG_WARNING", "Checksum failed on message '%s'", $msg );
364
356
365
            # REQUEST_SC_RESEND with error detection
357
            # REQUEST_SC_RESEND with error detection
366
            $last_response = REQUEST_SC_RESEND_CKSUM;
358
            $last_response = REQUEST_SC_RESEND_CKSUM;
Lines 377-383 sub handle { Link Here
377
        # We received a non-ED message when ED is supposed to be active.
369
        # We received a non-ED message when ED is supposed to be active.
378
        # Warn about this problem, then process the message anyway.
370
        # Warn about this problem, then process the message anyway.
379
        C4::SIP::SIPServer::get_logger()->warn("Received message without error detection: '$msg'");
371
        C4::SIP::SIPServer::get_logger()->warn("Received message without error detection: '$msg'");
380
        syslog( "LOG_WARNING", "Received message without error detection: '%s'", $msg );
381
        $error_detection = 0;
372
        $error_detection = 0;
382
        $self = C4::SIP::Sip::MsgType->new( $msg, 0 );
373
        $self = C4::SIP::Sip::MsgType->new( $msg, 0 );
383
    } else {
374
    } else {
Lines 391-397 sub handle { Link Here
391
    }
382
    }
392
    unless ( $self->{handler} ) {
383
    unless ( $self->{handler} ) {
393
        C4::SIP::SIPServer::get_logger()->warn("No handler defined for '$msg'");
384
        C4::SIP::SIPServer::get_logger()->warn("No handler defined for '$msg'");
394
        syslog( "LOG_WARNING", "No handler defined for '%s'", $msg );
395
        $last_response = REQUEST_SC_RESEND;
385
        $last_response = REQUEST_SC_RESEND;
396
        print("$last_response\r");
386
        print("$last_response\r");
397
        return REQUEST_ACS_RESEND;
387
        return REQUEST_ACS_RESEND;
Lines 515-521 sub handle_checkout { Link Here
515
        # Off-line transactions need to be recorded, but there's
505
        # Off-line transactions need to be recorded, but there's
516
        # not a lot we can do about it
506
        # not a lot we can do about it
517
        C4::SIP::SIPServer::get_logger()->warn("received no-block checkout from terminal '$account->{id}'");
507
        C4::SIP::SIPServer::get_logger()->warn("received no-block checkout from terminal '$account->{id}'");
518
        syslog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} );
519
508
520
        $status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date );
509
        $status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date );
521
    } else {
510
    } else {
Lines 643-649 sub handle_checkin { Link Here
643
632
644
        # Off-line transactions, ick.
633
        # Off-line transactions, ick.
645
        C4::SIP::SIPServer::get_logger()->warn("received no-block checkin from terminal '$account->{id}'");
634
        C4::SIP::SIPServer::get_logger()->warn("received no-block checkin from terminal '$account->{id}'");
646
        syslog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
647
        $status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
635
        $status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
648
    } else {
636
    } else {
649
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok} );
637
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok} );
Lines 758-779 sub handle_sc_status { Link Here
758
        $new_proto = 2;
746
        $new_proto = 2;
759
    } else {
747
    } else {
760
        C4::SIP::SIPServer::get_logger()->warn("Unrecognized protocol revision '$sc_protocol_version', falling back to '1'");
748
        C4::SIP::SIPServer::get_logger()->warn("Unrecognized protocol revision '$sc_protocol_version', falling back to '1'");
761
        syslog( "LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version );
762
        $new_proto = 1;
749
        $new_proto = 1;
763
    }
750
    }
764
751
765
    if ( $new_proto != $protocol_version ) {
752
    if ( $new_proto != $protocol_version ) {
766
        C4::SIP::SIPServer::get_logger()->info("Setting protocol level to $new_proto");
753
        C4::SIP::SIPServer::get_logger()->info("Setting protocol level to $new_proto");
767
        syslog( "LOG_INFO", "Setting protocol level to $new_proto" );
768
        $protocol_version = $new_proto;
754
        $protocol_version = $new_proto;
769
    }
755
    }
770
756
771
    if ( $status == SC_STATUS_PAPER ) {
757
    if ( $status == SC_STATUS_PAPER ) {
772
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' out of paper");
758
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' out of paper");
773
        syslog( "LOG_WARNING", "Self-Check unit '%s@%s' out of paper", $self->{account}->{id}, $self->{account}->{institution} );
774
    } elsif ( $status == SC_STATUS_SHUTDOWN ) {
759
    } elsif ( $status == SC_STATUS_SHUTDOWN ) {
775
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' shutting down");
760
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' shutting down");
776
        syslog( "LOG_WARNING", "Self-Check unit '%s@%s' shutting down", $self->{account}->{id}, $self->{account}->{institution} );
777
    }
761
    }
778
762
779
    $self->{account}->{print_width} = $print_width;
763
    $self->{account}->{print_width} = $print_width;
Lines 814-824 sub login_core { Link Here
814
    my $status = 1;                 # Assume it all works
798
    my $status = 1;                 # Assume it all works
815
    if ( !exists( $server->{config}->{accounts}->{$uid} ) ) {
799
    if ( !exists( $server->{config}->{accounts}->{$uid} ) ) {
816
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Unknown login '$uid'");
800
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Unknown login '$uid'");
817
        syslog( "LOG_WARNING", "MsgType::login_core: Unknown login '$uid'" );
818
        $status = 0;
801
        $status = 0;
819
    } elsif ( $server->{config}->{accounts}->{$uid}->{password} ne $pwd ) {
802
    } elsif ( $server->{config}->{accounts}->{$uid}->{password} ne $pwd ) {
820
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Invalid password for login '$uid'");
803
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Invalid password for login '$uid'");
821
        syslog( "LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'" );
822
        $status = 0;
804
        $status = 0;
823
    } else {
805
    } else {
824
806
Lines 833-850 sub login_core { Link Here
833
        my $auth_status = api_auth( $uid, $pwd, $inst );
815
        my $auth_status = api_auth( $uid, $pwd, $inst );
834
        if ( !$auth_status or $auth_status !~ /^ok$/i ) {
816
        if ( !$auth_status or $auth_status !~ /^ok$/i ) {
835
            C4::SIP::SIPServer::get_logger()->warn("api_auth failed for SIP terminal '$uid' of '$inst': " . ($auth_status||'unknown') );
817
            C4::SIP::SIPServer::get_logger()->warn("api_auth failed for SIP terminal '$uid' of '$inst': " . ($auth_status||'unknown') );
836
            syslog( "LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", $uid, $inst, ( $auth_status || 'unknown' ) );
837
            $status = 0;
818
            $status = 0;
838
        } else {
819
        } else {
839
            C4::SIP::SIPServer::get_logger()->info("Successful login/auth for '$server->{account}->{id}' of '$inst'");
820
            C4::SIP::SIPServer::get_logger()->info("Successful login/auth for '$server->{account}->{id}' of '$inst'");
840
            syslog( "LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst );
841
821
842
            #
822
            #
843
            # initialize connection to ILS
823
            # initialize connection to ILS
844
            #
824
            #
845
            my $module = $server->{config}->{institutions}->{$inst}->{implementation};
825
            my $module = $server->{config}->{institutions}->{$inst}->{implementation};
846
            C4::SIP::SIPServer::get_logger()->debug("login_core: " . Dumper($module) );
826
            C4::SIP::SIPServer::get_logger()->debug("login_core: " . Dumper($module) );
847
            syslog( "LOG_DEBUG", 'login_core: ' . Dumper($module) );
848
827
849
            # Suspect this is always ILS but so we don't break any eccentic install (for now)
828
            # Suspect this is always ILS but so we don't break any eccentic install (for now)
850
            if ( $module eq 'ILS' ) {
829
            if ( $module eq 'ILS' ) {
Lines 853-859 sub login_core { Link Here
853
            $module->use;
832
            $module->use;
854
            if ($@) {
833
            if ($@) {
855
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: Loading ILS implementation '$module' for institution '$inst' failed");
834
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: Loading ILS implementation '$module' for institution '$inst' failed");
856
                syslog( "LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", $server->{service}, $module, $inst );
857
                die("Failed to load ILS implementation '$module' for $inst");
835
                die("Failed to load ILS implementation '$module' for $inst");
858
            }
836
            }
859
837
Lines 861-867 sub login_core { Link Here
861
            $server->{ils} = $module->new( $server->{institution}, $server->{account} );
839
            $server->{ils} = $module->new( $server->{institution}, $server->{account} );
862
            if ( !$server->{ils} ) {
840
            if ( !$server->{ils} ) {
863
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: ILS connection to '$inst' failed");
841
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: ILS connection to '$inst' failed");
864
                syslog( "LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst );
865
                die("Unable to connect to ILS '$inst'");
842
                die("Unable to connect to ILS '$inst'");
866
            }
843
            }
867
        }
844
        }
Lines 885-891 sub handle_login { Link Here
885
862
886
    if ( $uid_algorithm || $pwd_algorithm ) {
863
    if ( $uid_algorithm || $pwd_algorithm ) {
887
        C4::SIP::SIPServer::get_logger()->error("LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm");
864
        C4::SIP::SIPServer::get_logger()->error("LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm");
888
        syslog( "LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm" );
889
        $status = 0;
865
        $status = 0;
890
    } else {
866
    } else {
891
        $status = login_core( $server, $uid, $pwd );
867
        $status = login_core( $server, $uid, $pwd );
Lines 925-938 sub summary_info { Link Here
925
    }
901
    }
926
902
927
    C4::SIP::SIPServer::get_logger()->debug("Summary_info: index == '$summary_type', field '$summary_map[$summary_type]->{fid}'");
903
    C4::SIP::SIPServer::get_logger()->debug("Summary_info: index == '$summary_type', field '$summary_map[$summary_type]->{fid}'");
928
    syslog( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} );
929
904
930
    my $func     = $summary_map[$summary_type]->{func};
905
    my $func     = $summary_map[$summary_type]->{func};
931
    my $fid      = $summary_map[$summary_type]->{fid};
906
    my $fid      = $summary_map[$summary_type]->{fid};
932
    my $itemlist = &$func( $patron, $start, $end, $server );
907
    my $itemlist = &$func( $patron, $start, $end, $server );
933
908
934
    C4::SIP::SIPServer::get_logger()->debug("summary_info: list = (" . join(", ", @{$itemlist}) . ")");
909
    C4::SIP::SIPServer::get_logger()->debug("summary_info: list = (" . join(", ", @{$itemlist}) . ")");
935
    syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", @{$itemlist} ) );
936
    foreach my $i ( @{$itemlist} ) {
910
    foreach my $i ( @{$itemlist} ) {
937
        $resp .= add_field( $fid, $i->{barcode} );
911
        $resp .= add_field( $fid, $i->{barcode} );
938
    }
912
    }
Lines 1205-1211 sub handle_item_status_update { Link Here
1205
1179
1206
    if ( !defined($item_id) ) {
1180
    if ( !defined($item_id) ) {
1207
        C4::SIP::SIPServer::get_logger()->warn("handle_item_status: received message without Item ID field");
1181
        C4::SIP::SIPServer::get_logger()->warn("handle_item_status: received message without Item ID field");
1208
        syslog( "LOG_WARNING", "handle_item_status: received message without Item ID field" );
1209
    } else {
1182
    } else {
1210
        $item = $ils->find_item($item_id);
1183
        $item = $ils->find_item($item_id);
1211
    }
1184
    }
Lines 1251-1257 sub handle_patron_enable { Link Here
1251
    $patron_pwd = $fields->{ (FID_PATRON_PWD) };
1224
    $patron_pwd = $fields->{ (FID_PATRON_PWD) };
1252
1225
1253
    C4::SIP::SIPServer::get_logger()->debug("handle_patron_enable: patron_id: '$patron_id', patron_pwd: '$patron_pwd'");
1226
    C4::SIP::SIPServer::get_logger()->debug("handle_patron_enable: patron_id: '$patron_id', patron_pwd: '$patron_pwd'");
1254
    syslog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd );
1255
1227
1256
    $patron = $ils->find_patron($patron_id);
1228
    $patron = $ils->find_patron($patron_id);
1257
1229
Lines 1322-1328 sub handle_hold { Link Here
1322
        $status = $ils->alter_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack );
1294
        $status = $ils->alter_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack );
1323
    } else {
1295
    } else {
1324
        C4::SIP::SIPServer::get_logger()->warn("handle_hold: Unrecognized hold mode '$hold_mode' from terminal '$server->{account}->{id}'");
1296
        C4::SIP::SIPServer::get_logger()->warn("handle_hold: Unrecognized hold mode '$hold_mode' from terminal '$server->{account}->{id}'");
1325
        syslog( "LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", $hold_mode, $server->{account}->{id} );
1326
        $status = $ils->Transaction::Hold;    # new?
1297
        $status = $ils->Transaction::Hold;    # new?
1327
        $status->screen_msg("System error. Please contact library staff.");
1298
        $status->screen_msg("System error. Please contact library staff.");
1328
    }
1299
    }
Lines 1371-1377 sub handle_renew { Link Here
1371
1342
1372
    if ( $no_block eq 'Y' ) {
1343
    if ( $no_block eq 'Y' ) {
1373
        C4::SIP::SIPServer::get_logger()->warn("handle_renew: received 'no block' renewal from terminal '$server->{account}->{id}'");
1344
        C4::SIP::SIPServer::get_logger()->warn("handle_renew: received 'no block' renewal from terminal '$server->{account}->{id}'");
1374
        syslog( "LOG_WARNING", "handle_renew: received 'no block' renewal from terminal '%s'", $server->{account}->{id} );
1375
    }
1345
    }
1376
1346
1377
    $patron_id  = $fields->{ (FID_PATRON_ID) };
1347
    $patron_id  = $fields->{ (FID_PATRON_ID) };
Lines 1539-1545 sub send_acs_status { Link Here
1539
1509
1540
    if ( length($retries) != 3 ) {
1510
    if ( length($retries) != 3 ) {
1541
        C4::SIP::SIPServer::get_logger()->error("handle_acs_status: timeout field wrong size: '$timeout'");
1511
        C4::SIP::SIPServer::get_logger()->error("handle_acs_status: timeout field wrong size: '$timeout'");
1542
        syslog( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries );
1543
        $retries = '000';
1512
        $retries = '000';
1544
    }
1513
    }
1545
1514
Lines 1553-1559 sub send_acs_status { Link Here
1553
        $msg .= '2.00';
1522
        $msg .= '2.00';
1554
    } else {
1523
    } else {
1555
        C4::SIP::SIPServer::get_logger()->error("Bad setting for \$protocol_version, '$protocol_version' in send_acs_status");
1524
        C4::SIP::SIPServer::get_logger()->error("Bad setting for \$protocol_version, '$protocol_version' in send_acs_status");
1556
        syslog( "LOG_ERR", 'Bad setting for $protocol_version, "%s" in send_acs_status', $protocol_version );
1557
        $msg .= '1.00';
1525
        $msg .= '1.00';
1558
    }
1526
    }
1559
1527
Lines 1574-1580 sub send_acs_status { Link Here
1574
        }
1542
        }
1575
        if ( length($supported_msgs) < 16 ) {
1543
        if ( length($supported_msgs) < 16 ) {
1576
            C4::SIP::SIPServer::get_logger()->error("send_acs_status: supported messages '$supported_msgs' too short");
1544
            C4::SIP::SIPServer::get_logger()->error("send_acs_status: supported messages '$supported_msgs' too short");
1577
            syslog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs );
1578
        }
1545
        }
1579
        $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs );
1546
        $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs );
1580
    }
1547
    }
Lines 1585-1591 sub send_acs_status { Link Here
1585
        && defined($print_line)
1552
        && defined($print_line)
1586
        && $account->{print_width} < length($print_line) ) {
1553
        && $account->{print_width} < length($print_line) ) {
1587
        C4::SIP::SIPServer::get_logger()->warn("send_acs_status: print line '$print_line' too long.  Truncating");
1554
        C4::SIP::SIPServer::get_logger()->warn("send_acs_status: print line '$print_line' too long.  Truncating");
1588
        syslog( "LOG_WARNING", "send_acs_status: print line '%s' too long.  Truncating", $print_line );
1589
        $print_line = substr( $print_line, 0, $account->{print_width} );
1555
        $print_line = substr( $print_line, 0, $account->{print_width} );
1590
    }
1556
    }
1591
1557
Lines 1606-1612 sub patron_status_string { Link Here
1606
    my $patron_status;
1572
    my $patron_status;
1607
1573
1608
    C4::SIP::SIPServer::get_logger()->debug("patron_status_string: $patron->id charge_ok: $patron->charge_ok");
1574
    C4::SIP::SIPServer::get_logger()->debug("patron_status_string: $patron->id charge_ok: $patron->charge_ok");
1609
    syslog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
1610
    $patron_status = sprintf(
1575
    $patron_status = sprintf(
1611
        '%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
1576
        '%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
1612
        denied( $patron->charge_ok ),
1577
        denied( $patron->charge_ok ),
(-)a/etc/SIPconfig.xml (-4 lines)
Lines 10-18 Link Here
10
  <server-params
10
  <server-params
11
    min_servers='1'
11
    min_servers='1'
12
    min_spare_servers='0'
12
    min_spare_servers='0'
13
    log_file='Sys::Syslog'
14
    syslog_ident='koha_sip'
15
    syslog_facility='local6'
16
  />
13
  />
17
14
18
  <listeners>
15
  <listeners>
19
- 

Return to bug 15253