From 5390605797d2ec8db4c6eb81752cd6e6c1dc2fac Mon Sep 17 00:00:00 2001 From: SteveGilvarry Date: Thu, 3 Dec 2015 10:23:19 +1100 Subject: [PATCH 1/2] Add v to front of version string in version->parse to force conversion of decimal to dotted decimal versions, and change from ge to > to prevent reapplying current version --- scripts/zmupdate.pl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index e9f4a2dc2..969c72cb6 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -1044,7 +1044,7 @@ if ( $version ) foreach my $patch ( @files ) { my ( $v ) = $patch =~ /^zm_update\-([\d\.]+)\.sql$/; #PP make sure we use version compare - if ( version->parse($v) ge version->parse($version) ) { + if ( version->parse('v' . $v) > version->parse('v' . $version) ) { print( "Upgrading DB to $v from $version\n" ); patchDB( $dbh, $v ); if ( $dbh->errstr() ) { From 7c298c58ed0aab83b860ac2c768d125f3c2a3bbf Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 8 Dec 2015 16:20:38 -0500 Subject: [PATCH 2/2] Add code to detect the change in REALM from older to newer firmware --- .../lib/ZoneMinder/Control/TVIP862.pm | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm index 050e2bb75..d7c669583 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm @@ -138,6 +138,30 @@ sub open ."'" ); $self->{ua}->credentials($ADDRESS,$REALM,$USERNAME,$PASSWORD); + + # Detect REALM + my $req = HTTP::Request->new( GET=>"http://".$ADDRESS."/cgi/ptdc.cgi" ); + my $res = $self->{ua}->request($req); + + if ( ! $res->is_success ) { + Debug("Need newer REALM"); + if ( $res->status_line() eq '401 Unauthorized' ) { + my $headers = $res->headers(); + foreach my $k ( keys %$headers ) { + Debug("Initial Header $k => $$headers{$k}"); + } # end foreach + if ( $$headers{'www-authenticate'} ) { + my ( $auth, $tokens ) = $$headers{'www-authenticate'} =~ /^(\w+)\s+(.*)$/; + if ( $tokens =~ /\w+="([^"]+)"/i ) { + $REALM = $1; + Debug( "Changing REALM to $REALM" ); + $self->{ua}->credentials($ADDRESS,$REALM,$USERNAME,$PASSWORD); + } # end if + } else { + Debug("No headers line"); + } # end if headers + } # end if $res->status_line() eq '401 Unauthorized' + } # end if ! $res->is_success } sub close