From 0134f8e4476aa93bef6c87f18b8fa0f17ef11da8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Jul 2023 12:42:20 -0400 Subject: [PATCH] Change detect_realm to return empty string instead o f undef. Just so that realm is always a string and not undefined. Fix integer comparison on strings and make detect_realm succeed as long as response isn't 401. --- scripts/ZoneMinder/lib/ZoneMinder/Control/Trendnet.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/Trendnet.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/Trendnet.pm index 659d883d4..4b1ecea45 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/Trendnet.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/Trendnet.pm @@ -83,7 +83,7 @@ sub open { # Detect REALM $REALM = $self->detect_realm($PROTOCOL, $ADDRESS, $REALM, $USERNAME, $PASSWORD, '/cgi/ptdc.cgi'); - if (defined($REALM)) { + if ($REALM) { $self->{state} = 'open'; return !undef; } @@ -118,7 +118,7 @@ sub detect_realm { Debug("Changing REALM to $realm"); $self->{ua}->credentials($address, $realm, $username, $password); $res = $self->{ua}->get($protocol.$address.$url); - if ($res->is_success()) { + if ($res->status_line() ne '401 Unauthorized') { return $realm; } Error('Authentication still failed after updating REALM' . $res->status_line); @@ -135,7 +135,7 @@ sub detect_realm { } else { Debug('No headers line'); } # end if headers - return undef; + return ''; } sub sendCmd { @@ -425,7 +425,7 @@ sub reset { sub reboot { my $self = shift; Debug('Camera Reboot'); - if ($$self{state} != 'open') { + if ($$self{state} ne 'open') { Warning("Not open. opening. Should call ->open() before calling reboot()"); return if !$self->open(); }