From 0b5ebbbe59e861a1c1b15c715b2caa503fd3ac3a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 24 Mar 2020 14:56:25 -0400 Subject: [PATCH 01/10] add focal to ubuntu builds --- utils/do_debian_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 539205e3b..af9921294 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -80,7 +80,7 @@ fi; if [ "$DISTROS" == "" ]; then if [ "$RELEASE" != "" ]; then - DISTROS="xenial,bionic,disco,eoan,trusty" + DISTROS="xenial,bionic,disco,eoan,focal,trusty" else DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; fi; From a5ec89ab1b2408a740a25428682d0aebec0f486a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 24 Mar 2020 15:30:52 -0400 Subject: [PATCH 02/10] use bool instead of my_bool to fix #2886 --- src/zm_db.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_db.cpp b/src/zm_db.cpp index 77c149f03..8e6258b0b 100644 --- a/src/zm_db.cpp +++ b/src/zm_db.cpp @@ -40,7 +40,7 @@ bool zmDbConnect() { Error("Can't initialise database connection: %s", mysql_error(&dbconn)); return false; } - my_bool reconnect = 1; + bool reconnect = 1; if ( mysql_options(&dbconn, MYSQL_OPT_RECONNECT, &reconnect) ) Error("Can't set database auto reconnect option: %s", mysql_error(&dbconn)); if ( !staticConfig.DB_SSL_CA_CERT.empty() ) From ea7bea4c6e20e4e0cd558c86c4f3006cfede50a6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 24 Mar 2020 15:30:16 -0400 Subject: [PATCH 03/10] fix warnings because length() returns long unsigned int, but gnutls_datum_t size is unsigned int. --- src/zm_rtsp_auth.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zm_rtsp_auth.cpp b/src/zm_rtsp_auth.cpp index 81aa13c27..2f8b2c3ce 100644 --- a/src/zm_rtsp_auth.cpp +++ b/src/zm_rtsp_auth.cpp @@ -144,7 +144,7 @@ std::string Authenticator::computeDigestResponse(std::string &method, std::strin #if HAVE_DECL_MD5 MD5((unsigned char*)ha1Data.c_str(), ha1Data.length(), md5buf); #elif HAVE_DECL_GNUTLS_FINGERPRINT - gnutls_datum_t md5dataha1 = { (unsigned char*)ha1Data.c_str(), ha1Data.length() }; + gnutls_datum_t md5dataha1 = { (unsigned char*)ha1Data.c_str(), (unsigned int)ha1Data.length() }; gnutls_fingerprint( GNUTLS_DIG_MD5, &md5dataha1, md5buf, &md5len ); #endif for ( unsigned int j = 0; j < md5len; j++ ) { @@ -159,7 +159,7 @@ std::string Authenticator::computeDigestResponse(std::string &method, std::strin #if HAVE_DECL_MD5 MD5((unsigned char*)ha2Data.c_str(), ha2Data.length(), md5buf ); #elif HAVE_DECL_GNUTLS_FINGERPRINT - gnutls_datum_t md5dataha2 = { (unsigned char*)ha2Data.c_str(), ha2Data.length() }; + gnutls_datum_t md5dataha2 = { (unsigned char*)ha2Data.c_str(), (unsigned int)ha2Data.length() }; gnutls_fingerprint( GNUTLS_DIG_MD5, &md5dataha2, md5buf, &md5len ); #endif for ( unsigned int j = 0; j < md5len; j++ ) { @@ -180,7 +180,7 @@ std::string Authenticator::computeDigestResponse(std::string &method, std::strin #if HAVE_DECL_MD5 MD5((unsigned char*)digestData.c_str(), digestData.length(), md5buf); #elif HAVE_DECL_GNUTLS_FINGERPRINT - gnutls_datum_t md5datadigest = { (unsigned char*)digestData.c_str(), digestData.length() }; + gnutls_datum_t md5datadigest = { (unsigned char*)digestData.c_str(), (unsigned int)digestData.length() }; gnutls_fingerprint( GNUTLS_DIG_MD5, &md5datadigest, md5buf, &md5len ); #endif for ( unsigned int j = 0; j < md5len; j++ ) { From eed45ae66c449af305c1f24a944535b1c6c8e4fd Mon Sep 17 00:00:00 2001 From: hax0kartik Date: Tue, 24 Mar 2020 09:29:19 -0700 Subject: [PATCH 04/10] Fix 2892 --- CMakeLists.txt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 018fc0eb0..a15267582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -738,14 +738,6 @@ if(HAVE_OPENSSL_MD5_H) "unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)" "NULL" "openssl/md5.h" HAVE_MD5_OPENSSL) endif(HAVE_OPENSSL_MD5_H) -if(HAVE_GNUTLS_OPENSSL_H) - set(CMAKE_REQUIRED_LIBRARIES "${GNUTLS_LIBRARIES}") - set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}") - check_prototype_definition( - MD5 - "unsigned char *MD5 (const unsigned char *buf, unsigned long len, unsigned char *md)" "NULL" "gnutls/openssl.h" - HAVE_MD5_GNUTLS) -endif(HAVE_GNUTLS_OPENSSL_H) if(HAVE_GNUTLS_GNUTLS_H) set(CMAKE_REQUIRED_LIBRARIES "${GNUTLS_LIBRARIES}") set(CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIR}") @@ -754,13 +746,13 @@ if(HAVE_GNUTLS_GNUTLS_H) "int gnutls_fingerprint (gnutls_digest_algorithm_t algo, const gnutls_datum_t * data, void *result, size_t * result_size)" "0" "stdlib.h;gnutls/gnutls.h" HAVE_DECL_GNUTLS_FINGERPRINT) endif(HAVE_GNUTLS_GNUTLS_H) -if(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS) +if(HAVE_MD5_OPENSSL) set(HAVE_DECL_MD5 1) -else(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS) +else(HAVE_MD5_OPENSSL) message(AUTHOR_WARNING "ZoneMinder requires a working MD5 function for hashed authenication but none were found - hashed authenication will not be available") -endif(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS) +endif(HAVE_MD5_OPENSSL) # Dirty fix for zm_user only using openssl's md5 if gnutls and gcrypt are not available. # This needs to be fixed in zm_user.[h,cpp] but such fix will also require changes to configure.ac if(HAVE_LIBCRYPTO AND HAVE_OPENSSL_MD5_H AND HAVE_MD5_OPENSSL) From cf6b24b432c4492b24117042e22e7b8242793b72 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 16 Mar 2020 14:49:27 -0400 Subject: [PATCH 05/10] add ES status to telemetry and --show option to display what is being sent to ZM --- scripts/zmtelemetry.pl.in | 47 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/scripts/zmtelemetry.pl.in b/scripts/zmtelemetry.pl.in index 9b5e7c89d..82ceeac96 100644 --- a/scripts/zmtelemetry.pl.in +++ b/scripts/zmtelemetry.pl.in @@ -45,6 +45,7 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; my $help = 0; my $force = 0; +my $show = 0; # Interval between version checks my $interval; my $version; @@ -52,6 +53,7 @@ my $version; GetOptions( force => \$force, help => \$help, + show => \$show, interval => \$interval, version => \$version ); @@ -59,6 +61,14 @@ if ( $version ) { print( ZoneMinder::Base::ZM_VERSION . "\n"); exit(0); } +if ($show) { + my %telemetry; + my $dbh = zmDbConnect(); + collectData($dbh, \%telemetry); + my $result = jsonEncode(\%telemetry); + print ($result); + exit(0); +} if ( $help ) { pod2usage(-exitstatus => -1); } @@ -89,21 +99,9 @@ while( 1 ) { my $dbh = zmDbConnect(); # Build the telemetry hash # We should keep *BSD systems in mind when calling system commands + my %telemetry; - $telemetry{uuid} = getUUID($dbh); - @telemetry{qw(city region country latitude longitude)} = getGeo(); - $telemetry{timestamp} = strftime('%Y-%m-%dT%H:%M:%S%z', localtime()); - $telemetry{monitor_count} = countQuery($dbh,'Monitors'); - $telemetry{event_count} = countQuery($dbh,'Events'); - $telemetry{architecture} = runSysCmd('uname -p'); - ($telemetry{kernel}, $telemetry{distro}, $telemetry{version}) = getDistro(); - $telemetry{zm_version} = ZoneMinder::Base::ZM_VERSION; - $telemetry{system_memory} = totalmem(); - $telemetry{processor_count} = cpu_count(); - $telemetry{monitors} = getMonitorRef($dbh); - - Info('Sending data to ZoneMinder Telemetry server.'); - + collectData($dbh,\%telemetry); my $result = jsonEncode(\%telemetry); if ( sendData($result) ) { @@ -126,6 +124,24 @@ print 'ZoneMinder Telemetry Agent exiting at '.strftime('%y/%m/%d %H:%M:%S', loc # SUBROUTINES # ############### +# collect data to send +sub collectData { + my $dbh = shift; + my $telemetry = shift; + $telemetry->{uuid} = getUUID($dbh); + ($telemetry->{city},$telemetry->{region},$telemetry->{country},$telemetry->{latitude},$telemetry->{longitude})=getGeo(); + $telemetry->{timestamp} = strftime('%Y-%m-%dT%H:%M:%S%z', localtime()); + $telemetry->{monitor_count} = countQuery($dbh,'Monitors'); + $telemetry->{event_count} = countQuery($dbh,'Events'); + $telemetry->{architecture} = runSysCmd('uname -p'); + ($telemetry->{kernel}, $telemetry->{distro}, $telemetry->{version}) = getDistro(); + $telemetry->{zm_version} = ZoneMinder::Base::ZM_VERSION; + $telemetry->{system_memory} = totalmem(); + $telemetry->{processor_count} = cpu_count(); + $telemetry->{use_event_server} = $Config{ZM_OPT_USE_EVENTNOTIFICATION}; + $telemetry->{monitors} = getMonitorRef($dbh); +} + # Find, verify, then run the supplied system command sub runSysCmd { my $msg = shift; @@ -365,7 +381,7 @@ zmtelemetry.pl - Send usage information to the ZoneMinder development team =head1 SYNOPSIS - zmtelemetry.pl [--force] [--help] [--interval=seconds] [--version] + zmtelemetry.pl [--force] [--help] [--show] [--interval=seconds] [--version] =head1 DESCRIPTION @@ -382,6 +398,7 @@ console under Options. --force Force the script to upload it's data instead of waiting for the defined interval since last upload. --help Display usage information + --show Displays telemetry data that is sent to zoneminder --interval Override the default configured interval since last upload. The value should be given in seconds, but can be an expression such as 24*60*60. From 45299955a1b07b0ad5c3bf7fe84db0ac4a8fb761 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 Mar 2020 12:06:07 -0400 Subject: [PATCH 06/10] Fix SLOW FWD not working --- src/zm_eventstream.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/zm_eventstream.cpp b/src/zm_eventstream.cpp index 034ff778a..ee495a2e0 100644 --- a/src/zm_eventstream.cpp +++ b/src/zm_eventstream.cpp @@ -76,7 +76,7 @@ bool EventStream::loadInitialEventData(int monitor_id, time_t event_time) { curr_frame_id = 1; // curr_frame_id is 1-based if ( event_time >= event_data->start_time ) { Debug(2, "event time is after event start"); - for (unsigned int i = 0; i < event_data->frame_count; i++ ) { + for ( unsigned int i = 0; i < event_data->frame_count; i++ ) { //Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time ); if ( event_data->frames[i].timestamp >= event_time ) { curr_frame_id = i+1; @@ -377,6 +377,8 @@ void EventStream::processCommand(const CmdMsg *msg) { paused = true; replay_rate = ZM_RATE_BASE; step = 1; + if ( (unsigned int)curr_frame_id < event_data->frame_count ) + curr_frame_id += 1; break; case CMD_SLOWREV : Debug(1, "Got SLOW REV command"); @@ -845,20 +847,15 @@ void EventStream::runStream() { // commands may set send_frame to true while ( checkCommandQueue() && !zm_terminate ) { // The idea is to loop here processing all commands before proceeding. - Debug(1, "Have command queue"); } - Debug(2, "Done command queue"); // Update modified time of the socket .lock file so that we can tell which ones are stale. if ( now.tv_sec - last_comm_update.tv_sec > 3600 ) { touch(sock_path_lock); last_comm_update = now; } - } else { - Debug(2, "Not checking command queue"); } - // Get current frame data FrameData *frame_data = &event_data->frames[curr_frame_id-1]; @@ -1014,7 +1011,8 @@ void EventStream::runStream() { curr_frame_id += step; // Detects when we hit end of event and will load the next event or previous event - checkEventLoaded(); + if ( !paused ) + checkEventLoaded(); } // end while ! zm_terminate #if HAVE_LIBAVCODEC if ( type == STREAM_MPEG ) From af36cc3e52c100244051b2c4de0503b68887120a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 Mar 2020 13:57:00 -0400 Subject: [PATCH 07/10] Fix starting and stopping zmcontrol processes across servers. --- web/includes/Monitor.php | 12 ++++++++---- web/includes/actions/monitor.php | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index e2eee7ba9..8c45c0d27 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -497,6 +497,10 @@ class Monitor extends ZM_Object { if ( !count($options) ) { if ( $command == 'quit' ) { $options['command'] = 'quit'; + } else if ( $command == 'start' ) { + $options['command'] = 'start'; + } else if ( $command == 'stop' ) { + $options['command'] = 'stop'; } else { Warning("No commands to send to zmcontrol from $command"); return false; @@ -531,7 +535,7 @@ class Monitor extends ZM_Object { } else if ( $this->ServerId() ) { $Server = $this->Server(); - $url = ZM_BASE_PROTOCOL . '://'.$Server->Hostname().'/zm/api/monitors/daemonControl/'.$this->{'Id'}.'/'.$mode.'/zmcontrol.json'; + $url = ZM_BASE_PROTOCOL . '://'.$Server->Hostname().'/zm/api/monitors/daemonControl/'.$this->{'Id'}.'/'.$command.'/zmcontrol.pl.json'; if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); @@ -547,12 +551,12 @@ class Monitor extends ZM_Object { $context = stream_context_create(); try { $result = file_get_contents($url, false, $context); - if ($result === FALSE) { /* Handle error */ - Error("Error restarting zma using $url"); + if ( $result === FALSE ) { /* Handle error */ + Error("Error sending command using $url"); return false; } } catch ( Exception $e ) { - Error("Except $e thrown trying to restart zma"); + Error("Exception $e thrown trying to send command to $url"); return false; } } else { diff --git a/web/includes/actions/monitor.php b/web/includes/actions/monitor.php index 94e527e29..78b64e13c 100644 --- a/web/includes/actions/monitor.php +++ b/web/includes/actions/monitor.php @@ -92,6 +92,9 @@ if ( $action == 'monitor' ) { if ( $monitor->Type() != 'WebSite' ) { $monitor->zmaControl('stop'); $monitor->zmcControl('stop'); + if ( $monitor->Controllable() ) { + $monitor->sendControlCommand('stop'); + } } # These are used in updating zones @@ -264,8 +267,7 @@ if ( $action == 'monitor' ) { $monitor->zmaControl('start'); if ( $monitor->Controllable() ) { - require_once('includes/control_functions.php'); - $monitor->sendControlCommand('quit'); + $monitor->sendControlCommand('start'); } } // really should thump zmwatch and maybe zmtrigger too. From b354641df3dd4538724b87ddf18809ba183fb711 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 Mar 2020 13:57:19 -0400 Subject: [PATCH 08/10] fix syntax errors in triggers in monitor view --- web/skins/classic/views/monitor.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 76614decb..a78c6f615 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -729,12 +729,12 @@ switch ( $tab ) { continue; if ( $optCount && ($optCount%$breakCount == 0) ) echo '
'; - echo 'Triggers()) && in_array($optTrigger, $monitor->Triggers()) ) ? ' checked="checked"':''). '/> '. $optTrigger; - $optCount ++; + echo 'Triggers()) && in_array($optTrigger, $monitor->Triggers()) ) ? ' checked="checked"' : ''). '/> '. $optTrigger; + $optCount ++; } # end foreach trigger option if ( !$optCount ) { - echo ''. translate('NoneAvailable') .''; + echo ''.translate('NoneAvailable').''; } ?> From 3e55795cad2e5dc1de6a9f8e108ef6b761c75d8b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 Mar 2020 13:57:43 -0400 Subject: [PATCH 09/10] Handle different command line syntax for zmcontrol.pl --- web/api/app/Controller/MonitorsController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/api/app/Controller/MonitorsController.php b/web/api/app/Controller/MonitorsController.php index 92114a558..3818f69d3 100644 --- a/web/api/app/Controller/MonitorsController.php +++ b/web/api/app/Controller/MonitorsController.php @@ -379,6 +379,8 @@ class MonitorsController extends AppController { $args = ''; if ( $daemon == 'zmc' and $monitor['Type'] == 'Local' ) { $args = '-d ' . $monitor['Device']; + } else if ( $daemon == 'zmcontrol.pl' ) { + $args = '--id '.$id; } else { $args = '-m ' . $id; } From c880793fdc411558236e8d8c55ec29c455e6c416 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 Mar 2020 15:34:36 -0400 Subject: [PATCH 10/10] bump version to 1.34.7 --- db/zm_update-1.34.7.sql | 5 +++++ distros/redhat/zoneminder.spec | 2 +- version | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/zm_update-1.34.7.sql diff --git a/db/zm_update-1.34.7.sql b/db/zm_update-1.34.7.sql new file mode 100644 index 000000000..ba86b1202 --- /dev/null +++ b/db/zm_update-1.34.7.sql @@ -0,0 +1,5 @@ +-- +-- This updates a 1.34.6 database to 1.34.7 +-- +-- No changes required +-- diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index 60701c429..39d6353f5 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -28,7 +28,7 @@ %global _hardened_build 1 Name: zoneminder -Version: 1.34.6 +Version: 1.34.7 Release: 1%{?dist} Summary: A camera monitoring and analysis tool Group: System Environment/Daemons diff --git a/version b/version index 6fef6c580..ca380088a 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.34.6 +1.34.7