Bugzilla – Attachment 53013 Details for
Bug 15006
Need to distinguish client timeout from login timeout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15006: Add timeout and strikes to raw_transport
Bug-15006-Add-timeout-and-strikes-to-rawtransport.patch (text/plain), 2.75 KB, created by
Marcel de Rooy
on 2016-07-01 10:15:55 UTC
(
hide
)
Description:
Bug 15006: Add timeout and strikes to raw_transport
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-07-01 10:15:55 UTC
Size:
2.75 KB
patch
obsolete
>From cd295f7cecf890d45f8aba296f9c2c7197b6acb0 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 17 Jun 2016 11:39:12 +0200 >Subject: [PATCH] Bug 15006: Add timeout and strikes to raw_transport >Content-Type: text/plain; charset=utf-8 > >The code in raw_transport includes setting a $SIG{ALRM}, but did not >use it. For consistency, we add an alarm statement here. > >Similarly, we add the "three strikes" to raw_transport just as >telnet_transport does. Note that raw_transport still responds to other >requests, but will exit if there is no valid login within three >attempts. (If we want more restrictions, add them later?) > >Test plan: >[1] Start sip session with telnet on raw port 6001. > Wait until it times out (probably the default 60 seconds). >[2] Change SIPconfig.xml: set timeout=5 for service port 6001. > Restart SIP and start another telnet 6001 session. > Did it timeout within 5 seconds? >[3] Start another 6001 session. Give three wrong requests or false > login attempts. Does the connection close? > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/SIP/SIPServer.pm | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) > >diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm >index e496683..a972182 100755 >--- a/C4/SIP/SIPServer.pm >+++ b/C4/SIP/SIPServer.pm >@@ -124,20 +124,30 @@ sub process_request { > > sub raw_transport { > my $self = shift; >- my ($input); > my $service = $self->{service}; >+ my $strikes = 3; >+ >+ local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; >+ my $timeout = $service->{timeout} || 30; >+ syslog("LOG_DEBUG", "raw_transport: timeout is %d", $timeout); > >- while (!$self->{account}) { >- local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; >- syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout}); >- $input = read_request(); >+ while( $strikes && ( !$self->{account} || !$self->{account}->{id} )) { >+ # an empty account hash is not good enough.. >+ alarm $timeout; >+ my $input = read_request(); > if (!$input) { > # EOF on the socket > syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); > return; > } > $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) >- last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); >+ C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); >+ $strikes--; >+ } >+ alarm 0; >+ if( !$self->{account} || !$self->{account}->{id} ) { >+ syslog("LOG_ERR", "raw_transport: Login Failed"); >+ die "Login Failure"; > } > > syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15006
:
45039
|
45583
|
45594
|
52477
|
52478
|
52479
|
52480
|
52784
|
52785
|
52786
|
52787
|
52849
|
52850
|
52851
|
52852
|
52853
|
53009
|
53010
|
53011
|
53012
|
53013
|
53014
|
53132
|
53133
|
53134
|
53135
|
53309
|
53310
|
53311
|
53312
|
53355
|
53356
|
53357
|
53358
|
53359
|
53360
|
53363
|
53364
|
53365
|
53366
|
53367
|
53368
|
53369