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 453-463 sub renew { Link Here
453
		foreach my $i (@{$patron->{items}}) {
446
		foreach my $i (@{$patron->{items}}) {
454
            unless (defined $i->{barcode}) {    # FIXME: using data instead of objects may violate the abstraction layer
447
            unless (defined $i->{barcode}) {    # FIXME: using data instead of objects may violate the abstraction layer
455
                C4::SIP::SIPServer::get_logger()->error("No barcode for item " . $j+1 . " of $count: $item_id");
448
                C4::SIP::SIPServer::get_logger()->error("No barcode for item " . $j+1 . " of $count: $item_id");
456
                syslog("LOG_ERR", "No barcode for item %s of %s: $item_id", $j+1, $count);
457
                next;
449
                next;
458
            }
450
            }
459
            C4::SIP::SIPServer::get_logger()->debug("checking item ". $j + 1 . " of $count: $item_id vs. $i->{barcode} " );
451
            C4::SIP::SIPServer::get_logger()->debug("checking item ". $j + 1 . " of $count: $item_id vs. $i->{barcode} " );
460
            syslog("LOG_DEBUG", "checking item %s of %s: $item_id vs. %s", ++$j, $count, $i->{barcode});
461
            if ($i->{barcode} eq $item_id) {
452
            if ($i->{barcode} eq $item_id) {
462
				# We have it checked out
453
				# We have it checked out
463
				$item = C4::SIP::ILS::Item->new( $item_id );
454
				$item = C4::SIP::ILS::Item->new( $item_id );
Lines 492-501 sub renew_all { Link Here
492
    $trans->patron($patron = C4::SIP::ILS::Patron->new( $patron_id ));
483
    $trans->patron($patron = C4::SIP::ILS::Patron->new( $patron_id ));
493
    if (defined $patron) {
484
    if (defined $patron) {
494
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: patron '$patron->name': renew_ok: $patron->renew_ok");
485
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: patron '$patron->name': renew_ok: $patron->renew_ok");
495
        syslog("LOG_DEBUG", "ILS::renew_all: patron '%s': renew_ok: %s", $patron->name, $patron->renew_ok);
496
    } else {
486
    } else {
497
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: Invalid patron id: '$patron_id'");
487
        C4::SIP::SIPServer::get_logger()->debug("ILS::renew_all: Invalid patron id: '$patron_id'");
498
        syslog("LOG_DEBUG", "ILS::renew_all: Invalid patron id: '%s'", $patron_id);
499
    }
488
    }
500
489
501
    if (!defined($patron)) {
490
    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
13
15
use C4::SIP::SIPServer;
14
use C4::SIP::SIPServer;
Lines 80-86 sub new { Link Here
80
	my $item = GetBiblioFromItemNumber($itemnumber);    # actually biblio.*, biblioitems.* AND items.*  (overkill)
79
	my $item = GetBiblioFromItemNumber($itemnumber);    # actually biblio.*, biblioitems.* AND items.*  (overkill)
81
	if (! $item) {
80
	if (! $item) {
82
                C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): not found");
81
                C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): not found");
83
		syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id);
84
		warn "new ILS::Item($item_id) : No item '$item_id'.";
82
		warn "new ILS::Item($item_id) : No item '$item_id'.";
85
        return;
83
        return;
86
	}
84
	}
Lines 109-115 sub new { Link Here
109
	bless $self, $type;
107
	bless $self, $type;
110
108
111
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): found with title '$self->{title}'");
109
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Item('$item_id'): found with title '$self->{title}'");
112
    syslog("LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'",
113
	   $item_id, $self->{title});
110
	   $item_id, $self->{title});
114
111
115
    return $self;
112
    return $self;
Lines 173-179 sub hold_patron_name { Link Here
173
    my $holder = GetMember(borrowernumber=>$borrowernumber);
170
    my $holder = GetMember(borrowernumber=>$borrowernumber);
174
    unless ($holder) {
171
    unless ($holder) {
175
        C4::SIP::SIPServer::get_logger()->debug("While checking hold, GetMember failed for borrowernumber '$borrowernumber'");
172
        C4::SIP::SIPServer::get_logger()->debug("While checking hold, GetMember failed for borrowernumber '$borrowernumber'");
176
        syslog("LOG_ERR", "While checking hold, GetMember failed for borrowernumber '$borrowernumber'");
177
        return;
173
        return;
178
    }
174
    }
179
    my $email = $holder->{email} || '';
175
    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 35-41 sub new { Link Here
35
    $debug and warn "new Patron (GetMember): " . Dumper($kp);
34
    $debug and warn "new Patron (GetMember): " . Dumper($kp);
36
    unless (defined $kp) {
35
    unless (defined $kp) {
37
        C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): no such patron");
36
        C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): no such patron");
38
        syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
39
        return;
37
        return;
40
    }
38
    }
41
    $kp = GetMemberDetails($kp->{borrowernumber});
39
    $kp = GetMemberDetails($kp->{borrowernumber});
Lines 124-130 sub new { Link Here
124
    $self = \%ilspatron;
122
    $self = \%ilspatron;
125
    $debug and warn Dumper($self);
123
    $debug and warn Dumper($self);
126
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): found patron '$self->{id}'");
124
    C4::SIP::SIPServer::get_logger()->debug("new ILS::Patron($patron_id): found patron '$self->{id}'");
127
    syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
128
    bless $self, $type;
125
    bless $self, $type;
129
    return $self;
126
    return $self;
130
}
127
}
Lines 361-369 sub enable { Link Here
361
    }
358
    }
362
    C4::SIP::SIPServer::get_logger()->debug("Patron($self->{id})->enable: charge: $self->{charge_ok}, ".
359
    C4::SIP::SIPServer::get_logger()->debug("Patron($self->{id})->enable: charge: $self->{charge_ok}, ".
363
                                            "renew:$self->{renew_ok}, recall:$self->{recall_ok}, hold:$self->{hold_ok}");
360
                                            "renew:$self->{renew_ok}, recall:$self->{recall_ok}, hold:$self->{hold_ok}");
364
    syslog("LOG_DEBUG", "Patron(%s)->enable: charge: %s, renew:%s, recall:%s, hold:%s",
365
       $self->{id}, $self->{charge_ok}, $self->{renew_ok},
366
       $self->{recall_ok}, $self->{hold_ok});
367
    $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored.";   # TODO: not really affecting patron record
361
    $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored.";   # TODO: not really affecting patron record
368
    return $self;
362
    return $self;
369
}
363
}
(-)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 C4::Members qw( GetMember );
11
use C4::Members qw( GetMember );
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 (-4 / +6 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 (-31 / +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},
174
        $self->{account}->{id},
181
        $self->{account}->{institution});
175
        $self->{account}->{institution});
182
    if (! $self->{account}->{id}) {
176
    if (! $self->{account}->{id}) {
183
        syslog("LOG_ERR","Login failed shutting down");
177
        C4::SIP::SIPServer::get_logger()->error("Login failed shutting down");
184
        return;
178
        return;
185
    }
179
    }
186
180
187
    $self->sip_protocol_loop();
181
    $self->sip_protocol_loop();
188
182
189
    C4::SIP::SIPServer::get_logger()->info("raw_transport: shutting down");
183
    C4::SIP::SIPServer::get_logger()->info("raw_transport: shutting down");
190
    syslog("LOG_INFO", "raw_transport: shutting down");
191
    return;
184
    return;
192
}
185
}
193
186
Lines 195-209 sub get_clean_string { Link Here
195
	my $string = shift;
188
	my $string = shift;
196
	if (defined $string) {
189
	if (defined $string) {
197
                C4::SIP::SIPServer::get_logger()->debug("get_clean_string  pre-clean(length " . length($string) . "): $string");
190
                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);
191
		chomp($string);
200
		$string =~ s/^[^A-z0-9]+//;
192
		$string =~ s/^[^A-z0-9]+//;
201
		$string =~ s/[^A-z0-9]+$//;
193
		$string =~ s/[^A-z0-9]+$//;
202
                C4::SIP::SIPServer::get_logger()->debug("get_clean_string post-clean(length " . length($string) . "): $string)");
194
                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 {
195
	} else {
205
                C4::SIP::SIPServer::get_logger()->info("get_clean_string called on undefined");
196
                C4::SIP::SIPServer::get_logger()->info("get_clean_string called on undefined");
206
		syslog("LOG_INFO", "get_clean_string called on undefined");
207
	}
197
	}
208
	return $string;
198
	return $string;
209
}
199
}
Lines 214-220 sub get_clean_input { Link Here
214
	$in = get_clean_string($in);
204
	$in = get_clean_string($in);
215
	while (my $extra = <STDIN>){
205
	while (my $extra = <STDIN>){
216
                C4::SIP::SIPServer::get_logger()->error("get_clean_input got extra lines: $extra");
206
                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
	}
207
	}
219
	return $in;
208
	return $in;
220
}
209
}
Lines 228-234 sub telnet_transport { Link Here
228
    my $config  = $self->{config};
217
    my $config  = $self->{config};
229
    my $timeout = $self->get_timeout({ transport => 1 });
218
    my $timeout = $self->get_timeout({ transport => 1 });
230
    C4::SIP::SIPServer::get_logger()->debug("telnet_transport: timeout is $timeout");
219
    C4::SIP::SIPServer::get_logger()->debug("telnet_transport: timeout is $timeout");
231
    syslog("LOG_DEBUG", "telnet_transport: timeout is $timeout");
232
220
233
    eval {
221
    eval {
234
	local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
222
	local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
Lines 248-258 sub telnet_transport { Link Here
248
		alarm 0;
236
		alarm 0;
249
237
250
                C4::SIP::SIPServer::get_logger()->debug("telnet_transport 1: uid length " . length($uid) . ", pwd length " . length($pwd));
238
                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);
239
		$uid = get_clean_string ($uid);
253
		$pwd = get_clean_string ($pwd);
240
		$pwd = get_clean_string ($pwd);
254
                C4::SIP::SIPServer::get_logger()->debug("telnet_transport 2: uid length " . length($uid) . ", pwd length " . length($pwd));
241
                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
242
257
	    if (exists ($config->{accounts}->{$uid})
243
	    if (exists ($config->{accounts}->{$uid})
258
		&& ($pwd eq $config->{accounts}->{$uid}->{password})) {
244
		&& ($pwd eq $config->{accounts}->{$uid}->{password})) {
Lines 262-279 sub telnet_transport { Link Here
262
            }
248
            }
263
	    }
249
	    }
264
		C4::SIP::SIPServer::get_logger()->warn("Invalid login attempt: ' . ($uid||'')  . '");
250
		C4::SIP::SIPServer::get_logger()->warn("Invalid login attempt: ' . ($uid||'')  . '");
265
		syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||''));
266
		print("Invalid login$CRLF");
251
		print("Invalid login$CRLF");
267
	}
252
	}
268
    }; # End of eval
253
    }; # End of eval
269
254
270
    if ($@) {
255
    if ($@) {
271
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login timed out");
256
		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";
257
		die "Telnet Login Timed out";
274
    } elsif (!defined($account)) {
258
    } elsif (!defined($account)) {
275
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login Failed");
259
		C4::SIP::SIPServer::get_logger()->error("telnet_transport: Login Failed");
276
		syslog("LOG_ERR", "telnet_transport: Login Failed");
277
		die "Login Failure";
260
		die "Login Failure";
278
    } else {
261
    } else {
279
		print "Login OK.  Initiating SIP$CRLF";
262
		print "Login OK.  Initiating SIP$CRLF";
Lines 282-291 sub telnet_transport { Link Here
282
    $self->{account} = $account;
265
    $self->{account} = $account;
283
    $self->{logger} = _set_logger( Koha::Logger->get( { interface => 'sip', category => $self->{account}->{id} } ) ); # Add id to namespace
266
    $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}'");
267
    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();
268
    $self->sip_protocol_loop();
287
    C4::SIP::SIPServer::get_logger()->info("telnet_transport: shutting down");
269
    C4::SIP::SIPServer::get_logger()->info("telnet_transport: shutting down");
288
    syslog("LOG_INFO", "telnet_transport: shutting down");
289
    return;
270
    return;
290
}
271
}
291
272
Lines 316-322 sub sip_protocol_loop { Link Here
316
    eval {
297
    eval {
317
        local $SIG{ALRM} = sub {
298
        local $SIG{ALRM} = sub {
318
            C4::SIP::SIPServer::get_logger()->debug("Inactive: timed out");
299
            C4::SIP::SIPServer::get_logger()->debug("Inactive: timed out");
319
            syslog( 'LOG_DEBUG', 'Inactive: timed out' );
320
            die "Timed Out!\n";
300
            die "Timed Out!\n";
321
        };
301
        };
322
        my $previous_alarm = alarm($timeout);
302
        my $previous_alarm = alarm($timeout);
Lines 329-335 sub sip_protocol_loop { Link Here
329
309
330
            unless ($inputbuf) {
310
            unless ($inputbuf) {
331
                C4::SIP::SIPServer::get_logger()->error("sip_protocol_loop: empty input skipped");
311
                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");
312
                print("96$CR");
334
                next;
313
                next;
335
            }
314
            }
Lines 337-347 sub sip_protocol_loop { Link Here
337
            my $status = C4::SIP::Sip::MsgType::handle( $inputbuf, $self, q{} );
316
            my $status = C4::SIP::Sip::MsgType::handle( $inputbuf, $self, q{} );
338
            if ( !$status ) {
317
            if ( !$status ) {
339
                C4::SIP::SIPServer::get_logger()->error("sip_protocol_loop: failed to handle " . substr( $inputbuf, 0, 2 ) );
318
                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
            }
319
            }
346
            next if $status eq REQUEST_ACS_RESEND;
320
            next if $status eq REQUEST_ACS_RESEND;
347
        }
321
        }
Lines 377-394 sub read_request { Link Here
377
      }
351
      }
378
      else {
352
      else {
379
          C4::SIP::SIPServer::get_logger()->debug('EOF returned on read');
353
          C4::SIP::SIPServer::get_logger()->debug('EOF returned on read');
380
          syslog( 'LOG_DEBUG', 'EOF returned on read' );
381
          return;
354
          return;
382
      }
355
      }
383
      my $len = length $buffer;
356
      my $len = length $buffer;
384
      if ( $len != $raw_length ) {
357
      if ( $len != $raw_length ) {
385
          my $trim = $raw_length - $len;
358
          my $trim = $raw_length - $len;
386
          C4::SIP::SIPServer::get_logger()->debug("read_request trimmed $trim character(s) ");
359
          C4::SIP::SIPServer::get_logger()->debug("read_request trimmed $trim character(s) ");
387
          syslog( 'LOG_DEBUG', "read_request trimmed $trim character(s) " );
388
      }
360
      }
389
361
390
      C4::SIP::SIPServer::get_logger()->info("INPUT MSG: '$buffer'");
362
      C4::SIP::SIPServer::get_logger()->info("INPUT MSG: '$buffer'");
391
      syslog( 'LOG_INFO', "INPUT MSG: '$buffer'" );
392
      return $buffer;
363
      return $buffer;
393
}
364
}
394
365
Lines 425-431 sub get_timeout { Link Here
425
        my $rv = sprintf( "%03d", $policy->{timeout} // 0 );
396
        my $rv = sprintf( "%03d", $policy->{timeout} // 0 );
426
        if( length($rv) != 3 ) {
397
        if( length($rv) != 3 ) {
427
            C4::SIP::SIPServer::get_logger()->error("LOG_ERR", "Policy timeout has wrong size: '$rv'");
398
            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';
399
            return '000';
430
        }
400
        }
431
        return $rv;
401
        return $rv;
(-)a/C4/SIP/Sip.pm (-6 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-124 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);
117
	       $label, $count);
123
		$count = ' ' x 4;
118
		$count = ' ' x 4;
124
    }
119
    }
Lines 190-196 sub write_msg { Link Here
190
        STDOUT->autoflush(1);
185
        STDOUT->autoflush(1);
191
        print $msg, $terminator;
186
        print $msg, $terminator;
192
        C4::SIP::SIPServer::get_logger()->info("OUTPUT MSG: '$msg'");
187
        C4::SIP::SIPServer::get_logger()->info("OUTPUT MSG: '$msg'");
193
        syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
194
    }
188
    }
195
189
196
    $last_response = $msg;
190
    $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 766-787 sub handle_sc_status { Link Here
766
        $new_proto = 2;
754
        $new_proto = 2;
767
    } else {
755
    } else {
768
        C4::SIP::SIPServer::get_logger()->warn("Unrecognized protocol revision '$sc_protocol_version', falling back to '1'");
756
        C4::SIP::SIPServer::get_logger()->warn("Unrecognized protocol revision '$sc_protocol_version', falling back to '1'");
769
        syslog( "LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version );
770
        $new_proto = 1;
757
        $new_proto = 1;
771
    }
758
    }
772
759
773
    if ( $new_proto != $protocol_version ) {
760
    if ( $new_proto != $protocol_version ) {
774
        C4::SIP::SIPServer::get_logger()->info("Setting protocol level to $new_proto");
761
        C4::SIP::SIPServer::get_logger()->info("Setting protocol level to $new_proto");
775
        syslog( "LOG_INFO", "Setting protocol level to $new_proto" );
776
        $protocol_version = $new_proto;
762
        $protocol_version = $new_proto;
777
    }
763
    }
778
764
779
    if ( $status == SC_STATUS_PAPER ) {
765
    if ( $status == SC_STATUS_PAPER ) {
780
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' out of paper");
766
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' out of paper");
781
        syslog( "LOG_WARNING", "Self-Check unit '%s@%s' out of paper", $self->{account}->{id}, $self->{account}->{institution} );
782
    } elsif ( $status == SC_STATUS_SHUTDOWN ) {
767
    } elsif ( $status == SC_STATUS_SHUTDOWN ) {
783
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' shutting down");
768
        C4::SIP::SIPServer::get_logger()->warn("Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' shutting down");
784
        syslog( "LOG_WARNING", "Self-Check unit '%s@%s' shutting down", $self->{account}->{id}, $self->{account}->{institution} );
785
    }
769
    }
786
770
787
    $self->{account}->{print_width} = $print_width;
771
    $self->{account}->{print_width} = $print_width;
Lines 822-832 sub login_core { Link Here
822
    my $status = 1;                 # Assume it all works
806
    my $status = 1;                 # Assume it all works
823
    if ( !exists( $server->{config}->{accounts}->{$uid} ) ) {
807
    if ( !exists( $server->{config}->{accounts}->{$uid} ) ) {
824
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Unknown login '$uid'");
808
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Unknown login '$uid'");
825
        syslog( "LOG_WARNING", "MsgType::login_core: Unknown login '$uid'" );
826
        $status = 0;
809
        $status = 0;
827
    } elsif ( $server->{config}->{accounts}->{$uid}->{password} ne $pwd ) {
810
    } elsif ( $server->{config}->{accounts}->{$uid}->{password} ne $pwd ) {
828
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Invalid password for login '$uid'");
811
        C4::SIP::SIPServer::get_logger()->warn("MsgType::login_core: Invalid password for login '$uid'");
829
        syslog( "LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'" );
830
        $status = 0;
812
        $status = 0;
831
    } else {
813
    } else {
832
814
Lines 841-858 sub login_core { Link Here
841
        my $auth_status = api_auth( $uid, $pwd, $inst );
823
        my $auth_status = api_auth( $uid, $pwd, $inst );
842
        if ( !$auth_status or $auth_status !~ /^ok$/i ) {
824
        if ( !$auth_status or $auth_status !~ /^ok$/i ) {
843
            C4::SIP::SIPServer::get_logger()->warn("api_auth failed for SIP terminal '$uid' of '$inst': " . ($auth_status||'unknown') );
825
            C4::SIP::SIPServer::get_logger()->warn("api_auth failed for SIP terminal '$uid' of '$inst': " . ($auth_status||'unknown') );
844
            syslog( "LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", $uid, $inst, ( $auth_status || 'unknown' ) );
845
            $status = 0;
826
            $status = 0;
846
        } else {
827
        } else {
847
            C4::SIP::SIPServer::get_logger()->info("Successful login/auth for '$server->{account}->{id}' of '$inst'");
828
            C4::SIP::SIPServer::get_logger()->info("Successful login/auth for '$server->{account}->{id}' of '$inst'");
848
            syslog( "LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst );
849
829
850
            #
830
            #
851
            # initialize connection to ILS
831
            # initialize connection to ILS
852
            #
832
            #
853
            my $module = $server->{config}->{institutions}->{$inst}->{implementation};
833
            my $module = $server->{config}->{institutions}->{$inst}->{implementation};
854
            C4::SIP::SIPServer::get_logger()->debug("login_core: " . Dumper($module) );
834
            C4::SIP::SIPServer::get_logger()->debug("login_core: " . Dumper($module) );
855
            syslog( "LOG_DEBUG", 'login_core: ' . Dumper($module) );
856
835
857
            # Suspect this is always ILS but so we don't break any eccentic install (for now)
836
            # Suspect this is always ILS but so we don't break any eccentic install (for now)
858
            if ( $module eq 'ILS' ) {
837
            if ( $module eq 'ILS' ) {
Lines 861-867 sub login_core { Link Here
861
            $module->use;
840
            $module->use;
862
            if ($@) {
841
            if ($@) {
863
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: Loading ILS implementation '$module' for institution '$inst' failed");
842
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: Loading ILS implementation '$module' for institution '$inst' failed");
864
                syslog( "LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", $server->{service}, $module, $inst );
865
                die("Failed to load ILS implementation '$module' for $inst");
843
                die("Failed to load ILS implementation '$module' for $inst");
866
            }
844
            }
867
845
Lines 869-875 sub login_core { Link Here
869
            $server->{ils} = $module->new( $server->{institution}, $server->{account} );
847
            $server->{ils} = $module->new( $server->{institution}, $server->{account} );
870
            if ( !$server->{ils} ) {
848
            if ( !$server->{ils} ) {
871
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: ILS connection to '$inst' failed");
849
                C4::SIP::SIPServer::get_logger()->error("$server->{service}: ILS connection to '$inst' failed");
872
                syslog( "LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst );
873
                die("Unable to connect to ILS '$inst'");
850
                die("Unable to connect to ILS '$inst'");
874
            }
851
            }
875
        }
852
        }
Lines 893-899 sub handle_login { Link Here
893
870
894
    if ( $uid_algorithm || $pwd_algorithm ) {
871
    if ( $uid_algorithm || $pwd_algorithm ) {
895
        C4::SIP::SIPServer::get_logger()->error("LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm");
872
        C4::SIP::SIPServer::get_logger()->error("LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm");
896
        syslog( "LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm" );
897
        $status = 0;
873
        $status = 0;
898
    } else {
874
    } else {
899
        $status = login_core( $server, $uid, $pwd );
875
        $status = login_core( $server, $uid, $pwd );
Lines 933-946 sub summary_info { Link Here
933
    }
909
    }
934
910
935
    C4::SIP::SIPServer::get_logger()->debug("Summary_info: index == '$summary_type', field '$summary_map[$summary_type]->{fid}'");
911
    C4::SIP::SIPServer::get_logger()->debug("Summary_info: index == '$summary_type', field '$summary_map[$summary_type]->{fid}'");
936
    syslog( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} );
937
912
938
    my $func     = $summary_map[$summary_type]->{func};
913
    my $func     = $summary_map[$summary_type]->{func};
939
    my $fid      = $summary_map[$summary_type]->{fid};
914
    my $fid      = $summary_map[$summary_type]->{fid};
940
    my $itemlist = &$func( $patron, $start, $end, $server );
915
    my $itemlist = &$func( $patron, $start, $end, $server );
941
916
942
    C4::SIP::SIPServer::get_logger()->debug("summary_info: list = (" . join(", ", @{$itemlist}) . ")");
917
    C4::SIP::SIPServer::get_logger()->debug("summary_info: list = (" . join(", ", @{$itemlist}) . ")");
943
    syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", @{$itemlist} ) );
944
    foreach my $i ( @{$itemlist} ) {
918
    foreach my $i ( @{$itemlist} ) {
945
        $resp .= add_field( $fid, $i->{barcode} );
919
        $resp .= add_field( $fid, $i->{barcode} );
946
    }
920
    }
Lines 1207-1213 sub handle_item_status_update { Link Here
1207
1181
1208
    if ( !defined($item_id) ) {
1182
    if ( !defined($item_id) ) {
1209
        C4::SIP::SIPServer::get_logger()->warn("handle_item_status: received message without Item ID field");
1183
        C4::SIP::SIPServer::get_logger()->warn("handle_item_status: received message without Item ID field");
1210
        syslog( "LOG_WARNING", "handle_item_status: received message without Item ID field" );
1211
    } else {
1184
    } else {
1212
        $item = $ils->find_item($item_id);
1185
        $item = $ils->find_item($item_id);
1213
    }
1186
    }
Lines 1253-1259 sub handle_patron_enable { Link Here
1253
    $patron_pwd = $fields->{ (FID_PATRON_PWD) };
1226
    $patron_pwd = $fields->{ (FID_PATRON_PWD) };
1254
1227
1255
    C4::SIP::SIPServer::get_logger()->debug("handle_patron_enable: patron_id: '$patron_id', patron_pwd: '$patron_pwd'");
1228
    C4::SIP::SIPServer::get_logger()->debug("handle_patron_enable: patron_id: '$patron_id', patron_pwd: '$patron_pwd'");
1256
    syslog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd );
1257
1229
1258
    $patron = $ils->find_patron($patron_id);
1230
    $patron = $ils->find_patron($patron_id);
1259
1231
Lines 1324-1330 sub handle_hold { Link Here
1324
        $status = $ils->alter_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack );
1296
        $status = $ils->alter_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack );
1325
    } else {
1297
    } else {
1326
        C4::SIP::SIPServer::get_logger()->warn("handle_hold: Unrecognized hold mode '$hold_mode' from terminal '$server->{account}->{id}'");
1298
        C4::SIP::SIPServer::get_logger()->warn("handle_hold: Unrecognized hold mode '$hold_mode' from terminal '$server->{account}->{id}'");
1327
        syslog( "LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", $hold_mode, $server->{account}->{id} );
1328
        $status = $ils->Transaction::Hold;    # new?
1299
        $status = $ils->Transaction::Hold;    # new?
1329
        $status->screen_msg("System error. Please contact library staff.");
1300
        $status->screen_msg("System error. Please contact library staff.");
1330
    }
1301
    }
Lines 1373-1379 sub handle_renew { Link Here
1373
1344
1374
    if ( $no_block eq 'Y' ) {
1345
    if ( $no_block eq 'Y' ) {
1375
        C4::SIP::SIPServer::get_logger()->warn("handle_renew: received 'no block' renewal from terminal '$server->{account}->{id}'");
1346
        C4::SIP::SIPServer::get_logger()->warn("handle_renew: received 'no block' renewal from terminal '$server->{account}->{id}'");
1376
        syslog( "LOG_WARNING", "handle_renew: received 'no block' renewal from terminal '%s'", $server->{account}->{id} );
1377
    }
1347
    }
1378
1348
1379
    $patron_id  = $fields->{ (FID_PATRON_ID) };
1349
    $patron_id  = $fields->{ (FID_PATRON_ID) };
Lines 1541-1547 sub send_acs_status { Link Here
1541
1511
1542
    if ( length($retries) != 3 ) {
1512
    if ( length($retries) != 3 ) {
1543
        C4::SIP::SIPServer::get_logger()->error("handle_acs_status: timeout field wrong size: '$timeout'");
1513
        C4::SIP::SIPServer::get_logger()->error("handle_acs_status: timeout field wrong size: '$timeout'");
1544
        syslog( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries );
1545
        $retries = '000';
1514
        $retries = '000';
1546
    }
1515
    }
1547
1516
Lines 1555-1561 sub send_acs_status { Link Here
1555
        $msg .= '2.00';
1524
        $msg .= '2.00';
1556
    } else {
1525
    } else {
1557
        C4::SIP::SIPServer::get_logger()->error("Bad setting for \$protocol_version, '$protocol_version' in send_acs_status");
1526
        C4::SIP::SIPServer::get_logger()->error("Bad setting for \$protocol_version, '$protocol_version' in send_acs_status");
1558
        syslog( "LOG_ERR", 'Bad setting for $protocol_version, "%s" in send_acs_status', $protocol_version );
1559
        $msg .= '1.00';
1527
        $msg .= '1.00';
1560
    }
1528
    }
1561
1529
Lines 1576-1582 sub send_acs_status { Link Here
1576
        }
1544
        }
1577
        if ( length($supported_msgs) < 16 ) {
1545
        if ( length($supported_msgs) < 16 ) {
1578
            C4::SIP::SIPServer::get_logger()->error("send_acs_status: supported messages '$supported_msgs' too short");
1546
            C4::SIP::SIPServer::get_logger()->error("send_acs_status: supported messages '$supported_msgs' too short");
1579
            syslog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs );
1580
        }
1547
        }
1581
        $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs );
1548
        $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs );
1582
    }
1549
    }
Lines 1587-1593 sub send_acs_status { Link Here
1587
        && defined($print_line)
1554
        && defined($print_line)
1588
        && $account->{print_width} < length($print_line) ) {
1555
        && $account->{print_width} < length($print_line) ) {
1589
        C4::SIP::SIPServer::get_logger()->warn("send_acs_status: print line '$print_line' too long.  Truncating");
1556
        C4::SIP::SIPServer::get_logger()->warn("send_acs_status: print line '$print_line' too long.  Truncating");
1590
        syslog( "LOG_WARNING", "send_acs_status: print line '%s' too long.  Truncating", $print_line );
1591
        $print_line = substr( $print_line, 0, $account->{print_width} );
1557
        $print_line = substr( $print_line, 0, $account->{print_width} );
1592
    }
1558
    }
1593
1559
Lines 1608-1614 sub patron_status_string { Link Here
1608
    my $patron_status;
1574
    my $patron_status;
1609
1575
1610
    C4::SIP::SIPServer::get_logger()->debug("patron_status_string: $patron->id charge_ok: $patron->charge_ok");
1576
    C4::SIP::SIPServer::get_logger()->debug("patron_status_string: $patron->id charge_ok: $patron->charge_ok");
1611
    syslog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok );
1612
    $patron_status = sprintf(
1577
    $patron_status = sprintf(
1613
        '%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
1578
        '%s%s%s%s%s%s%s%s%s%s%s%s%s%s',
1614
        denied( $patron->charge_ok ),
1579
        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