Commit Graph

127 Commits

Author SHA1 Message Date
Peter Keresztes Schmidt
68bedfe48f Fix logging format string mismatches
* Remove SZFMTD format macro and use %zu instead for size_t. %zu is understood by every compiler nowadays.
2021-04-30 00:26:24 +02:00
Isaac Connor
fd72fbd2ac Remove unused state var and unneeded if have_output 2021-04-20 17:22:35 -04:00
Isaac Connor
ef10ecc06a Allow users to start/stop alarms without monitor view permission. When forcing an alarm, disable recording first so that the alarm is distinct. This is necessary due to permissions. 2021-04-12 15:59:31 -04:00
Peter Keresztes Schmidt
4e8c7d1f7c Eliminate non-thread-safe calls to localtime
localtime uses an internal static storage to which a pointer is given as return value.
Due to this it is not safe to call localtime from multiple threads since the same static storage is used.

Use localtime_r instead which allows to pass in a tm struct.

Fixes:
https://github.com/ZoneMinder/zoneminder/security/code-scanning/24
https://github.com/ZoneMinder/zoneminder/security/code-scanning/25
https://github.com/ZoneMinder/zoneminder/security/code-scanning/26
https://github.com/ZoneMinder/zoneminder/security/code-scanning/27
https://github.com/ZoneMinder/zoneminder/security/code-scanning/28
https://github.com/ZoneMinder/zoneminder/security/code-scanning/30
https://github.com/ZoneMinder/zoneminder/security/code-scanning/31
https://github.com/ZoneMinder/zoneminder/security/code-scanning/33
https://github.com/ZoneMinder/zoneminder/security/code-scanning/58
https://github.com/ZoneMinder/zoneminder/security/code-scanning/59
https://github.com/ZoneMinder/zoneminder/security/code-scanning/63
https://github.com/ZoneMinder/zoneminder/security/code-scanning/64
https://github.com/ZoneMinder/zoneminder/security/code-scanning/65
2021-03-21 21:42:02 +01:00
Isaac Connor
c9170a87b2 Allow users with Monitors::View to generate and cancel events 2021-03-12 09:26:56 -05:00
Peter Keresztes Schmidt
9e77324de4 Replace raw mysql_query calls with the zmDb* functions
With this we can make sure we have proper locking of our DB connection at all times.
2021-03-06 00:12:18 +01:00
Peter Keresztes Schmidt
d9568a98c0 Drop zm_thread which has been replaced by STL implementations 2021-03-04 10:55:46 +01:00
Isaac Connor
57f599237c Merge pull request #3136 from Carbenium/db-connect
DB: Make connection initialization more predictable and finalize mysql library correctly
2021-02-08 08:43:33 -05:00
Peter Keresztes Schmidt
f43507dce0 Use the power of smart pointers to manage Monitor instances 2021-02-07 21:20:45 +01:00
Peter Keresztes Schmidt
aec4dbc6ff DB: Make connection initialization more predictable and avoid double-initialization
Remove calls to zmDBConnect from various places to avoid possible side-effects/double initialization.
The function should be called once from the main thread of the daemon.

Also split config loading into 2 steps: static and DB config loading. Load the static config before zmDBConnect is called so it has a chance to succeed.
2021-02-07 13:44:41 +01:00
Peter Keresztes Schmidt
0dbc39ee25 Cleanup and reorganize includes
With this commit a unified structure for includes is introduced.
The general rules:
 * Only include what you need
 * Include wherever possible in the cpp and forward-declare in the header

 The includes are sorted in a local to global fashion. This means for the include order:
  0. If cpp file: The corresponding h file and an empty line
  1. Includes from the project sorted alphabetically
  2. System/library includes sorted alphabetically
  3. Conditional includes
2021-02-04 18:02:01 +01:00
Peter Keresztes Schmidt
e09fa1bebf Remove includes of <cinttypes>
Instead of including <cinttypes> directly, zm_define.h should be used
to get the typedef'ed types as well.
2021-02-02 21:37:26 +01:00
Isaac Connor
4bcefe0562 Add a 10 second wait to force alarm on. If the monitor doesn't notice it is likely not running, leaving an mmap behind 2021-01-31 11:44:58 -05:00
Isaac Connor
b306f1b2e8 Add R and W short form options 2020-12-15 16:55:28 -05:00
Isaac Connor
c9bd09ae7b report both capture_fps and analysis_fps 2020-12-09 15:03:18 -05:00
Isaac Connor
1257a7ea37 improvements reported by cppcheck 2020-11-01 16:11:19 -05:00
Peter Keresztes Schmidt
8f980a1168 Convert NULL/0 to nullptr
The 0 -> nullptr changes should definitely improve readability.
2020-08-26 22:03:40 +02:00
Isaac Connor
ce9e2c8b27 Merge branch 'release-1.34' 2020-05-15 11:53:09 -04:00
Isaac Connor
9ea1c637f9 Remove debug Exiting message 2020-05-15 11:48:41 -04:00
Isaac Connor
6bb2c09a72 Merge branch 'release-1.34' 2020-05-15 11:41:34 -04:00
Isaac Connor
7a85be59be Remove errant closing db debug output 2020-05-15 10:22:58 -04:00
Isaac Connor
d92772343a Merge branch 'release-1.34' 2020-05-14 12:02:50 -04:00
Isaac Connor
25a772c5eb reorder logic a bit to make it easier to read. Make exit_zmu not return a value. 2020-05-14 12:02:02 -04:00
Isaac Connor
e274aa471a Use fputc instead of printf for separator to be a tiny bit more efficient. Report current state when forcing alarm on 2020-04-23 18:13:34 -04:00
Isaac Connor
7fcd71e684 Use fputc instead of printf for separator to be a tiny bit more efficient. Report current state when forcing alarm on 2020-03-24 15:19:16 -04:00
Isaac Connor
ad61a0e385 Escape Function to fix mysql8. Fixes #2885 2020-03-16 21:06:31 -04:00
Isaac Connor
f05dbd3b89 Fix zmu not respecting jwt token auth when AUTH_RELAY set to none 2020-02-25 14:40:47 -05:00
Isaac Connor
33951ae584 Print out an error when a monitor is in MONITOR mode because we can't handle alarms. Allow signals to terminate zmu by checking zm_terminate. 2019-06-19 08:36:37 -04:00
Pliable Pixels
bb18c305ab add token to command line for zmu 2019-05-08 11:08:27 -04:00
Pliable Pixels
b293592e4c added token validation to zms/zmu/zmuser 2019-05-08 10:55:32 -04:00
Isaac Connor
f3d0c4e643 Merge branch 'master' of github.com:zoneminder/ZoneMinder 2019-04-04 09:37:13 -04:00
Isaac Connor
8de7d576a5 spacing and use Error instead of fprintf(stderr) so that things get logged. 2019-04-04 09:35:37 -04:00
Isaac Connor
b794c2ca20 fix crash by checking username without checking if it is NULL 2019-03-18 12:01:51 -04:00
Steve Gilvarry
924d5235d0 Validate zmu Username and Password lengths (#2484)
* Validate zmu Username and Password lengths
Ensure user provided values are not larger than allowed and error if
they are, therefore further preventing overflow.

* Check username and password functions for zmu and zms

* Check username and password functions for zmu and zms
2019-02-13 10:40:43 -05:00
Isaac Connor
8404f0ef64 When forcing an alarm, print out the event id 2018-11-26 16:21:32 -05:00
Isaac Connor
8a80cf686b Merge branch 'master' into storageareas 2018-04-26 21:58:34 -04:00
Isaac Connor
356badf21d Merge branch 'master' of github.com:ZoneMinder/ZoneMinder 2018-04-26 11:57:46 -04:00
Andy Bauer
678503b992 fix ftbs on el7 2018-04-24 12:16:19 -05:00
Isaac Connor
3ab0755e03 google code style plus other cleanups 2018-04-23 13:50:10 -04:00
Isaac Connor
235fc640be exit_zmu must come before use 2018-04-23 11:15:33 -04:00
Isaac Connor
11cacebb3b use a function called exit_zmu instead of exit() to properly close logs and db. The reason is just to reduce connection lost logs in mysql. 2018-04-23 11:14:44 -04:00
Isaac Connor
fd1c69d48a switch to uint64_t for event_id because long long can actually be 128 bit 2018-04-17 13:51:20 -04:00
Isaac Connor
344539f5dc cleanup 2017-11-28 11:55:47 -05:00
Isaac Connor
64816aa005 fixes from cppcheck. 2017-11-18 16:00:10 -05:00
Isaac Connor
b9f65c9f50 remove merge marker 2017-06-05 09:26:05 -04:00
Isaac Connor
451714a403 Merge branch 'master' into storageareas 2017-06-04 21:42:56 -04:00
Isaac Connor
bc32837e3a fix braces 2017-05-31 13:55:21 -04:00
Isaac Connor
5ae34a7561 Merge branch 'master' into storageareas 2017-01-02 09:39:10 -05:00
Andy Bauer
254fcbcef7 update gpl 2 mailing address in source files 2016-12-26 09:23:16 -06:00
Isaac Connor
59406fd03a Merge branch 'master' into storageareas 2016-04-28 09:24:36 -04:00