Commit Graph

422 Commits

Author SHA1 Message Date
Isaac Connor
d0611fec26 Merge branch 'master' into segment_recording 2026-03-17 14:09:58 -04:00
Isaac Connor
5561829450 fix: include username in auth relay and fix stale auth in stream restart
- Add user= parameter to get_auth_relay() so zms can use the indexed
  Username column instead of iterating all users to validate the hash
- Apply the same fix to Event.php getStreamSrc() and getThumbnailSrc()
- Tighten Monitor.php from isset() to !empty() for consistency
- In MonitorStream.js start(), check if the auth hash in the img src
  matches the current auth_hash before resuming via CMD_PLAY. If stale,
  fall through to rebuild the URL with fresh auth_relay. This prevents
  long-running montage pages from spawning zms with expired credentials.
- Downgrade zms auth failure from Error to Warning

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 10:01:47 -04:00
Isaac Connor
e04e2a5550 Merge remote-tracking branch 'upstream' into ai_server 2026-03-09 16:12:06 -04:00
Isaac Connor
3dfe185260 fix: resolve role-based group permissions not granting stream access
The C++ User class (used by zms for streaming) had no awareness of
roles. It only checked user-direct permissions from Monitors_Permissions
and Groups_Permissions tables, completely ignoring Role_Monitors_Permissions,
Role_Groups_Permissions, and User_Roles base permissions. This caused
users who received camera permissions via Roles to be denied live stream
access, even though the PHP web interface (which has its own role-aware
checks in visibleMonitor()) showed the monitors correctly.

Changes:
- Add role_id to C++ User class, loaded via COALESCE(RoleId, 0) in all
  SQL queries (find, zmLoadTokenUser, zmLoadAuthUser)
- Add loadRoleBasePermissions() to merge role's Stream/Events/Monitors/
  etc. as fallback when user's own permission is PERM_NONE
- Add findByRole() to Group_Permission and Monitor_Permission classes
  to query Role_Groups_Permissions and Role_Monitors_Permissions tables
- Extend User::canAccess() to check role monitor and group permissions
  after user-direct permissions, matching the PHP visibleMonitor() logic
- Fix Monitor::canView() in PHP to also check role permissions when
  called for a user other than the global $user
- Fix off-by-one in zmLoadTokenUser where dbrow[10] read TokenMinExpiry
  out of bounds (was at index 9); adding RoleId shifts it to index 10

Fixes #4692

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 15:07:14 -04:00
Isaac Connor
c8f352a095 Merge remote-tracking branch 'upstream/master' into ai_server 2026-03-09 10:11:12 -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
6704b7eb5e Merge remote-tracking branch 'upstream/master' into ai_server 2026-03-06 16:08:43 -05:00
Isaac Connor
44acdd9b95 fix: guard ModelId access with property_exists in Monitor::Model()
Prevents 'Undefined property' PHP warning when the Monitor object was
loaded from a database that doesn't yet have the ModelId column. Matches
the existing property_exists pattern used later in the same method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 16:50:40 -05:00
Isaac Connor
a90a3bccea fix: auto-detect and convert pixel zone coordinates to percentages in web layer
When zone coordinates are stored as pixel values (e.g. from a missed DB
migration), the web layer now detects values > 100 and converts them to
percentages using the monitor's dimensions, mirroring the existing C++
detection logic in zm_zone.cpp. This prevents limitPoints() from clamping
pixel values to 0-100 and zones rendering incorrectly in SVG overlays.

- Add convertPixelPointsToPercent() helper in functions.php
- Call conversion before limitPoints() in zone.php and zones.php
- Update Zone::svg_polygon() to accept monitor dimensions and convert
- Pass ViewWidth/ViewHeight to svg_polygon() from Monitor::getStreamHTML()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 17:49:14 -05:00
Isaac Connor
9d48917cf7 Merge remote-tracking branch 'upstream/master' into ai_server 2026-02-26 08:19:27 -05:00
Isaac Connor
9ebf48da35 Add Create to canEdit 2026-02-26 07:22:31 -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
d02c5f72f8 feat: add alpha blending and configurable opacity for analysis zone overlays
Add transparency support when drawing analysis zones on images:

- Add optional alpha parameter to Image::Overlay() for blending
  (0 = fully transparent, 255 = fully opaque)
- Add AnalysisImageOpacity monitor setting (0-255, default 128)
- Add range slider UI control on Analysis tab with (?) help popup
- Database migration for new Monitors column

The alpha blending uses signed arithmetic to correctly handle cases
where the overlay color is darker than the original pixel.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 12:36:40 -05:00
Isaac Connor
1d97336ca2 Merge remote-tracking branch 'upstream/edge' into ai_server 2026-02-10 17:56:59 -05:00
Isaac Connor
17450d122d 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-10 17:18:00 -05:00
Isaac Connor
bfbe47b7cc Merge pseudo:sandbox/ZoneMinder into ai_server 2026-01-31 19:45:37 -05:00
Isaac Connor
eae89025ee refactor: rename RTSP2WebStream to StreamChannel
Rename applies to Go2RTC, Janus, and RTSP2Web streaming options.
Update enum values from Primary/Secondary to Restream/CameraDirectPrimary/CameraDirectSecondary.

- Add db migration zm_update-1.37.79.sql to rename column and migrate data
- Update C++ enum StreamChannelOption and member stream_channel
- Update PHP getStreamChannelOptions() method
- Update all JavaScript references
- Auto-select CameraDirectPrimary when Restream option becomes disabled

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:37:08 -05:00
Isaac Connor
02685bff7e Pick up missed update for Restream and RTSP_User 2026-01-31 18:54:14 -05:00
Isaac Connor
4596b27c19 Add Restream to go2rtc options 2026-01-30 15:06:26 -05:00
Isaac Connor
9389fddf72 Merge remote-tracking branch 'upstream/master' into ai_server 2026-01-29 18:50:59 -05:00
Isaac Connor
3bd34ad3db Merge remote-tracking branch 'upstream/master' into ai_server 2026-01-29 14:20:35 -05:00
Isaac Connor
010959c9d4 fix: only show monitor edit button if user has edit permission
The edit button overlay on the montage view stream is now conditionally
displayed based on the user's edit permission for that monitor.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:56:03 -05:00
Ben Dailey
c80542343a Remove Preview Rate Control. Disable BuiltIn Video controls. 2026-01-29 11:18:30 -05:00
Isaac Connor
a530109492 Merge remote-tracking branch 'upstream/master' into ai_server 2026-01-02 12:53:51 -05:00
Isaac Connor
e6c5bdb85d Use modern string interpolation style 2025-12-22 19:43:05 -05:00
Isaac Connor
4fa20ef716 Merge branch 'master' into ai_server 2025-12-19 17:14:00 -05:00
Isaac Connor
254fd58c40 Use css style= to set width of video tag, and if height is specified, also set it. Fixes streams not having height. 2025-12-19 12:03:29 -05:00
Isaac Connor
6c2ad8d906 Use the same code for ImageStill and for ImageStream. Use ImageStream when mode == paused. Fixes #4491 2025-12-19 11:10:32 -05:00
Isaac Connor
7f87eb3e9e Merge remote-tracking branch 'upstream/master' into ai_server 2025-10-30 07:52:02 -04:00
Isaac Connor
736610d349 Simplify monitor state html, mostly to include the stream-info into the part that gets hidden with the other state info 2025-10-29 12:15:32 -04:00
Isaac Connor
9932c1f690 Add missing EncoderHWAccel fields 2025-10-27 09:40:06 -04:00
Isaac Connor
b8168403f0 Merge remote-tracking branch 'upstream/master' into ai_server 2025-10-22 09:53:23 -04:00
Isaac Connor
ecd37ae6c7 Revert change to assign 4 streams per port. It caused more trouble than it was worth 2025-10-16 12:13:53 -04:00
Isaac Connor
83800e8753 Test for existend of type in defaults to avoid warning 2025-10-10 13:26:57 -04:00
Isaac Connor
c1fe4a620a Merge remote-tracking branch 'upstream/master' into ai_server 2025-10-10 13:07:10 -04:00
Isaac Connor
b5a10ca1ce Add +1 because we will now use 30000 instead of 30001.. so some existing configs may break. 2025-10-09 11:01:08 -04:00
Isaac Connor
1fc27261e1 Add initial_scale property 2025-10-07 21:02:30 -04:00
Isaac Connor
756f197098 Merge remote-tracking branch 'upstream/master' into ai_server 2025-10-03 12:40:34 -04:00
Isaac Connor
e04d38f83e When using MIN_SPREAMING_PORT, divide by 5 so we get 5 streams per port 2025-10-01 21:01:29 -04:00
Isaac Connor
2a9b7d1f61 Merge remote-tracking branch 'upstream/master' into ai_server 2025-10-01 09:24:16 -04:00
Isaac Connor
3373fb71aa Simply zms option let's just assume that that we can stream 2025-09-25 17:36:13 -04:00
Isaac Connor
5982229369 Merge remote-tracking branch 'upstream/master' into ai_server 2025-09-25 08:55:48 -04:00
Isaac Connor
fe323e0aff Add DefaultPlayer support in getStreamSrc 2025-09-24 14:05:58 -04:00
Isaac Connor
063ec36106 Add DefaultPlayer to Monitor object 2025-09-24 09:54:19 -04:00
Isaac Connor
a0cc82b490 Merge branch 'master' into ai_server 2025-09-06 11:30:48 -04:00
Isaac Connor
edf87d6463 Move stream-info off the video stream down to where the monitor status info is. 2025-09-05 09:35:53 -04:00
Isaac Connor
28044f4fad Merge branch 'master' into ai_server 2025-08-20 16:47:25 -04:00
Isaac Connor
7bf2fb8fce Convert OutputCodec from int to varchar OutputCodecName. ffmpeg has different values for codec_id for different versions of ffmpeg. So just use the codec name instead. 2025-08-20 15:59:02 -04:00
Isaac Connor
2de116e8e4 Rough in restream in UI 2025-08-07 14:27:09 -04:00
Isaac Connor
c66c691280 Merge branch 'master' into ai_server 2025-08-04 20:02:25 -04:00