From 7ad92e51c3faec69f89a5864e5468b0c035e7388 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 May 2021 15:56:15 -0400 Subject: [PATCH 1/4] Fix initializers to compile on centos7 --- src/zm_monitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index dd5c82503..4606737d4 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -380,7 +380,7 @@ Monitor::Monitor() event_close_mode(CLOSE_IDLE), #if ZM_MEM_MAPPED map_fd(-1), - mem_file(""), + mem_file({}), #else // ZM_MEM_MAPPED shm_id(-1), #endif // ZM_MEM_MAPPED @@ -388,7 +388,7 @@ Monitor::Monitor() mem_ptr(nullptr), shared_data(nullptr), trigger_data(nullptr), - video_store_data(nullptr), + video_store_data({}), shared_timestamps(nullptr), shared_images(nullptr), video_stream_id(-1), From 16d98197965fd162680817fc7c7f24a459033f37 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 May 2021 15:56:31 -0400 Subject: [PATCH 2/4] include memory to fix build on centos 7 --- src/zm_packetqueue.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zm_packetqueue.h b/src/zm_packetqueue.h index cc163d2f1..a2f57dcfe 100644 --- a/src/zm_packetqueue.h +++ b/src/zm_packetqueue.h @@ -22,6 +22,7 @@ #include #include #include +#include class ZMPacket; class ZMLockedPacket; From 2f78916ab8fcf7d8eabfd186b1ded28af1c53b48 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 May 2021 16:28:22 -0400 Subject: [PATCH 3/4] change mem_file to std::string to resolve initialization problems --- src/zm_monitor.cpp | 42 +++++++++++++++++++++--------------------- src/zm_monitor.h | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 4606737d4..839a03c5d 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -124,7 +124,7 @@ Monitor::MonitorLink::MonitorLink(unsigned int p_id, const char *p_name) : #if ZM_MEM_MAPPED map_fd = -1; - snprintf(mem_file, sizeof(mem_file), "%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id); + mem_file = stringtf("%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id); #else // ZM_MEM_MAPPED shm_id = 0; #endif // ZM_MEM_MAPPED @@ -150,9 +150,9 @@ bool Monitor::MonitorLink::connect() { Debug(1, "link.mem.size=%jd", mem_size); #if ZM_MEM_MAPPED - map_fd = open(mem_file, O_RDWR, (mode_t)0600); + map_fd = open(mem_file.c_str(), O_RDWR, (mode_t)0600); if ( map_fd < 0 ) { - Debug(3, "Can't open linked memory map file %s: %s", mem_file, strerror(errno)); + Debug(3, "Can't open linked memory map file %s: %s", mem_file.c_str(), strerror(errno)); disconnect(); return false; } @@ -165,13 +165,13 @@ bool Monitor::MonitorLink::connect() { struct stat map_stat; if ( fstat(map_fd, &map_stat) < 0 ) { - Error("Can't stat linked memory map file %s: %s", mem_file, strerror(errno)); + Error("Can't stat linked memory map file %s: %s", mem_file.c_str(), strerror(errno)); disconnect(); return false; } if ( map_stat.st_size == 0 ) { - Error("Linked memory map file %s is empty: %s", mem_file, strerror(errno)); + Error("Linked memory map file %s is empty: %s", mem_file.c_str(), strerror(errno)); disconnect(); return false; } else if ( map_stat.st_size < mem_size ) { @@ -182,7 +182,7 @@ bool Monitor::MonitorLink::connect() { mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0); if ( mem_ptr == MAP_FAILED ) { - Error("Can't map file %s (%jd bytes) to memory: %s", mem_file, mem_size, strerror(errno)); + Error("Can't map file %s (%jd bytes) to memory: %s", mem_file.c_str(), mem_size, strerror(errno)); disconnect(); return false; } @@ -380,7 +380,7 @@ Monitor::Monitor() event_close_mode(CLOSE_IDLE), #if ZM_MEM_MAPPED map_fd(-1), - mem_file({}), + mem_file(""), #else // ZM_MEM_MAPPED shm_id(-1), #endif // ZM_MEM_MAPPED @@ -388,7 +388,7 @@ Monitor::Monitor() mem_ptr(nullptr), shared_data(nullptr), trigger_data(nullptr), - video_store_data({}), + video_store_data(nullptr), shared_timestamps(nullptr), shared_images(nullptr), video_stream_id(-1), @@ -905,23 +905,23 @@ bool Monitor::connect() { } Debug(3, "Connecting to monitor. Purpose is %d", purpose); #if ZM_MEM_MAPPED - snprintf(mem_file, sizeof(mem_file), "%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id); + mem_file = stringtf("%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id); if (purpose != CAPTURE) { - map_fd = open(mem_file, O_RDWR); + map_fd = open(mem_file.c_str(), O_RDWR); } else { - map_fd = open(mem_file, O_RDWR|O_CREAT, (mode_t)0660); + map_fd = open(mem_file.c_str(), O_RDWR|O_CREAT, (mode_t)0660); } if (map_fd < 0) { - Error("Can't open memory map file %s: %s", mem_file, strerror(errno)); + Error("Can't open memory map file %s: %s", mem_file.c_str(), strerror(errno)); return false; } else { - Debug(3, "Success opening mmap file at (%s)", mem_file); + Debug(3, "Success opening mmap file at (%s)", mem_file.c_str()); } struct stat map_stat; if (fstat(map_fd, &map_stat) < 0) { - Error("Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file, strerror(errno)); + Error("Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file.c_str(), strerror(errno)); close(map_fd); map_fd = -1; return false; @@ -931,7 +931,7 @@ bool Monitor::connect() { if (purpose == CAPTURE) { // Allocate the size if (ftruncate(map_fd, mem_size) < 0) { - Error("Can't extend memory map file %s to %jd bytes: %s", mem_file, mem_size, strerror(errno)); + Error("Can't extend memory map file %s to %jd bytes: %s", mem_file.c_str(), mem_size, strerror(errno)); close(map_fd); map_fd = -1; return false; @@ -954,18 +954,18 @@ bool Monitor::connect() { mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0); if (mem_ptr == MAP_FAILED) { if (errno == EAGAIN) { - Debug(1, "Unable to map file %s (%jd bytes) to locked memory, trying unlocked", mem_file, mem_size); + Debug(1, "Unable to map file %s (%jd bytes) to locked memory, trying unlocked", mem_file.c_str(), mem_size); #endif mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0); - Debug(1, "Mapped file %s (%jd bytes) to unlocked memory", mem_file, mem_size); + Debug(1, "Mapped file %s (%jd bytes) to unlocked memory", mem_file.c_str(), mem_size); #ifdef MAP_LOCKED } else { - Error("Unable to map file %s (%jd bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno)); + Error("Unable to map file %s (%jd bytes) to locked memory (%s)", mem_file.c_str(), mem_size, strerror(errno)); } } #endif if ((mem_ptr == MAP_FAILED) or (mem_ptr == nullptr)) { - Error("Can't map file %s (%jd bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno); + Error("Can't map file %s (%jd bytes) to memory: %s(%d)", mem_file.c_str(), mem_size, strerror(errno), errno); close(map_fd); map_fd = -1; mem_ptr = nullptr; @@ -1071,8 +1071,8 @@ bool Monitor::disconnect() { mem_ptr = nullptr; shared_data = nullptr; - if (purpose == CAPTURE and (unlink(mem_file) < 0) ) { - Warning("Can't unlink '%s': %s", mem_file, strerror(errno)); + if (purpose == CAPTURE and (unlink(mem_file.c_str()) < 0) ) { + Warning("Can't unlink '%s': %s", mem_file.c_str(), strerror(errno)); } #else // ZM_MEM_MAPPED struct shmid_ds shm_data; diff --git a/src/zm_monitor.h b/src/zm_monitor.h index aaf6e528c..69fff8c59 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -211,7 +211,7 @@ protected: #if ZM_MEM_MAPPED int map_fd; - char mem_file[PATH_MAX]; + std::string mem_file; #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED @@ -364,7 +364,7 @@ protected: #if ZM_MEM_MAPPED int map_fd; - char mem_file[PATH_MAX]; + std::string mem_file; #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED From f947c041df5ccef8d2aa4fff92990bc619e053ab Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 19 May 2021 20:29:31 -0400 Subject: [PATCH 4/4] Fix status of delete button when archived. Change title to say that you can't delete due to archived --- web/skins/classic/views/js/event.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index b3819cf30..53e42dcc8 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -936,7 +936,8 @@ function initPage() { editBtn.prop('disabled', !canEdit.Events); exportBtn.prop('disabled', !canView.Events); downloadBtn.prop('disabled', !canView.Events); - deleteBtn.prop('disabled', !canEdit.Events); + deleteBtn.prop('disabled', !(!eventData.Archived && canEdit.Events)); + deleteBtn.prop('title', eventData.Archived ? "You cannot delete an archived event." : ""); // Don't enable the back button if there is no previous zm page to go back to backBtn.prop('disabled', !document.referrer.length); @@ -979,14 +980,14 @@ function initPage() { // Manage the UNARCHIVE button bindButton('#unarchiveBtn', 'click', null, function onUnarchiveClick(evt) { - if ( ! canEdit.Events ) { + if (!canEdit.Events) { enoperm(); return; } evt.preventDefault(); $j.getJSON(thisUrl + '?request=events&task=unarchive&eids[]='+eventData.Id) .done( function(data) { - //FIXME: update the status of the unarchive button reather than reload the whole page + //FIXME: update the status of the unarchive button rather than reload the whole page window.location.reload(true); }) .fail(logAjaxFail);