Commit Graph

84 Commits

Author SHA1 Message Date
IgorA100
fa744743e5 Canonicalize the storage path (monitor.php) 2026-06-13 17:23:02 +03:00
IgorA100
c2820d1317 - Don't create symlinks if the monitor name is equal to its ID. This was previously broken in 9561ed8947
- Moved $oldLinkPathFound analysis outside the storages loop
- More correct check for an empty $_REQUEST['monitorName'] value
2026-05-27 12:12:38 +03:00
IgorA100
d4bbf23c98 Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-27 09:57:42 +03:00
IgorA100
37ed304994 To find old symlinks, compare $oldLinkPath with $linkPath, not $absolutePath. 2026-05-26 16:35:56 +03:00
IgorA100
3de3dc7d21 - Corrected English and Russian translations
- Check opendir($storagePath) before reading files.
- Use strict validation when creating symlinks
2026-05-25 00:35:40 +03:00
IgorA100
a95efdbd42 When changing the monitor name, delete all symlinks in all storages (monitor.php)
Now we scan directories in all storages for any symbolic links to the events folder of the renamed monitor and delete all found symbolic links in all storages. This is necessary to remove any possible symbolic link garbage from the previous operating algorithm or after other failures.

After deleting all old symbolic links, we create a new one with the new monitor name.
2026-05-14 16:49:18 +03:00
IgorA100
9561ed8947 If the monitor name has changed, you must change the symbolic links in all repositories that contain folders for recording events for this monitor. (monitor.php) 2026-05-14 14:13:22 +03:00
IgorA100
4453d15f82 Update monitor.php 2026-05-11 22:09:20 +03:00
IgorA100
dcbb7b65da - When changing the monitor name, also change the symlink, instead of simply deleting the old one.
- Condition adjustment. Changed from:
if (($saferName != $newMonitor['Name']) and !@symlink($mid, $link_path)) {
to:
if (($saferName != $newMonitor['Id']) and !@symlink($mid, $link_path)) {
This condition was changed in 203418d45e
But there was probably an error in the condition, since comparing one variable to itself is pointless, unless we're looking for prohibited characters in the name.
2026-05-03 00:58:00 +03:00
Isaac Connor
bb9e74a2f9 fix: only validate Device path for Local monitors
Follow-up to 419846c87 (GHSA-g66m-77fq-79v9). The Device path check was
applied to all monitor Types in three places, but the Device column is
only passed to a shell for Type='Local'. Non-Local monitors (Ffmpeg,
Remote, Libvlc, cURL, VNC) may legitimately hold legacy values such as
an RTSP URL in that column and should not be rejected or warned about.

- scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm: control() dropped the
  spurious Warning for non-Local monitors that was flooding zmwatch
  logs. The Error/early-return path is preserved for Local.
- web/includes/actions/monitor.php: save action only runs
  validDevicePath() when Type=='Local'.
- web/api/app/Model/Monitor.php: replaced the unconditional regex rule
  with a validDevicePath() method that checks Type before enforcing
  the /dev/ pattern.

Also add client-side validation matching the server rule, so Local
monitors get immediate feedback instead of a round-trip error:

- web/skins/classic/views/monitor.php: HTML5 pattern attribute on the
  Device input. Escaped for the v-flag regex engine used by pattern=.
- web/skins/classic/views/js/monitor.js.php: validateForm() now also
  rejects Device values that don't match the /dev/ pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 08:44:07 -04:00
Isaac Connor
419846c875 fix: sanitize monitor Device path to prevent command injection (GHSA-g66m-77fq-79v9)
The Device field from the Monitors table was interpolated directly into
shell commands (qx(), backticks, exec()) without sanitization, allowing
authenticated users with monitor-edit permissions to execute arbitrary
commands as www-data via the Device Path field.

Defense in depth:
- Input validation: reject Device values not matching /^\/dev\/[\w\/.\-]+$/
  at save time in both web UI and REST API
- Output sanitization: use escapeshellarg() in PHP and quote validated
  values in Perl at every shell execution point

Affected locations:
- scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm (control, zmcControl)
- scripts/zmpkg.pl.in (system startup)
- web/includes/Monitor.php (zmcControl)
- web/includes/functions.php (zmcStatus, zmcCheck, validDevicePath)
- web/includes/actions/monitor.php (save action)
- web/api/app/Model/Monitor.php (daemonControl, validation rules)
- web/api/app/Controller/MonitorsController.php (daemonStatus)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 13:19:03 -04:00
Isaac Connor
e6ace6fcf4 feat: add AUDIT logging level for tracking administrative changes
Add a new AUDIT logging level (-5) between PANIC (-4) and NOLOG (shifted
to -6) across C++, PHP, and Perl loggers. AUDIT entries use code 'AUD'
and syslog priority LOG_NOTICE. They record who changed what, from where,
for monitors, filters, users, config, roles, groups, zones, states,
servers, storage, events, snapshots, control caps, and login/logout.

AUDIT entries have their own retention period (ZM_LOG_AUDIT_DATABASE_LIMIT,
default 1 year) separate from regular log pruning. The log pruning in
zmstats.pl and zmaudit.pl now excludes AUDIT rows from regular pruning
and prunes them independently.

Critical safety: the C++ termination logic is changed from
'if (level <= FATAL)' to 'if (level == FATAL || level == PANIC)' to
prevent AUDIT-level log calls from killing the process.

Includes db migration zm_update-1.39.1.sql to shift any stored NOLOG
config values from -5 to -6.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:19:20 -05:00
Isaac Connor
c0016fa00b feat: store zone coordinates as percentages for resolution independence
Convert zone coordinates from absolute pixel values to percentages
(0.00-100.00) so zones automatically adapt when monitor resolution
changes. This eliminates the need to manually reconfigure zones after
resolution adjustments.

Changes:
- Add DB migration (zm_update-1.37.81.sql) to convert existing pixel
  coords to percentages, recalculate area, and update Units default
- Add Zone::ParsePercentagePolygon() in C++ to parse percentage coords
  and convert to pixels at runtime using monitor dimensions
- Backwards compat: C++ Zone::Load() checks Units column and uses old
  pixel parser for legacy 'Pixels' zones
- Update PHP coordsToPoints/mapCoords/getPolyArea for float coords,
  replace scanline area algorithm with shoelace formula
- Update JS zone editor to work in percentage coordinate space with
  SVG viewBox "0 0 100 100" and non-scaling-stroke for consistent
  line thickness
- Position zone SVG overlay inside imageFeed container via JS to align
  with image only (not status bar)
- Support array of zone IDs in Monitor::getStreamHTML zones option
- Update monitor resize handler: percentage coords don't need rescaling,
  only threshold pixel counts are adjusted
- Add 8 Catch2 unit tests for ParsePercentagePolygon

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:19:20 -05:00
Isaac Connor
d89f2e59db refactor: rename Janus_Use_RTSP_Restream to Restream
Rename Janus-specific restream fields to be more generic since they are
now used by Go2RTC and RTSP2Web as well:
- Janus_Use_RTSP_Restream → Restream
- Janus_RTSP_User → RTSP_User

Update visibility logic so the Restream checkbox appears when RTSPServer
is enabled AND any streaming service (Janus, Go2RTC, or RTSP2Web) is
selected, rather than only when Janus is enabled.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:47:37 -05:00
Steve Gilvarry
c4385768ad Fix default zone creation to account for monitor rotation
When creating a new monitor with Orientation set to ROTATE_90 or
ROTATE_270, the default "All" zone dimensions are now correctly swapped
to match the rotated image dimensions. This prevents zm_zone.cpp from
reporting that zones extend outside of image dimensions and having to
fix them at runtime.

Fixes issue where monitors created with Rotate Right or Rotate Left
would generate warnings like:
"Zone 1/All for monitor X extends outside of image dimensions,
(0,0), (3839,2159) != (2160,3840), fixing"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-08 22:58:59 +11:00
Isaac Connor
203418d45e Only make symlink if name is different than id 2025-09-06 11:37:07 -04:00
Isaac Connor
e42d31fe3b Fix not being able to turn off Go2RTCEnabled 2025-06-26 16:28:16 -04:00
Isaac Connor
edb0836fe1 Fix not being able to undelete a monitor 2024-12-09 12:27:42 -05:00
Isaac Connor
caeb65233e Fix not being able to unset use WallClockTimestamps 2024-07-08 08:36:55 -04:00
Isaac Connor
c2b6f6ba17 Detect when a new monitor uses a specified Id and the record exists in a deleted monitor. Automatically Undelete it. 2024-03-28 12:48:48 -04:00
Isaac Connor
b4bbff6353 Use per-monitor permissions 2024-03-05 14:00:40 -05:00
Server
0ff48f631e Implements an option to disable soap_wsa code that doesn't work
with some chinese cameras, more common to Latam zone
2024-02-12 19:22:01 -06:00
Isaac Connor
2d49e93405 Introduce a Create permission for Monitors, so that a given user may Edit existing monitors, but not create new ones. 2024-01-02 12:18:09 -05:00
Isaac Connor
aafd4067e0 Dont' restart a monitor if it has been deleted 2023-12-04 14:50:37 -05:00
Isaac Connor
889c809e0b Add RTSP2WebEnabled to defaults 2023-08-09 18:55:36 -04:00
Isaac Connor
e13a42aa46 Fix not saving Manufacturer and Model. Have to unset the text input if the ddm is populated 2023-07-12 14:30:49 -04:00
Isaac Connor
969baa3891 Convert user from an array to a User object 2023-04-23 12:57:29 -04:00
Isaac Connor
ce0a83f904 Reduce minimum to .05% as that is what seems to be necessary these days 2023-04-05 17:47:03 -04:00
Isaac Connor
21f6bdae35 Change minimum percent to 50% instead of 3% 2023-04-05 14:46:13 -04:00
Isaac Connor
d170112ef7 Change minimum percent to 50% instead of 3% 2023-04-05 14:45:30 -04:00
Isaac Connor
b1df318491 Use ORM Zone Object for Zone insertion on new monitor 2023-04-05 14:43:50 -04:00
baudneo
aab62c5a7e Add Janus RTSP session timeout to PHP (front end) ⚗️
Signed-off-by: baudneo <86508179+baudneo@users.noreply.github.com>
2023-01-09 17:57:26 -07:00
Isaac Connor
f06e11a097 Add SectionLengthWarn, use it to disable warnings in logs about section length being exceeded. 2023-01-07 12:33:42 -05:00
Isaac Connor
25100cd592 Fix missed references to oldW and oldH 2022-10-31 09:27:53 -04:00
Isaac Connor
2fb631fa6e Clean up debug. Clone the entire monitor object into oldMonitor instead of cherry-picking properties. Fixes use of new name when deleting old symlink. Always check for existence of monitor dir and symlink after done saving. 2022-10-31 09:27:53 -04:00
Isaac Connor
33455cbad2 Remove left over references to REQUEST['newMonitor']. Add error reporting to creating monitor directory and symlinking when adding a new monitor 2022-10-31 09:27:53 -04:00
Isaac Connor
6b3768fdf6 When saving monitor, only turn off error reporting for symlink. Don't delete old symlink unless the name has changed. 2022-10-31 09:27:53 -04:00
Isaac Connor
1f20b18100 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2022-09-06 11:22:28 -04:00
Isaac Connor
d76c425057 Fix saving monitor due to MQTT being empty 2022-09-06 11:22:04 -04:00
Isaac Connor
683acbbc1d Clear Manufacturer and Model so that they don't list as changes 2022-08-31 10:05:52 -04:00
Jonathan Bennett
d41792ae00 Adds Janus options Profile-ID Override and Use RTSP Restream to work around camera issues 2022-08-09 00:54:41 -05:00
Isaac Connor
cf3c194e21 Handle when there are no servers and hence no defined ServerId in newMonitor 2022-08-03 11:55:44 -04:00
Isaac Connor
10e39b3b13 :wqMerge branch 'master' into replace_function_concept 2022-02-02 17:08:01 -05:00
Jonathan Bennett
fb832e7d1b Adds janus_enable_audio, a switch to try to enable audio in live stream viewing. 2022-01-19 00:14:52 -06:00
Isaac Connor
d00aaa11e9 default JanusEnabled to 0 so that we can turn it off 2022-01-18 23:02:26 -05:00
Isaac Connor
3241fa59c5 Don't redirect if there was an error so that we display it 2022-01-18 23:02:26 -05:00
Isaac Connor
b1d881b118 Report more saving errors to ui 2021-11-17 18:57:36 -05:00
Isaac Connor
1fd99424bb Merge branch 'master' into add_manufacturer_model_to_monitors 2021-11-05 10:13:41 -04:00
Isaac Connor
1f04723f3a dbError is supposed to take the sql that caused the error. So pass something to satisfy php 2021-10-05 19:49:42 -04:00
Isaac Connor
2f12615f08 assign REQUEST['newMonitor'] to a variable to simplify code. Fixup ModelId and ManufacturerId saving. 2021-09-25 10:33:16 -04:00