From a44bbf8e345d3eefea92e2b05bb1034ae1bd46b7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 8 Sep 2021 18:35:01 -0400 Subject: [PATCH 1/6] use get_packet_and_increment_it instead of the two step to improve locking --- src/zm_monitor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 32b9161ac..44e032979 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1723,7 +1723,7 @@ bool Monitor::Analyse() { // if have event, send frames until we find a video packet, at which point do analysis. Adaptive skip should only affect which frames we do analysis on. // get_analysis_packet will lock the packet and may wait if analysis_it is at the end - ZMLockedPacket *packet_lock = packetqueue.get_packet(analysis_it); + ZMLockedPacket *packet_lock = packetqueue.get_packet_and_increment_it(analysis_it); if (!packet_lock) return false; std::shared_ptr snap = packet_lock->packet_; @@ -1731,13 +1731,11 @@ bool Monitor::Analyse() { if (snap->score != -1) { Error("skipping because score was %d", snap->score); packetqueue.unlock(packet_lock); - packetqueue.increment_it(analysis_it); return false; } // Store the it that points to our snap we will need it later - packetqueue_iterator snap_it = *analysis_it; - packetqueue.increment_it(analysis_it); + packetqueue_iterator snap_it = std::prev(*analysis_it); // signal is set by capture bool signal = shared_data->signal; From e18f8019b0f76f2c9e0ab53036fbb0c841ce5e5a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 8 Sep 2021 19:07:51 -0400 Subject: [PATCH 2/6] canView takes a user object, not a string --- web/skins/classic/includes/export_functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/includes/export_functions.php b/web/skins/classic/includes/export_functions.php index 4d32b85fe..44eeb4ce5 100644 --- a/web/skins/classic/includes/export_functions.php +++ b/web/skins/classic/includes/export_functions.php @@ -776,7 +776,7 @@ function exportFileList( ZM\Error("Empty event passed to exportFileList"); return; } - if (!$event->canView('Events')) { + if (!$event->canView()) { ZM\Error('Can\'t view event '.$event->Id()); return; } From 009b3ceffc6c6c8d87950afc10e9084526fb325d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 9 Sep 2021 13:28:25 -0400 Subject: [PATCH 3/6] Fix version of Crud --- web/api/app/Plugin/Crud | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/api/app/Plugin/Crud b/web/api/app/Plugin/Crud index 0bd63fb46..14292374c 160000 --- a/web/api/app/Plugin/Crud +++ b/web/api/app/Plugin/Crud @@ -1 +1 @@ -Subproject commit 0bd63fb464957080ead342db58ca9e01532cf1ef +Subproject commit 14292374ccf1328f2d5db20897bd06f99ba4d938 From a9379e5813ef5598dfbdeb5462fda063fe8872d7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 10 Sep 2021 10:58:06 -0400 Subject: [PATCH 4/6] Need to increase frame_count or else frame_count%frame_mod will never == 0 --- src/zm_monitorstream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 4e5e96f4a..067946eb7 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -751,6 +751,8 @@ void MonitorStream::runStream() { } // end if actual_delta_time > 5 } // end if change in zoom } // end if paused or not + } else { + frame_count++; } // end if should send frame if (buffered_playback && !paused) { From c2472894be9b5cd567c28d6fd8459a785d4745db Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 10 Sep 2021 13:47:32 -0400 Subject: [PATCH 5/6] Fix html emails when using ZM_NEW_MAIL_MODULES. Improve debugging and reduce Info logging --- scripts/zmfilter.pl.in | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 1f2906b4b..64a20b4d5 100644 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -843,7 +843,7 @@ sub sendEmail { return 0; } - Info('Creating notification email'); + Debug('Creating notification email'); my $subject = substituteTags($$filter{EmailSubject}, $filter, $Event); return 0 if !$subject; @@ -851,7 +851,7 @@ sub sendEmail { my $body = substituteTags($$filter{EmailBody}, $filter, $Event, \@attachments); return 0 if !$body; - Info("Sending notification email '$subject'"); + Debug("Sending notification email '$subject'"); eval { if ( $Config{ZM_NEW_MAIL_MODULES} ) { @@ -864,7 +864,7 @@ sub sendEmail { ); ### Add the text message part $mail->attach ( - Type => 'TEXT', + Type => (($body=~/ $body ); ### Add the attachments @@ -886,9 +886,7 @@ sub sendEmail { if ( $Config{ZM_SSMTP_MAIL} ) { my $ssmtp_location = $Config{ZM_SSMTP_PATH}; if ( !$ssmtp_location ) { - if ( logDebugging() ) { - Debug("which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message"); - } + Debug("which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message"); $ssmtp_location = qx('which ssmtp'); } if ( !$ssmtp_location ) { @@ -916,7 +914,7 @@ sub sendEmail { foreach my $attachment ( @attachments ) { my $size = -s $attachment->{path}; $total_size += $size; - Info("Attaching '$attachment->{path}' which is $size bytes"); + Debug("Attaching '$attachment->{path}' which is $size bytes"); $mail->attach( Path => $attachment->{path}, @@ -934,7 +932,7 @@ sub sendEmail { Error("Unable to send email: $@"); return 0; } else { - Info('Notification email sent'); + Info("Notification email sent to $$filter{EmailTo}"); } my $sql = 'UPDATE `Events` SET `Emailed` = 1 WHERE `Id` = ?'; my $sth = $dbh->prepare_cached($sql) From 385d1602e010f9a09130138b4474d02cff42c53f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 10 Sep 2021 13:54:24 -0400 Subject: [PATCH 6/6] Add an example fail2ban rule as provided by Pedulla --- misc/fail2ban.rules | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 misc/fail2ban.rules diff --git a/misc/fail2ban.rules b/misc/fail2ban.rules new file mode 100644 index 000000000..c1d5115fd --- /dev/null +++ b/misc/fail2ban.rules @@ -0,0 +1,2 @@ +failregex = ^\s*web_php\[\d+\]\.ERR \[\].*includes/auth.php +datepattern = ^%%m/%%d/%%y %%H:%%M:%%S(?:\.%%f)