From fc12b61750af8354699d86aba3c0056aa392419f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 13 May 2020 15:09:31 -0400 Subject: [PATCH 1/5] Fix probing --- scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in index 86cb859c6..2341e1748 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in @@ -39,12 +39,10 @@ our %EXPORT_TAGS = ( ); push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS; -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } ); our @EXPORT = qw(); -our $VERSION = $ZoneMinder::Base::VERSION; - use Data::UUID; use vars qw( $verbose $soap_version ); @@ -60,6 +58,9 @@ require WSDiscovery::TransportUDP; sub deserialize_message { my ($wsdl_client, $response) = @_; + if ( ! $response ) { + return; + } # copied and adapted from SOAP::WSDL::Client @@ -74,20 +75,16 @@ sub deserialize_message { } # set class resolver if serializer supports it $deserializer->set_class_resolver( $wsdl_client->get_class_resolver() ) - if ( $deserializer->can('set_class_resolver') ); + if $deserializer->can('set_class_resolver'); # Try deserializing response - there may be some, -# even if transport did not succeed (got a 500 response) - if ( ! $response ) { - return; - } - +# even if transport did not succeed (got a 500 response) # as our faults are false, returning a success marker is the only # reliable way of determining whether the deserializer succeeded. # Custom deserializers may return an empty list, or undef, # and $@ is not guaranteed to be undefined. my ($success, $result_body, $result_header) = eval { - (1, $deserializer->deserialize( $response )); + (1, $deserializer->deserialize($response)); }; if ( defined $success ) { return wantarray @@ -110,10 +107,7 @@ sub interpret_messages { my @results; foreach my $response ( @responses ) { - - if ( $verbose ) { - print "Received message:\n" . $response . "\n"; - } + print "Received message:\n" . $response . "\n" if $verbose; my $result = deserialize_message($svc_discover, $response); if ( not $result ) { @@ -151,17 +145,16 @@ sub interpret_messages { foreach my $scope (split ' ', $scopes) { if ( $scope =~ m|onvif://www\.onvif\.org/(.+)/(.*)| ) { my ($attr, $value) = ($1,$2); - if ( 0 < $count ++) { - print ', '; - } + print ', ' if 0 < $count ++; print $attr . '=\'' . $value . '\''; $scopes{$attr} = $value; } } print ")\n"; - push @results, { xaddr=>$xaddr, + push @results, { + xaddr => $xaddr, soap_version => $svc_discover->get_soap_version(), - scopes => \%scopes, + scopes => \%scopes, }; } return @results; @@ -170,7 +163,7 @@ sub interpret_messages { # functions sub discover { - my ( $soap_version, $net_interface ) = @_; + my ($soap_version, $net_interface) = @_; my @results; ## collect all responses @@ -195,7 +188,7 @@ sub discover { $svc_discover->set_soap_version($version); if ( $net_interface ) { my $transport = $svc_discover->get_transport(); - print "Setting net interface for $transport to $net_interface\n"; + print "Setting net interface for $transport to $net_interface\n" if $verbose; $transport->set_net_interface($net_interface); } @@ -203,7 +196,15 @@ sub discover { my $result = $svc_discover->ProbeOp( { # WSDiscovery::Types::ProbeType - Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType + ( + ($version eq '1.1') ? + ( + Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType + ) : ( + xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl', }, + Types => 'dn:NetworkVideoTransmitter', # QNameListType + ) + ), Scopes => { value => '' }, }, WSDiscovery10::Elements::Header->new({ @@ -215,22 +216,23 @@ sub discover { print $result."\n" if $verbose; push @results, interpret_messages($svc_discover, \%services, @responses); + @responses = (); } # end foreach version return @results; } # end sub discover sub profiles { - my ( $client ) = @_; + my ($client) = @_; my $media = $client->get_endpoint('media'); - if ( ! $media ) { + if ( !$media ) { print "No media endpoint for client.\n"; return; } my $result = $media->GetProfiles( { } ,, ); - if ( ! $result ) { + if ( !$result ) { print "No result from GetProfiles.\n"; return; } @@ -244,7 +246,7 @@ sub profiles { print "No profiles returned from get_Profiles\n"; return; } - print "Number of profiles found: " .(scalar @Profiles)."\n" if $verbose; + print 'Number of profiles found: ' .(scalar @Profiles)."\n" if $verbose; my @profiles; foreach my $profile ( @Profiles ) { @@ -339,12 +341,12 @@ sub move { } # end sub move sub metadata { - my ( $client ) = @_; + my ($client) = @_; my $media = $client->get_endpoint('media'); die 'No media endpoint.' if !$media; my $result = $media->GetMetadataConfigurations( { } ,, ); - if ( ! $result ) { + if ( !$result ) { print "No MetaDataConfigurations\n" if $verbose; } else { print $result . "\n"; @@ -363,8 +365,6 @@ sub metadata { } - - 1; __END__ From 437a96915fbae05dfe3df6c09e28530be500feb6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 13 May 2020 15:24:58 -0400 Subject: [PATCH 2/5] sketchy fix for soap 1.1 --- scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in index 2341e1748..01536bf77 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ONVIF.pm.in @@ -202,9 +202,9 @@ sub discover { Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType ) : ( xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl', }, - Types => 'dn:NetworkVideoTransmitter', # QNameListType ) ), + Types => 'dn:NetworkVideoTransmitter', # QNameListType Scopes => { value => '' }, }, WSDiscovery10::Elements::Header->new({ From 880b456d933e611c670e0a51095356640f607fcc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 13 May 2020 15:30:56 -0400 Subject: [PATCH 3/5] Rrename MetaConfig to ONVIF --- web/skins/classic/views/monitor.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index be4df7b16..f137c58cd 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -169,12 +169,6 @@ if ( !ZM_PCRE ) // Currently unsupported unset($httpMethods['jpegTags']); -$configTypes = array( - 'None' => translate('None'), - 'ONVIF' => 'ONVIF', - 'PSIA' => 'PSIA', -); - if ( ZM_HAS_V4L1 ) { $v4l1DeviceFormats = array( 'PAL' => 0, @@ -419,7 +413,7 @@ if ( canEdit('Monitors') ) { $tabs = array(); $tabs['general'] = translate('General'); $tabs['source'] = translate('Source'); -$tabs["config"] = translate('MetaConfig'); +$tabs['onvif'] = translate('ONVIF'); if ( $monitor->Type() != 'WebSite' ) { $tabs['storage'] = translate('Storage'); $tabs['timestamp'] = translate('Timestamp'); From 992ac144a9a728a6b88c93290920d2c706ab21ed Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 13 May 2020 16:04:26 -0400 Subject: [PATCH 4/5] Fix ONVIF_User => ONVIF_Username --- web/skins/classic/views/monitor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index f137c58cd..910adc539 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -492,7 +492,7 @@ if ( ZM_HAS_V4L && ($tab != 'source' || $monitor->Type() != 'Local') ) { if ( $tab != 'onvif' ) { ?> - + Date: Wed, 13 May 2020 16:06:26 -0400 Subject: [PATCH 5/5] Fix log file containing - or _ --- scripts/ZoneMinder/lib/ZoneMinder/Logger.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm index 39c10a058..0513f563e 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm @@ -210,7 +210,7 @@ sub initialise( @ ) { if ( my $logFile = $this->getTargettedEnv('LOG_FILE') ) { $tempLogFile = $logFile; } - ($tempLogFile) = $tempLogFile =~ /^([\w\.\/]+)$/; + ($tempLogFile) = $tempLogFile =~ /^([_\-\w\.\/]+)$/; my $tempLevel = INFO; my $tempTermLevel = $this->{termLevel}; @@ -456,9 +456,9 @@ sub fileLevel { if ( defined($fileLevel) ) { $fileLevel = $this->limit($fileLevel); # The filename might have changed, so always close and re-open - $this->closeFile() if ( $this->{fileLevel} > NOLOG ); + $this->closeFile() if $this->{fileLevel} > NOLOG; $this->{fileLevel} = $fileLevel; - $this->openFile() if ( $this->{fileLevel} > NOLOG ); + $this->openFile() if $this->{fileLevel} > NOLOG; } return $this->{fileLevel}; } @@ -499,6 +499,7 @@ sub logFile { sub openFile { my $this = shift; + if ( open($LOGFILE, '>>', $this->{logFile}) ) { $LOGFILE->autoflush() if $this->{autoFlush}; @@ -519,7 +520,6 @@ sub openFile { } sub closeFile { - #my $this = shift; close($LOGFILE) if fileno($LOGFILE); }