From c64f9005604e88eb49d201a07e3cd0b3d7280a01 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 17 Jun 2016 11:07:16 +0200 Subject: [PATCH] Bug 15006: [QA Follow-up] Indentation for two subroutines Content-Type: text/plain; charset=utf-8 Remove tabs from telnet_transport and sip_protocol_loop. Correct indentation. Test plan: Compare files before and after without whitespace (diff -b). Notice only two split lines. Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/SIP/SIPServer.pm | 116 +++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index d556845..aff49e5 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -128,21 +128,21 @@ sub raw_transport { my $service = $self->{service}; 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(); - 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); + local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; + syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout}); + $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); } syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", - $self->{account}->{id}, - $self->{account}->{institution}); + $self->{account}->{id}, + $self->{account}->{institution}); $self->sip_protocol_loop(); syslog("LOG_INFO", "raw_transport: shutting down"); @@ -180,55 +180,55 @@ sub telnet_transport { my $account = undef; my $input; my $config = $self->{config}; - my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; - syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout); + my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; + syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout); eval { - local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; }; - local $| = 1; # Unbuffered output - $/ = "\015"; # Internet Record Separator (lax version) - # Until the terminal has logged in, we don't trust it - # so use a timeout to protect ourselves from hanging. - - while ($strikes--) { - print "login: "; - alarm $timeout; - # $uid = &get_clean_input; - $uid = ; - print "password: "; - # $pwd = &get_clean_input || ''; - $pwd = ; - alarm 0; - - syslog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd)); - $uid = get_clean_string ($uid); - $pwd = get_clean_string ($pwd); - syslog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd)); - - if (exists ($config->{accounts}->{$uid}) - && ($pwd eq $config->{accounts}->{$uid}->{password})) { - $account = $config->{accounts}->{$uid}; - if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) { - last; + local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; }; + local $| = 1; # Unbuffered output + $/ = "\015"; # Internet Record Separator (lax version) + # Until the terminal has logged in, we don't trust it + # so use a timeout to protect ourselves from hanging. + + while ($strikes--) { + print "login: "; + alarm $timeout; + # $uid = &get_clean_input; + $uid = ; + print "password: "; + # $pwd = &get_clean_input || ''; + $pwd = ; + alarm 0; + + syslog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd)); + $uid = get_clean_string ($uid); + $pwd = get_clean_string ($pwd); + syslog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd)); + + if( exists ($config->{accounts}->{$uid}) && ($pwd eq $config->{accounts}->{$uid}->{password})) { + $account = $config->{accounts}->{$uid}; + if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) { + last; + } } - } - syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||'')); - print("Invalid login$CRLF"); - } + syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||'')); + print("Invalid login$CRLF"); + } }; # End of eval if ($@) { - syslog("LOG_ERR", "telnet_transport: Login timed out"); - die "Telnet Login Timed out"; + syslog("LOG_ERR", "telnet_transport: Login timed out"); + die "Telnet Login Timed out"; } elsif (!defined($account)) { - syslog("LOG_ERR", "telnet_transport: Login Failed"); - die "Login Failure"; + syslog("LOG_ERR", "telnet_transport: Login Failed"); + die "Login Failure"; } else { - print "Login OK. Initiating SIP$CRLF"; + print "Login OK. Initiating SIP$CRLF"; } $self->{account} = $account; - syslog("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", $account->{id}, $account->{institution}); + syslog("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", + $account->{id}, $account->{institution}); $self->sip_protocol_loop(); syslog("LOG_INFO", "telnet_transport: shutting down"); return; @@ -240,14 +240,14 @@ sub telnet_transport { # telnet transport. From that point on, both the raw and the telnet # processes are the same: sub sip_protocol_loop { - my $self = shift; - my $service = $self->{service}; - my $config = $self->{config}; + my $self = shift; + my $service = $self->{service}; + my $config = $self->{config}; my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; # The spec says the first message will be: - # SIP v1: SC_STATUS - # SIP v2: LOGIN (or SC_STATUS via telnet?) + # SIP v1: SC_STATUS + # SIP v2: LOGIN (or SC_STATUS via telnet?) # But it might be SC_REQUEST_RESEND. As long as we get # SC_REQUEST_RESEND, we keep waiting. @@ -255,9 +255,9 @@ sub sip_protocol_loop { # constraint, so we'll relax about it too. # Using the SIP "raw" login process, rather than telnet, # requires the LOGIN message and forces SIP 2.00. In that - # case, the LOGIN message has already been processed (above). - # - # In short, we'll take any valid message here. + # case, the LOGIN message has already been processed (above). + # + # In short, we'll take any valid message here. eval { local $SIG{ALRM} = sub { syslog( 'LOG_DEBUG', 'Inactive: timed out' ); -- 1.7.10.4