diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b1b78ea..8955325e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,18 @@ # cmake_minimum_required (VERSION 2.6) project (zoneminder) -set(zoneminder_VERSION "1.28.108") +set(zoneminder_VERSION "1.28.109") # Engine version is used for external plugin compilation set(ZM_ENGINE_VERSION 29) # make API version a minor of ZM version set(zoneminder_API_VERSION "${zoneminder_VERSION}.1") +# Make sure the submodules are there +if( NOT EXISTS "${CMAKE_SOURCE_DIR}/web/api/app/Plugin/Crud/Lib/CrudControllerTrait.php" ) +message( SEND_ERROR "The git submodules are not available. Please run +git submodule update --init --recursive") +endif( NOT EXISTS "${CMAKE_SOURCE_DIR}/web/api/app/Plugin/Crud/Lib/CrudControllerTrait.php" ) + # CMake does not allow out-of-source build if CMakeCache.exists # in the source folder. Abort and notify the user if( @@ -175,7 +181,7 @@ if(ZM_PLUGIN_SUPPORT) endif(ZM_PLUGIN_SUPPORT) # Reassign some variables if a target distro has been specified -if((ZM_TARGET_DISTRO STREQUAL "f21") OR (ZM_TARGET_DISTRO STREQUAL "f22")) +if((ZM_TARGET_DISTRO STREQUAL "f22") OR (ZM_TARGET_DISTRO STREQUAL "f23")) set(ZM_RUNDIR "/var/run/zoneminder") set(ZM_SOCKDIR "/var/lib/zoneminder/sock") set(ZM_TMPDIR "/var/lib/zoneminder/temp") @@ -207,7 +213,7 @@ elseif(ZM_TARGET_DISTRO STREQUAL "OS13") set(ZM_WEB_GROUP "www") set(ZM_WEBDIR "/srv/www/htdocs/zoneminder") set(ZM_CGIDIR "/srv/www/cgi-bin") -endif((ZM_TARGET_DISTRO STREQUAL "f21") OR (ZM_TARGET_DISTRO STREQUAL "f22")) +endif((ZM_TARGET_DISTRO STREQUAL "f22") OR (ZM_TARGET_DISTRO STREQUAL "f23")) # Required for certain checks to work set(CMAKE_EXTRA_INCLUDE_FILES @@ -788,13 +794,13 @@ if(ZM_PLUGIN_COMPIL) endif(ZM_PLUGIN_COMPIL) # Process distro subdirectories -if((ZM_TARGET_DISTRO STREQUAL "f21") OR (ZM_TARGET_DISTRO STREQUAL "f22")) +if((ZM_TARGET_DISTRO STREQUAL "f22") OR (ZM_TARGET_DISTRO STREQUAL "f23")) add_subdirectory(distros/fedora) elseif((ZM_TARGET_DISTRO STREQUAL "el6") OR (ZM_TARGET_DISTRO STREQUAL "el7")) add_subdirectory(distros/redhat) elseif(ZM_TARGET_DISTRO STREQUAL "OS13") add_subdirectory(distros/opensuse) -endif((ZM_TARGET_DISTRO STREQUAL "f21") OR (ZM_TARGET_DISTRO STREQUAL "f22")) +endif((ZM_TARGET_DISTRO STREQUAL "f22") OR (ZM_TARGET_DISTRO STREQUAL "f23")) # Print optional libraries detection status message(STATUS "Optional libraries found:${optlibsfound}") diff --git a/configure.ac b/configure.ac index 5f5d7b762..38d322c9b 100755 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # For instructions on building with cmake, please see INSTALL # AC_PREREQ(2.59) -AC_INIT(zm,1.28.108,[http://www.zoneminder.com/forums/ - Please check FAQ first],zoneminder,http://www.zoneminder.com/downloads.html) +AC_INIT(zm,1.28.109,[http://www.zoneminder.com/forums/ - Please check FAQ first],zoneminder,http://www.zoneminder.com/downloads.html) AC_CONFIG_AUX_DIR([.]) AM_INIT_AUTOMAKE LT_PREREQ([2.4.2]) diff --git a/db/zm_update-1.28.109.sql b/db/zm_update-1.28.109.sql index c23927e26..be6dca9f1 100644 --- a/db/zm_update-1.28.109.sql +++ b/db/zm_update-1.28.109.sql @@ -14,7 +14,7 @@ SET @s = (SELECT IF( AND column_name = 'Hostname' ) > 0, "SELECT 'Column Hostname already exists in Servers'", -"ALTER TABLE `Servers` ADD COLUMN `Hostname` TEXT AFTER Name", +"ALTER TABLE `Servers` ADD COLUMN `Hostname` TEXT AFTER Name" )); PREPARE stmt FROM @s; diff --git a/distros/debian_cmake/rules b/distros/debian_cmake/rules index 3b831a120..c9dccb928 100755 --- a/distros/debian_cmake/rules +++ b/distros/debian_cmake/rules @@ -17,9 +17,9 @@ override_dh_auto_configure: -DZM_SOCKDIR=/var/run/zm \ -DZM_TMPDIR=/var/tmp/zm \ -DZM_LOGDIR=/var/log/zm \ - -DZM_WEBDIR=/usr/share/zoneminder \ + -DZM_WEBDIR=/usr/share/zoneminder/www \ -DZM_CONTENTDIR=/var/cache/zoneminder \ - -DZM_CGIDIR=/usr/lib/cgi-bin \ + -DZM_CGIDIR=/usr/lib/zoneminder/cgi-bin \ -DZM_WEB_USER=www-data \ -DZM_WEB_GROUP=www-data \ -DCMAKE_INSTALL_SYSCONFDIR=etc/zm \ diff --git a/distros/debian_cmake/zoneminder.install b/distros/debian_cmake/zoneminder.install index 9e8953409..1bd76421f 100644 --- a/distros/debian_cmake/zoneminder.install +++ b/distros/debian_cmake/zoneminder.install @@ -1,5 +1,5 @@ usr/bin -usr/lib/cgi-bin +usr/lib/zoneminder/cgi-bin usr/share/man usr/share/perl5/ZoneMinder usr/share/perl5/ZoneMinder.pm diff --git a/distros/debian_cmake/zoneminder.links b/distros/debian_cmake/zoneminder.links index 9715ee428..5560a100a 100644 --- a/distros/debian_cmake/zoneminder.links +++ b/distros/debian_cmake/zoneminder.links @@ -1,4 +1,3 @@ var/cache/zoneminder/events usr/share/zoneminder/events var/cache/zoneminder/images usr/share/zoneminder/images var/cache/zoneminder/temp usr/share/zoneminder/temp -usr/lib/cgi-bin usr/share/zoneminder/cgi-bin diff --git a/distros/fedora/README.Fedora b/distros/fedora/README.Fedora index 3043d78fd..85088d868 100644 --- a/distros/fedora/README.Fedora +++ b/distros/fedora/README.Fedora @@ -11,9 +11,9 @@ What's New 2. The ZoneMinder config file, zm.conf, has been moved under /etc/zm. -3. The ZoneMinder mysql account now requires "Create" permission. This change - must be done manually before ZoneMinder will run. See the installation steps - below. +3. Due to the active state of the ZoneMinder project, we now recommend granting + ALL permission to the ZoneMinder mysql account. This change must be done + manually before ZoneMinder will run. See the installation steps below. 4. A new permission group called "Groups" has been added. This allows the system administrator to assign "view", "edit", or "none" permission to @@ -46,9 +46,9 @@ New installs mysql -u root -p < /usr/share/zoneminder/db/zm_create.sql mysql -u root -p - mysql> grant select,insert,update,delete,lock tables,alter,create - on zm.* to 'zmuser'@localhost identified by 'zmpass'; - mysql> exit; + mysql> grant all + on zm.* to 'zmuser'@localhost identified by 'zmpass'; + mysql> exit; mysqladmin -u root -p reload The database account credentials, zmuser/zmpass, are arbitrary. Set them to @@ -59,6 +59,11 @@ New installs Change ZM_DB_USER and ZM_DB_PASS to the values you created in the previous step. + Additionally, you must also edit + /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner. + Scroll down and change login and password to the values you created in the + previous step. + 4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local timezone. PHP will complain loudly if this is not set, or if it is set incorrectly, and these complaints will show up in the zoneminder logging @@ -109,12 +114,16 @@ Upgrades Compare /etc/zm/zm.conf to /etc/zm/zm.conf.rpmnew. Verify that zm.conf contains any new config settings that may be in zm.conf.rpmnew. + Additionally, you must also edit + /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner. + Scroll down and change login and password to the values you used + previsouly. + 2. Verify permissions of the zmuser account. Over time, the database account permissions required for normal operation - have changed. Verify the zmuser database account has been granted select, - insert, update, delete, lock tables, alter, and create permission to the - ZoneMinder database: + have increased. Verify the zmuser database account has been granted all + permission to the ZoneMinder database: mysql -u root -p mysql> show grants for zmuser@localhost; diff --git a/distros/fedora/zoneminder.f21.spec b/distros/fedora/archive/zoneminder.f21.spec similarity index 100% rename from distros/fedora/zoneminder.f21.spec rename to distros/fedora/archive/zoneminder.f21.spec diff --git a/distros/fedora/zoneminder.f23.spec b/distros/fedora/zoneminder.f23.spec new file mode 100644 index 000000000..da19c80ee --- /dev/null +++ b/distros/fedora/zoneminder.f23.spec @@ -0,0 +1,412 @@ +%define zmuid $(id -un) +%define zmgid $(id -gn) +%define zmuid_final apache +%define zmgid_final apache + +%global _hardened_build 1 + +### Delete the lines below to build with ffmpeg and/or x10 +%define _without_ffmpeg 1 +%define _without_x10 1 + +Name: zoneminder +Version: 1.29.0 +Release: 1%{?dist} +Summary: A camera monitoring and analysis tool +Group: System Environment/Daemons +# jscalendar is LGPL (any version): http://www.dynarch.com/projects/calendar/ +# Mootools is inder the MIT license: http://mootools.net/ +License: GPLv2+ and LGPLv2+ and MIT +URL: http://www.zoneminder.com/ + +#Source: https://github.com/ZoneMinder/ZoneMinder/archive/v%{version}.tar.gz +Source: ZoneMinder-%{version}.tar.gz + +BuildRequires: cmake gnutls-devel systemd-units bzip2-devel +BuildRequires: mariadb-devel pcre-devel libjpeg-turbo-devel +BuildRequires: perl(Archive::Tar) perl(Archive::Zip) perl-podlators +BuildRequires: perl(Date::Manip) perl(DBD::mysql) +BuildRequires: perl(ExtUtils::MakeMaker) perl(LWP::UserAgent) +BuildRequires: perl(MIME::Entity) perl(MIME::Lite) +BuildRequires: perl(PHP::Serialization) perl(Sys::Mmap) +BuildRequires: perl(Time::HiRes) perl(Net::SFTP::Foreign) +BuildRequires: perl(Expect) perl(Sys::Syslog) +BuildRequires: gcc gcc-c++ vlc-devel libcurl-devel libv4l-devel +%{!?_without_ffmpeg:BuildRequires: ffmpeg-devel} +%{!?_without_x10:BuildRequires: perl(X10::ActiveHome) perl(Astro::SunTime)} +# cmake needs the following installed at build time due to the way it auto-detects certain parameters +BuildRequires: httpd polkit-devel +%{!?_without_ffmpeg:BuildRequires: ffmpeg} + +Requires: httpd php php-gd php-mysql cambozola polkit net-tools psmisc mod_ssl +Requires: libjpeg-turbo vlc-core libcurl +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) +Requires: perl(DBD::mysql) perl(Archive::Tar) perl(Archive::Zip) +Requires: perl(MIME::Entity) perl(MIME::Lite) perl(Net::SMTP) perl(Net::FTP) +Requires: perl(LWP::Protocol::https) +%{!?_without_ffmpeg:Requires: ffmpeg} + +Requires(post): systemd-units systemd-sysv +Requires(post): /usr/bin/gpasswd +Requires(post): /usr/bin/less +Requires(preun): systemd-units +Requires(postun): systemd-units + +%description +ZoneMinder is a set of applications which is intended to provide a complete +solution allowing you to capture, analyse, record and monitor any cameras you +have attached to a Linux based machine. It is designed to run on kernels which +support the Video For Linux (V4L) interface and has been tested with cameras +attached to BTTV cards, various USB cameras and IP network cameras. It is +designed to support as many cameras as you can attach to your computer without +too much degradation of performance. + +%prep +%setup -q -n ZoneMinder-%{version} + +# Change the following default values +./utils/zmeditconfigdata.sh ZM_PATH_ZMS /cgi-bin/zm/nph-zms +./utils/zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes +./utils/zmeditconfigdata.sh ZM_PATH_SWAP /dev/shm +./utils/zmeditconfigdata.sh ZM_UPLOAD_FTP_LOC_DIR /var/spool/zoneminder-upload +./utils/zmeditconfigdata.sh ZM_OPT_CONTROL yes +./utils/zmeditconfigdata.sh ZM_CHECK_FOR_UPDATES no +./utils/zmeditconfigdata.sh ZM_DYN_SHOW_DONATE_REMINDER no + +%build +%cmake \ + -DZM_TARGET_DISTRO="f23" \ +%{?_without_ffmpeg:-DZM_NO_FFMPEG=ON} \ +%{?_without_x10:-DZM_NO_X10=ON} \ + . + +make %{?_smp_mflags} + +%install +export DESTDIR=%{buildroot} +make install + +%post +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi + +# Allow zoneminder access to local video sources, serial ports, and x10 +/usr/bin/gpasswd -a %{zmuid_final} video +/usr/bin/gpasswd -a %{zmuid_final} dialout + +# Upgrade from a previous version of zoneminder +if [ $1 -eq 2 ] ; then + # Freshen the database + /usr/bin/zmupdate.pl -f + + # We can't run this automatically when new sql account permissions need to + # be manually added first + # Run zmupdate non-interactively + #/usr/bin/zmupdate.pl --nointeractive +fi + +# Warn the end user to read the README file +echo -e "\nVERY IMPORTANT: Before starting ZoneMinder, read README.Fedora to finish the\ninstallation or upgrade!\n" +echo -e "\nThe README file is located here: %{_docdir}/%{name}\n" + +%preun +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable zoneminder.service > /dev/null 2>&1 || : + /bin/systemctl stop zoneminder.service > /dev/null 2>&1 || : +fi + +%postun +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart zoneminder.service >/dev/null 2>&1 || : +fi + +%triggerun -- zoneminder < 1.25.0-4 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply zoneminder +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save zoneminder >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del zoneminder >/dev/null 2>&1 || : +/bin/systemctl try-restart zoneminder.service >/dev/null 2>&1 || : + + +%files +%defattr(-,root,root,-) +%doc AUTHORS COPYING README.md distros/fedora/README.Fedora distros/fedora/jscalendar-doc +%config %attr(640,root,%{zmgid_final}) /etc/zm/zm.conf +%config(noreplace) %attr(644,root,root) /etc/httpd/conf.d/zoneminder.conf +%config(noreplace) /etc/tmpfiles.d/zoneminder.conf +%config(noreplace) /etc/logrotate.d/zoneminder + +%{_unitdir}/zoneminder.service + +%{_bindir}/zma +%{_bindir}/zmaudit.pl +%{_bindir}/zmc +%{_bindir}/zmcontrol.pl +%{_bindir}/zmdc.pl +%{_bindir}/zmf +%{_bindir}/zmfilter.pl +%{_bindir}/zmpkg.pl +%{_bindir}/zmstreamer +%{_bindir}/zmtrack.pl +%{_bindir}/zmtrigger.pl +%{_bindir}/zmu +%{_bindir}/zmupdate.pl +%{_bindir}/zmvideo.pl +%{_bindir}/zmwatch.pl +%{_bindir}/zmcamtool.pl +%{_bindir}/zmsystemctl.pl +%{!?_without_x10:%{_bindir}/zmx10.pl} + +%{perl_vendorlib}/ZoneMinder* +%{_mandir}/man*/* +%dir %{_libexecdir}/zoneminder +%{_libexecdir}/zoneminder/cgi-bin +%dir %{_datadir}/zoneminder +%{_datadir}/zoneminder/db +%{_datadir}/zoneminder/www + +%{_datadir}/polkit-1/actions/com.zoneminder.systemctl.policy +%{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules + +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/lib/zoneminder +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/lib/zoneminder/events +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/lib/zoneminder/images +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/lib/zoneminder/sock +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/lib/zoneminder/swap +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/lib/zoneminder/temp +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/log/zoneminder +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /var/spool/zoneminder-upload +%dir %attr(755,%{zmuid_final},%{zmgid_final}) /run/zoneminder + + +%changelog +* Sat Nov 21 2015 Andrew Bauer - 1.29.0 +- Bump version for 1.29.0 release on Fedora 23. + +* Sat Feb 14 2015 Andrew Bauer - 1.28.1 +- Bump version for 1.28.1 release on Fedora 21. + +* Sun Oct 5 2014 Andrew Bauer - 1.28.0 +- Bump version for 1.28.0 release. + +* Fri Mar 14 2014 Andrew Bauer - 1.27 +- Tweak build requirements for cmake + +* Sat Feb 01 2014 Andrew Bauer - 1.27 +- Add zmcamtool.pl. Bump version for 1.27 release. + +* Mon Dec 16 2013 Andrew Bauer - 1.26.5 +- This is a bug fixe release +- RTSP fixes, cmake enhancements, couple other misc fixes + +* Mon Oct 07 2013 Andrew Bauer - 1.26.4 +- Initial cmake build. + +* Sat Oct 05 2013 Andrew Bauer - 1.26.4 +- Fedora specific path changes have been moved to zoneminder-1.26.0-defaults.patch +- All files are now part of the zoneminder source tree. Update specfile accordingly. + +* Sat Sep 21 2013 Andrew Bauer - 1.26.3 +- Initial rebuild for ZoneMinder 1.26.3 release. + +* Fri Feb 15 2013 Fedora Release Engineering - 1.25.0-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Mon Jan 21 2013 Adam Tkac - 1.25.0-12 +- rebuild due to "jpeg8-ABI" feature drop + +* Mon Jan 7 2013 Remi Collet - 1.25.0-11 +- fix configuration file for httpd 2.4, #871502 + +* Fri Dec 21 2012 Adam Tkac - 1.25.0-10 +- rebuild against new libjpeg + +* Thu Aug 09 2012 Jason L Tibbitts III - 1.25.0-9 +- Add patch to work around v4l2 api breakage in 3.5 kernel. + +* Sun Jul 22 2012 Fedora Release Engineering - 1.25.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat Jun 23 2012 Petr Pisar - 1.25.0-7 +- Perl 5.16 rebuild + +* Wed Mar 21 2012 Jason L Tibbitts III - 1.25.0-6 +- Fix stupid thinko in sql modifications. + +* Sat Feb 25 2012 Jason L Tibbitts III - 1.25.0-5 +- Clean up macro usage. + +* Sat Feb 25 2012 Jason L Tibbitts III - 1.25.0-4 +- Convert to systemd. +- Add tmpfiles.d configuration since the initscript isn't around to create + /run/zoneminder. +- Remove some pointless executable permissions. +- Add logrotate file. + +* Wed Feb 22 2012 Jason L Tibbitts III - 1.25.0-3 +- Update README.Fedora to reference systemctl and mention timezone info in + php.ini. +- Add proper default for EYEZM_LOG_TO_FILE. + + +* Thu Feb 09 2012 Jason L Tibbitts III - 1.25.0-2 +- Rebuild for new pcre. + +* Thu Jan 19 2012 Jason L Tibbitts III - 1.25.0-1 +- Update to 1.25.0 +- Fix gcc4.7 build problems. +- Drop gcc4.4 build fixes; for whatever reason they now break the build. +- Clean up old patches. +- Force setting of ZM_TMPDIR and ZM_RUNDIR. + +* Sat Jan 14 2012 Fedora Release Engineering - 1.24.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Thu Sep 15 2011 Jason L Tibbitts III - 1.24.4-3 +- Re-add the dist-tag that somehow got lost. + +* Thu Sep 15 2011 Jason L Tibbitts III - 1.24.4-2 +- Add patch for bug 711780 - fix syntax issue in Mapped.pm. +- Undo that patch, and undo another which was the cause of the whole mess. +- Fix up other patches so ZM_PATH_BUILD is both defined and useful. +- Make sure database creation mods actually take. +- Update Fedora-specific docs with some additional info. +- Use bundled mootools (javascript, so no guideline violation). +- Update download location. +- Update the gcrypt patch to actually work. +- Upstream changed the tarball without changing the version to patch a + vulnerability, so redownload. + +* Sun Aug 14 2011 Jason L Tibbitts III - 1.24.4-1 +- Initial attempt to upgrade to 1.24.4. +- Add patch from BZ 460310 to build against libgcrypt instead of requiring the + gnutls openssl libs. + +* Thu Jul 21 2011 Petr Sabata - 1.24.3-7.20110324svn3310 +- Perl mass rebuild + +* Wed Jul 20 2011 Petr Sabata - 1.24.3-6.20110324svn3310 +- Perl mass rebuild + +* Mon May 09 2011 Jason L Tibbitts III - 1.24.3-5.20110324svn3310 +- Bump for gnutls update. + +* Thu Mar 24 2011 Jason L Tibbitts III - 1.24.3-4.20110324svn3310 +- Update to latest 1.24.3 subversion. Turns out that what upstream was calling + 1.24.3 is really just an occasionally updated devel snapshot. +- Rebase various patches. + +* Wed Mar 23 2011 Dan Horák - 1.24.3-3 +- rebuilt for mysql 5.5.10 (soname bump in libmysqlclient) + +* Tue Feb 08 2011 Fedora Release Engineering - 1.24.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Tue Jan 25 2011 Jason L Tibbitts III - 1.24.3-1 +- Update to latest upstream version. +- Rebase patches. +- Initial incomplete attempt to disable v4l1 support. + +* Fri Jan 21 2011 Jason L Tibbitts III - 1.24.2-6 +- Unbundle cambozola; instead link to the separately pacakged copy. +- Remove BuildRoot:, %%clean and buildroot cleaning in %%install. +- Git rid of mixed space/tab usage by removing all tabs. +- Remove unnecessary Conflicts: line. +- Attempt to force short_open_tag on for the code directories. +- Move default location of sockets, swaps, logfiles and some temporary files to + make more sense and allow things to work better with a future selinux policy. +- Fix errors in README.Fedora. + +* Wed Jun 02 2010 Marcela Maslanova - 1.24.2-5 +- Mass rebuild with perl-5.12.0 + +* Fri Dec 4 2009 Stepan Kasal - 1.24.2-4 +- rebuild against perl 5.10.1 +- use Perl vendorarch and archlib variables correctly + +* Mon Jul 27 2009 Fedora Release Engineering - 1.24.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Wed Jul 22 2009 Jason L Tibbitts III - 1.24.2-2 +- Bump release since 1.24.2-1 was mistakenly tagged a few months ago. + +* Wed Jul 22 2009 Jason L Tibbitts III - 1.24.2-1 +- Initial update to 1.24.2. +- Rebase patches. +- Update mootools download location. +- Update to mootools 1.2.3. +- Add additional dependencies for some optional features. + +* Sat Apr 11 2009 Martin Ebourne - 1.24.1-3 +- Remove unused Sys::Mmap perl dependency RPM is finding + +* Sat Apr 11 2009 Martin Ebourne - 1.24.1-2 +- Update gcc44 patch to disable -frepo, seems to be broken with gcc44 +- Added noffmpeg patch to make building outside mock easier + +* Sat Mar 21 2009 Martin Ebourne - 1.24.1-1 +- Patch for gcc 4.4 compilation errors +- Upgrade to 1.24.1 + +* Wed Feb 25 2009 Fedora Release Engineering - 1.23.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Sat Jan 24 2009 Caolán McNamara - 1.23.3-3 +- rebuild for dependencies + +* Mon Dec 15 2008 Martin Ebourne - 1.23.3-2 +- Fix permissions on zm.conf + +* Fri Jul 11 2008 Jason L Tibbitts III - 1.23.3-1 +- Initial attempt at packaging 1.23. + +* Tue Jul 1 2008 Martin Ebourne - 1.22.3-15 +- Add perl module compat dependency, bz #453590 + +* Tue May 6 2008 Martin Ebourne - 1.22.3-14 +- Remove default runlevel, bz #441315 + +* Mon Apr 28 2008 Jason L Tibbitts III - 1.22.3-13 +- Backport patch for CVE-2008-1381 from 1.23.3 to 1.22.3. + +* Tue Feb 19 2008 Fedora Release Engineering - 1.22.3-12 +- Autorebuild for GCC 4.3 + +* Thu Jan 3 2008 Martin Ebourne - 1.22.3-11 +- Fix compilation on gcc 4.3 + +* Thu Dec 6 2007 Martin Ebourne - 1.22.3-10 +- Rebuild for new openssl + +* Thu Aug 2 2007 Martin Ebourne - 1.22.3-8 +- Fix licence tag + +* Thu Jul 12 2007 Martin Ebourne - 1.22.3-7 +- Fixes from testing by Jitz including missing dependencies and database creation + +* Sat Jun 30 2007 Martin Ebourne - 1.22.3-6 +- Disable crashtrace on ppc + +* Sat Jun 30 2007 Martin Ebourne - 1.22.3-5 +- Fix uid for directories in /var/lib/zoneminder + +* Tue Jun 26 2007 Martin Ebourne - 1.22.3-4 +- Added perl Archive::Tar dependency +- Disabled web interface due to lack of access control on the event images + +* Sun Jun 10 2007 Martin Ebourne - 1.22.3-3 +- Changes recommended in review by Jason Tibbitts + +* Mon Apr 2 2007 Martin Ebourne - 1.22.3-2 +- Standardised on package name of zoneminder + +* Thu Dec 28 2006 Martin Ebourne - 1.22.3-1 +- First version. Uses some parts from zm-1.20.1 by Corey DeLasaux and Serg Oskin diff --git a/distros/redhat/README.CentOS b/distros/redhat/README.CentOS index 05e2cb0ab..e6e53bbc6 100644 --- a/distros/redhat/README.CentOS +++ b/distros/redhat/README.CentOS @@ -1,9 +1,9 @@ What's New ========== -1. The ZoneMinder mysql account now requires "Create" permission. This change - must be done manually before ZoneMinder will run. See the installation steps - below. +1. Due to the active state of the ZoneMinder project, we now recommend granting + ALL permission to the ZoneMinder mysql account. This change must be done + manually before ZoneMinder will run. See the installation steps below. 2. A new permission group called "Groups" has been added. This allows the system administrator to assign "view", "edit", or "none" permission to @@ -32,7 +32,7 @@ New installs mysql -uroot -p mysql> create database zm; - mysql> grant select,insert,update,delete,lock tables,alter,create + mysql> grant all on zm.* to 'zmuser'@localhost identified by 'zmpass'; mysql> exit; mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql @@ -45,6 +45,11 @@ New installs other than zmuser/zmpass then you must now edit /etc/zm.conf. Change ZM_DB_USER and ZM_DB_PASS to the values you created in step 2. + Additionally, you must also edit + /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner. + Scroll down and change login and password to the values you created in the + previous step. + 4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local timezone. PHP will complain loudly if this is not set, or if it is set incorrectly, and these complaints will show up in the zoneminder logging @@ -101,12 +106,16 @@ New installs Compare /etc/zm.conf to /etc/zm.conf.rpmnew. Verify that zm.conf contains any new config settings that may be in zm.conf.rpmnew. + Additionally, you must also edit + /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner. + Scroll down and change login and password to the values you used + previsouly. + 2. Verify permissions of the zmuser account. Over time, the database account permissions required for normal operation - have changed. Verify the zmuser database account has been granted select, - insert, update, delete, lock tables, alter, and create permission to the - ZoneMinder database: + have increased. Verify the zmuser database account has been granted all + permission to the ZoneMinder database: mysql -u root -p mysql> show grants for zmuser@localhost; diff --git a/distros/redhat/README.Centos7 b/distros/redhat/README.Centos7 index 70e98b006..451f4290b 100644 --- a/distros/redhat/README.Centos7 +++ b/distros/redhat/README.Centos7 @@ -1,9 +1,9 @@ What's New ========== -1. The ZoneMinder mysql account now requires "Create" permission. This change - must be done manually before ZoneMinder will run. See the installation steps - below. +1. Due to the active state of the ZoneMinder project, we now recommend granting + ALL permission to the ZoneMinder mysql account. This change must be done + manually before ZoneMinder will run. See the installation steps below. 2. A new permission group called "Groups" has been added. This allows the system administrator to assign "view", "edit", or "none" permission to @@ -34,9 +34,9 @@ New installs mysql -u root -p < /usr/share/zoneminder/db/zm_create.sql mysql -u root -p - mysql> grant select,insert,update,delete,lock tables,alter,create - on zm.* to 'zmuser'@localhost identified by 'zmpass'; - mysql> exit; + mysql> grant all + on zm.* to 'zmuser'@localhost identified by 'zmpass'; + mysql> exit; mysqladmin -u root -p reload The database account credentials, zmuser/zmpass, are arbitrary. Set them to @@ -47,6 +47,11 @@ New installs Change ZM_DB_USER and ZM_DB_PASS to the values you created in the previous step. + Additionally, you must also edit + /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner. + Scroll down and change login and password to the values you created in the + previous step. + 4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local timezone. PHP will complain loudly if this is not set, or if it is set incorrectly, and these complaints will show up in the zoneminder logging @@ -96,12 +101,16 @@ Upgrades Compare /etc/zm/zm.conf to /etc/zm/zm.conf.rpmnew. Verify that zm.conf contains any new config settings that may be in zm.conf.rpmnew. + Additionally, you must also edit + /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner. + Scroll down and change login and password to the values you used + previsouly. + 2. Verify permissions of the zmuser account. Over time, the database account permissions required for normal operation - have changed. Verify the zmuser database account has been granted select, - insert, update, delete, lock tables, alter, and create permission to the - ZoneMinder database: + have increased. Verify the zmuser database account has been granted all + permission to the ZoneMinder database: mysql -u root -p mysql> show grants for zmuser@localhost; diff --git a/distros/ubuntu1204/apache.conf b/distros/ubuntu1204/apache.conf index 965c67f86..262db423f 100644 --- a/distros/ubuntu1204/apache.conf +++ b/distros/ubuntu1204/apache.conf @@ -1,9 +1,21 @@ Alias /zm /usr/share/zoneminder/www - - php_flag register_globals off - Options Indexes FollowSymLinks - - DirectoryIndex index.php - - + + + Options +ExecCGI + AllowOverride All + AddHandler fcgid-script .php + FCGIWrapper /usr/bin/php5-cgi + Order allow,deny + Allow from all + + + + + php_flag register_globals off + Options Indexes FollowSymLinks + + DirectoryIndex index.php + + + diff --git a/distros/ubuntu1204_cmake/source/format b/distros/ubuntu1204_cmake/source/format index 163aaf8d8..89ae9db8f 100644 --- a/distros/ubuntu1204_cmake/source/format +++ b/distros/ubuntu1204_cmake/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff --git a/distros/ubuntu1504_cmake/README.Debian b/distros/ubuntu1504_cmake/README.Debian index 2ba809fe4..8182e0678 100644 --- a/distros/ubuntu1504_cmake/README.Debian +++ b/distros/ubuntu1504_cmake/README.Debian @@ -8,7 +8,7 @@ Initializing database OR cat /usr/share/zoneminder/db/zm_create.sql | sudo mysql --defaults-file=/etc/mysql/debian.cnf - echo 'grant lock tables,alter,create,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";'\ + echo 'grant lock tables,alter,create,index,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";'\ | sudo mysql --defaults-file=/etc/mysql/debian.cnf mysql Hint: generate secure password with `pwgen` and update "/etc/zm/zm.conf" diff --git a/distros/ubuntu1504_cmake/zoneminder.postinst b/distros/ubuntu1504_cmake/zoneminder.postinst index 4d2da7331..82b256e6b 100644 --- a/distros/ubuntu1504_cmake/zoneminder.postinst +++ b/distros/ubuntu1504_cmake/zoneminder.postinst @@ -2,6 +2,8 @@ set -e +. /etc/zm/zm.conf + if [ "$1" = "configure" ]; then chown www-data:root /var/log/zm chown www-data:www-data /var/lib/zm @@ -15,9 +17,13 @@ if [ "$1" = "configure" ]; then # Ensure zoneminder is stopped deb-systemd-invoke stop zoneminder.service || exit $? - echo 'grant lock tables, create, index, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - # Run the ZoneMinder update tool - zmupdate.pl --nointeractive + if [ "$ZM_DB_HOST" = "localhost" ]; then + echo 'grant lock tables, create, index, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + # Run the ZoneMinder update tool + zmupdate.pl --nointeractive + else + echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + fi; fi diff --git a/docs/_static/zmstyle.css b/docs/_static/zmstyle.css new file mode 100644 index 000000000..b8f0235f3 --- /dev/null +++ b/docs/_static/zmstyle.css @@ -0,0 +1,3 @@ +img { + border: 1px solid black !important; + } diff --git a/docs/_static/zmstyles.css b/docs/_static/zmstyles.css deleted file mode 100644 index 8f59f3910..000000000 --- a/docs/_static/zmstyles.css +++ /dev/null @@ -1,13 +0,0 @@ -@import url("default.css"); - -div.admonition-note { -border-top: 2px solid red; -border-bottom: 2px solid red; -border-left: 2px solid red; -border-right: 2px solid red; -background-color: #ff6347 -} - -img { - border: 1px solid black !important; -} diff --git a/docs/conf.py b/docs/conf.py index 2d376f03d..9bda5df7b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,9 @@ import sys import os +def setup(app): + app.add_stylesheet('zmstyle.css') + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -51,9 +54,9 @@ copyright = u'2014, https://github.com/ZoneMinder/ZoneMinder/graphs/contributors # built documents. # # The short X.Y version. -version = '1.28.1' +#version = '1.28.1' # The full version, including alpha/beta/rc tags. -release = '1.28.1' +#release = '1.28.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -99,13 +102,14 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' +#html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -html_theme_options = { - "stickysidebar": "true" -} +#html_theme_options = { +# "stickysidebar": "true" +#} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] @@ -130,7 +134,7 @@ html_theme_options = { # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] -html_style='zmstyles.css' +#html_style='zmstyles.css' # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/docs/installationguide/ubuntu.rst b/docs/installationguide/ubuntu.rst index b95d46a89..1d5412077 100644 --- a/docs/installationguide/ubuntu.rst +++ b/docs/installationguide/ubuntu.rst @@ -1,64 +1,466 @@ Ubuntu ====== -Option A: Install a ready made package ---------------------------------------- +.. contents:: -Installation procedure (common for all versions of Ubuntu) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Easy Way: Install ZoneMinder from a package (Ubuntu 15.x+) +----------------------------------------------------------- +These instructions are for a brand new ubuntu 15.04 system which does not have ZM installed. -It is important that you first apply any system software upgrades first to Ubuntu, especially if you have just created a new image of Ubuntu. -Not doing this may cause the PPA process to fail and complain about various unmet dependencies. - -If you also plan to install the database in the same server (which is typically the case), first do: +**Step 1**: Make sure we add the correct packages :: - sudo apt-get install mysql-server + sudo add-apt-repository ppa:iconnor/zoneminder + sudo apt-get update -This will ask you for a user and password to configure for Zoneminder. -Note that when you install the PPA, it will also create a username of zmuser and a password of zmpass irrespective of what you select at this stage - -Now add the ppa repository path: +if you don't have mysql already installed: :: - sudo apt-add-repository ppa:iconnor/zoneminder + sudo apt-get install mysql-server + +This will ask you to set up a master password for the DB (you are asked for the mysql root password when installing mysql server). + +**Step 2**: Install ZoneMinder -Once you have updated the repository then update and install the package.: - :: - sudo apt-get update - sudo apt-get install zoneminder + sudo apt-get install zoneminder +**Step 3**: Configure the Database +:: + sudo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql + mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" -Post Install steps for Ubuntu 15.x or newer (systemd) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +You don't really need this, but no harm (needed if you are upgrading) :: sudo /usr/bin/zmupdate.pl + +**Step 4**: Configure systemd to recognize ZoneMinder and configure Apache correctly: + +:: + sudo systemctl enable zoneminder sudo a2enconf zoneminder + sudo a2enmod cgi + sudo chown -R www-data:www-data /usr/share/zoneminder/ + + +We need this for API routing to work: + +:: + + sudo a2enmod rewrite + +This is probably a bug with iconnor's PPA as of Oct 3, 2015 with package 1.28.107. After installing, ``zm.conf`` does not have the right read permissions, so we need to fix that. This may go away in future PPA releases: + +:: + + sudo chown www-data:www-data /etc/zm/zm.conf + +We also need to install php5-gd (as of 1.28.107, this is not installed) + +:: + + sudo apt-get install php5-gd + +**Step 5**: Edit Timezone in PHP + +:: + + vi /etc/php5/apache2/php.ini + +Look for [Date] and inside it you will see a date.timezone +that is commented. remove the comment and specific your timezone. +Please make sure the timezone is valid (see this: http://php.net/manual/en/timezones.php) + +In my case: + +:: + + date.timezone = America/New_York + +**Step 6**: Restart services + +:: + sudo service apache2 reload - systemctl restart zoneminder + sudo systemctl restart zoneminder -You should now be able to view the zoneminder interface at ``http://localhost/zm`` (replace localhost with your server IP if you are accessing it remotely) -.. image:: images/zm_first_screen_post_install.png +**Step 7: make sure live streaming works**: Make sure you can view Monitor streams: + +startup ZM console in your browser, go to ``Options->Path`` and make sure ``PATH_ZMS`` is set to ``/zm/cgi-bin/nph-zms`` and restart ZM (you should not need to do this for packages, as this should automatically work) + + +**Step 8**: If you have changed your DB login/password from zmuser/zmpass, the API won't know about it + +If you changed the DB password **after** installing ZM, the APIs will not be able to connect to the DB. + +If you have, go to ``zoneminder/www/api/app/Config`` & Edit ``database.php`` + +There is a class there called ``DATABASE_CONFIG`` - change the ``$default`` array to reflect your new details. Example: + +:: + + public $default = array( + 'datasource' => 'Database/Mysql', + 'persistent' => false, + 'host' => 'localhost', + 'login' => 'mynewDBusername', + 'password' => 'mynewDBpassword' + 'database' => 'zm', + 'prefix' => '', + //'encoding' => 'utf8', + ); + + +You are done. Lets proceed to make sure everything works: + +Making sure ZM and APIs work: + +1. open up a browser and go to ``http://localhost/zm`` - should bring up ZM +2. (OPTIONAL - just for peace of mind) open up a tab and go to ``http://localhost/zm/api`` - should bring up a screen showing CakePHP version with some green color boxes. Green is good. If you see red, or you don't see green, there may be a problem (should not happen). Ignore any warnings in yellow saying "DebugKit" not installed. You don't need it +3. open up a tab in the same browser and go to ``http://localhost/zm/api/host/getVersion.json`` + +If it responds with something like: + +:: + + { + "version": "1.28.107", + "apiversion": "1.28.107.1" + } + + +**Then your APIs are working** + +Make sure ZM and APIs work with security: +1. Enable OPT_AUTH in ZM +2. Log out of ZM in browser +3. Open a NEW tab in the SAME BROWSER (important) and go to ``http://localhost/zm/api/host/getVersion.json`` - should give you "Unauthorized" along with a lot more of text +4. Go to another tab in the SAME BROWSER (important) and log into ZM +5. Repeat step 3 and it should give you the ZM and API version + +**Congrats** your installation is complete + + +Easy Way: Install ZoneMinder from a package (Ubuntu 14.x) +----------------------------------------------------------- +**These instructions are for a brand new ubuntu 14.x system which does not have ZM installed.** + +**Step 1:** Install ZoneMinder + +:: + + sudo add-apt-repository ppa:iconnor/zoneminder + sudo apt-get update + sudo apt-get install zoneminder + +(just press OK for the prompts you get) + +**Step 2:** Set up DB + +:: + + sudo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql + mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" + +**Step 3:** Set up Apache + +:: + + sudo a2enconf zoneminder + sudo a2enmod rewrite + sudo a2enmod cgi + +**Step 4:**:Some tweaks that will be needed: + +Edit /etc/init.d/zoneminder: + +add a ``sleep 10`` right after line 25 that reads ``echo -n "Starting $prog:"`` +(The reason we need this sleep is to make sure ZM starts after mysqld starts) + +As of Oct 3 2015, zm.conf is not readable by ZM. This is likely a bug and will go away in the next package + +:: + + sudo chown www-data:www-data /etc/zm/zm.conf + + + +**Step 5**: If you have changed your DB login/password + +If you changed the DB password **after** installing ZM, the APIs will not be able to connect to the DB. + +If you have, go to zoneminder/www/api/app/Config & Edit ``database.php`` + +There is a class there called ``DATABASE_CONFIG`` - change the ``$default`` array to reflect your new details. Example: + +:: + + public $default = array( + 'datasource' => 'Database/Mysql', + 'persistent' => false, + 'host' => 'localhost', + 'login' => 'mynewDBusername', + 'password' => 'mynewDBpassword' + 'database' => 'zm', + 'prefix' => '', + //'encoding' => 'utf8',` + ); + +We also need to install php5-gd (as of 1.28.107, this is not installed) + +:: + + sudo apt-get install php5-gd + + +**Step 6**: Edit Timezone in PHP + +vi /etc/php5/apache2/php.ini +Look for [Date] and inside it you will see a date.timezone +that is commented. remove the comment and specific your timezone. +Please make sure the timezone is valid (see [this](http://php.net/manual/en/timezones.php)) + +In my case: + +:: + + date.timezone = America/New_York + + +**Step 7: make sure live streaming works**: Make sure you can view Monitor streams: + +startup ZM console in your browser, go to ``Options->Path`` and make sure ``PATH_ZMS`` is set to ``/zm/cgi-bin/nph-zms`` and restart ZM (you should not need to do this for packages, as this should automatically work) + + + +restart: + +:: + + sudo service apache2 restart + /etc/init.d/zoneminder restart + +**Step 8**: Making sure ZM and APIs work: (optional - only if you need APIs) + +1. open up a browser and go to ``http://localhost/zm`` - should bring up ZM +2. (OPTIONAL - just for peace of mind) open up a tab and go to ``http://localhost/zm/api`` - should bring up a screen showing CakePHP version with some green color boxes. Green is good. If you see red, or you don't see green, there may be a problem (should not happen). Ignore any warnings in yellow saying "DebugKit" not installed. You don't need it +3. open up a tab in the same browser and go to ``http://localhost/zm/api/host/getVersion.json`` + +If it responds with something like: + +:: + + { + "version": "1.28.107", + "apiversion": "1.28.107.1" + } + +Then your APIs are working + +Make sure you can view Monitor View: +1. Open up ZM, configure your monitors and verify you can view Monitor feeds. +2. If not, open up ZM console in your browser, go to ``Options->Path`` and make sure ``PATH_ZMS`` is set to ``/zm/cgi-bin/nph-zms`` and restart ZM (you should not need to do this for packages, as this should automatically work) + +Make sure ZM and APIs work with security: +1. Enable OPT_AUTH in ZM +2. Log out of ZM in browser +3. Open a NEW tab in the SAME BROWSER (important) and go to ``http://localhost/zm/api/host/getVersion.json`` - should give you "Unauthorized" along with a lot more of text +4. Go to another tab in the SAME BROWSER (important) and log into ZM +5. Repeat step 3 and it should give you the ZM and API version + +**Congrats** Your installation is complete -Post install steps for Ubuntu 14.x or older (SystemV) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Harder Way: Build Package From Source +------------------------------------------- +(These instructions assume installation from source on a ubuntu 15.x+ system) + +**Step 1:** First make sure you have the needed tools + +:: + + sudo apt-get update + sudo apt-get install cmake git + +**Step 2:** Next up make sure you have all the dependencies + +:: + + sudo apt-get install apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2 libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch policykit-1 libpolkit-gobject-1-dev libextutils-pkgconfig-perl libcurl3 libvlc-dev libcurl4-openssl-dev curl php5-gd + +(you are asked for the mysql root password when installing mysql server - put in a password that you'd like). + +**Step 3:** Download ZoneMinder source code and compile+install: + +:: + + git clone https://github.com/ZoneMinder/ZoneMinder.git + cd ZoneMinder/ + git submodule init + git submodule update + cmake . + make + sudo make install + +**Step 4:** Now make sure your symlinks to events and images are set correctly: + +:: + + sudo ./zmlinkcontent.sh + +**Step 5:** Now lets make sure ZM has DB permissions to write to the DB: + +:: + + mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" + +**Step 6:** Now lets create the DB & its tables that ZM needs + +:: + + mysql -uroot -p + Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch + AllowOverride All + Require all granted + + + Alias /zm /usr/local/share/zoneminder/www + + php_flag register_globals off + Options Indexes FollowSymLinks + + DirectoryIndex index.php + + + + + AllowOverride All + + +**Step 11:** Now lets make sure ZM can read/write to the zoneminder directory: + +:: + + sudo chown -R www-data:www-data /usr/local/share/zoneminder/ + + +**Step 12:** Make sure you can view Monitor View + +1. Open up ZM, configure your monitors and verify you can view Monitor feeds +2. If not, open up ZM console in your browser, go to ``Options->Path`` and make sure ``PATH_ZMS`` is set to ``/zm/cgi-bin/nph-zms`` and restart ZM + +**Step 13**: Edit Timezone in PHP + +vi /etc/php5/apache2/php.ini +Look for [Date] and inside it you will see a date.timezone +that is commented. remove the comment and specific your timezone. +Please make sure the timezone is valid (see http://php.net/manual/en/timezones.php) + +In my case: + +:: + + date.timezone = America/New_York + +**Step 14:** Finally, lets make a config change to apache (needed for htaccess overrides to work for APIs) +Edit /etc/apache2/apache2.conf and add this: + +:: + + + AllowOverride All + Require all granted + + +Restart apache + +:: + + sudo service apache2 reload + +You are done. Lets proceed to make sure everything works: + +Making sure ZM and APIs work: + +1. open up a browser and go to ``http://localhost/zm`` - should bring up ZM +2. (OPTIONAL - just for peace of mind) open up a tab and go to ``http://localhost/zm/api`` - should bring up a screen showing CakePHP version with some green color boxes. Green is good. If you see red, or you don't see green, there may be a problem (should not happen). Ignore any warnings in yellow saying "DebugKit" not installed. You don't need it +3. open up a tab in the same browser and go to ``http://localhost/zm/api/host/getVersion.json`` + +If it responds with something like: + +:: + + { + "version": "1.28.107", + "apiversion": "1.28.107.1" + } + +Then your APIs are working + +Make sure ZM and APIs work with security: +1. Enable OPT_AUTH in ZM +2. Log out of ZM in browser +3. Open a NEW tab in the SAME BROWSER (important) and go to ``http://localhost/zm/api/host/getVersion.json`` - should give you "Unauthorized" along with a lot more of text +4. Go to another tab in the SAME BROWSER (important) and log into ZM +5. Repeat step 3 and it should give you the ZM and API version + +**Congrats** your installation is complete + Suggested changes to MySQL (Optional but recommended) -""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +------------------------------------------------------ For most of you Zoneminder will run just fine with the default MySQL settings. There are a couple of settings that may, in time, provide beneficial especially if you have a number of cameras and many events with a lot of files. One setting we recommend is the "innodb_file_per_table" This will be a default setting in MySQL 5.6 but should be added in MySQL 5.5 which comes with Ubuntu 14.04. A description can be found here: http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html To add "innodb_file_per_table" edit the my.cnf file: @@ -72,90 +474,4 @@ Save and exit. Restart MySQL ``service mysql restart`` -Adding a sleep for mysql dependency (Ubuntu 14.x and below only) -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -We recommend you add a "sleep" command just after ``start() {`` in ``/etc/init.d/zoneminder`` to make sure mysql starts before ZoneMinder does. To do this, -simply modify ``/etc/init.d/zoneminder`` at around line 25 (where you will find the start function) to look like this: - -:: - - start() { - echo -n "Making sure mysql started... Sleeping for 10 seconds..." - sleep 10 - echo -n "Starting $prog: " - -Making Apache aware of ZoneMinder -"""""""""""""""""""""""""""""""""""""""""""" - -Next, we need to make sure apache knows about zoneminder's configuration for apache. - -:: - - ln -s /etc/zm/apache.conf /etc/apache2/conf-available/zoneminder.conf - -If you are upgrading from an old version: - -:: - - sudo /usr/bin/zmupdate.pl - -Then look for ``/etc/apache2/conf-enable/zm.conf`` - if you have it, please remove it - -:: - - a2enconf zoneminder - adduser www-data video - - -lets make sure we restart apache: - -:: - - service apache2 restart - - -You should now be able to view the zoneminder interface at ``http://localhost/zm`` (replace localhost with your server IP if you are accessing it remotely) - -.. image:: images/zm_first_screen_post_install.png - - -Finally, in the zoneminder web interface, go to Options->Paths, change PATH_ZMS to ``/zm/cgi-bin/nph-zms`` - - -Option B: Build Package From Source -------------------------------------------- - -A fresh build based on master branch running Ubuntu 1204 LTS. Will likely work for other versions as well.:: - - root@host:~# aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8-dev libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libgnutls-dev libjpeg8-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch; - - root@host:~# git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder; - root@host:~# cd zoneminder; - root@host:~# ln -s distros/ubuntu1204 debian; - root@host:~# dpkg-checkbuilddeps; - root@host:~# dpkg-buildpackage; - - -One level above you'll now find a deb package matching the architecture of the build host\::: - - root@host:~# ls -1 ~/zoneminder\*; - /root/zoneminder_1.26.4-1_amd64.changes - /root/zoneminder_1.26.4-1_amd64.deb - /root/zoneminder_1.26.4-1.dsc - /root/zoneminder_1.26.4-1.tar.gz - - -The dpkg command itself does not resolve dependencies. That's what high-level interfaces like aptitude and apt-get are normally for. Unfortunately, unlike RPM, there's no easy way to install a separate deb package not contained with any repository. - -To overcome this "limitation" we'll use dpkg only to install the zoneminder package and apt-get to fetch all needed dependencies afterwards. Running dpkg-reconfigure in the end will ensure that the setup scripts e.g. for database provisioning were executed.:: - - root@host:~# dpkg -i /root/zoneminder_1.26.4-1_amd64.deb; apt-get install -f; - root@host:~# dpkg-reconfigure zoneminder; - -Alternatively you may also use gdebi to automatically resolve dependencies during installation\::: - - root@host:~# aptitude install -y gdebi; - root@host:~# gdebi /root/zoneminder_1.26.4-1_amd64.deb; - - sudo apt-get install apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg-turbo8-dev libjpeg-turbo8 apache2-mpm-prefork libapache2-mod-php5 php5-cli diff --git a/docs/userguide/mobile.rst b/docs/userguide/mobile.rst index fe8d6e418..b6feb805d 100644 --- a/docs/userguide/mobile.rst +++ b/docs/userguide/mobile.rst @@ -3,16 +3,17 @@ Mobile Devices Here are some options for using ZoneMinder on Mobile devices: -Using the existing web console -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* You can directly use the ZoneMinder interface by launching a browser and going to the ZoneMinder server just like you do on the Desktop -* ZoneMinder also has a "mobile skin" that offers limited functionality (not all views are present in this skin). You can point your mobile browser to ``http://yourzoneminderip/zm/index.php?skin=mobile`` and bookmark it - Third party mobile clients ^^^^^^^^^^^^^^^^^^^^^^^^^^^ * zmNinja (`source code `__, needs APIs to be installed to work) - * Currently in free beta testing for iOS and Android. Will be in app/play store as soon as ZM 1.29 is launched -* zmView (limited, free) and zmView Pro (more features, paid) - `website `__ + * Available in App Store and Play Store - `website `__ +* zmView (limited, free) and zmView Pro (more features, paid) + * Available in App Store and Play Store, relies on ZM skins `website `__ + +Using the existing web console +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +* You can directly use the ZoneMinder interface by launching a browser and going to the ZoneMinder server just like you do on the Desktop +* ZoneMinder also has a "mobile skin" that offers limited functionality (not all views are present in this skin). You can point your mobile browser to ``http://yourzoneminderip/zm/index.php?skin=mobile`` and bookmark it. **Note however that 1.29 is the last release that will support the mobile skin. It's use is deprecated** Discontinued clients ^^^^^^^^^^^^^^^^^^^^ diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 3bcdd8429..7e0c11a21 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -357,7 +357,23 @@ our @options = type => $types{boolean}, category => "system", }, - # PP - Google reCaptcha settings + { + name => "ZM_OPT_USE_API", + default => "yes", + description => "Enable ZoneMinder APIs", + help => qqq(" + ZoneMinder now features a new API using which 3rd party + applications can interact with ZoneMinder data. It is + STRONGLY recommended that you enable authentication along + with APIs. Note that the APIs return sensitive data like + Monitor access details which are configured as JSON objects. + Which is why we recommend you enabling authentication, especially + if you are exposing your ZM instance on the Internet. + "), + type => $types{boolean}, + category => "system", + }, +# PP - Google reCaptcha settings { name => "ZM_OPT_USE_GOOG_RECAPTCHA", default => "no", @@ -410,6 +426,7 @@ our @options = type => $types {string}, category => "system", }, + { name => "ZM_DIR_EVENTS", diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm index 050e2bb75..d7c669583 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/TVIP862.pm @@ -138,6 +138,30 @@ sub open ."'" ); $self->{ua}->credentials($ADDRESS,$REALM,$USERNAME,$PASSWORD); + + # Detect REALM + my $req = HTTP::Request->new( GET=>"http://".$ADDRESS."/cgi/ptdc.cgi" ); + my $res = $self->{ua}->request($req); + + if ( ! $res->is_success ) { + Debug("Need newer REALM"); + if ( $res->status_line() eq '401 Unauthorized' ) { + my $headers = $res->headers(); + foreach my $k ( keys %$headers ) { + Debug("Initial Header $k => $$headers{$k}"); + } # end foreach + if ( $$headers{'www-authenticate'} ) { + my ( $auth, $tokens ) = $$headers{'www-authenticate'} =~ /^(\w+)\s+(.*)$/; + if ( $tokens =~ /\w+="([^"]+)"/i ) { + $REALM = $1; + Debug( "Changing REALM to $REALM" ); + $self->{ua}->credentials($ADDRESS,$REALM,$USERNAME,$PASSWORD); + } # end if + } else { + Debug("No headers line"); + } # end if headers + } # end if $res->status_line() eq '401 Unauthorized' + } # end if ! $res->is_success } sub close diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index e9f4a2dc2..969c72cb6 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -1044,7 +1044,7 @@ if ( $version ) foreach my $patch ( @files ) { my ( $v ) = $patch =~ /^zm_update\-([\d\.]+)\.sql$/; #PP make sure we use version compare - if ( version->parse($v) ge version->parse($version) ) { + if ( version->parse('v' . $v) > version->parse('v' . $version) ) { print( "Upgrading DB to $v from $version\n" ); patchDB( $dbh, $v ); if ( $dbh->errstr() ) { diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 1aba5c183..80e80cf18 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -4355,21 +4355,24 @@ void MonitorStream::runStream() char *swap_path = 0; bool buffered_playback = false; + + // 15 is the max length for the swap path suffix, /zmswap-whatever, assuming max 6 digits for monitor id + const int max_swap_len_suffix = 15; + int swap_path_length = strlen(config.path_swap)+1; // +1 for NULL terminator if ( connkey && playback_buffer > 0 ) { - if ( swap_path_length + 15 > PATH_MAX ) { - // 15 is for /zmswap-whatever, assuming max 6 digits for monitor id - Error( "Swap Path is too long. %d > %d ", swap_path_length+15, PATH_MAX ); + if ( swap_path_length + max_swap_len_suffix > PATH_MAX ) { + Error( "Swap Path is too long. %d > %d ", swap_path_length+max_swap_len_suffix, PATH_MAX ); } else { - swap_path = (char *)malloc( swap_path_length+15 ); + swap_path = (char *)malloc( swap_path_length+max_swap_len_suffix ); Debug( 3, "Checking swap image path %s", config.path_swap ); strncpy( swap_path, config.path_swap, swap_path_length ); if ( checkSwapPath( swap_path, false ) ) { - snprintf( &(swap_path[swap_path_length]), sizeof(swap_path)-swap_path_length, "/zmswap-m%d", monitor->Id() ); + snprintf( &(swap_path[swap_path_length]), max_swap_len_suffix, "/zmswap-m%d", monitor->Id() ); if ( checkSwapPath( swap_path, true ) ) { - snprintf( &(swap_path[swap_path_length]), sizeof(swap_path)-swap_path_length, "/zmswap-q%06d", connkey ); + snprintf( &(swap_path[swap_path_length]), max_swap_len_suffix, "/zmswap-q%06d", connkey ); if ( checkSwapPath( swap_path, true ) ) { buffered_playback = true; } diff --git a/src/zm_remote_camera.cpp b/src/zm_remote_camera.cpp index 608311649..8ac4a51ba 100644 --- a/src/zm_remote_camera.cpp +++ b/src/zm_remote_camera.cpp @@ -71,7 +71,7 @@ void RemoteCamera::Initialise() } mNeedAuth = false; - mAuthenticator = new Authenticator(username,password); + mAuthenticator = new zm::Authenticator(username,password); struct addrinfo hints; memset(&hints, 0, sizeof(hints)); diff --git a/src/zm_remote_camera.h b/src/zm_remote_camera.h index 44c00bf65..7e3ae79a8 100644 --- a/src/zm_remote_camera.h +++ b/src/zm_remote_camera.h @@ -50,7 +50,7 @@ protected: // fill required fields and set needAuth // subsequent requests can set the required authentication header. bool mNeedAuth; - Authenticator* mAuthenticator; + zm::Authenticator* mAuthenticator; protected: struct addrinfo *hp; diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index 44004564f..440c24e05 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -306,7 +306,7 @@ int RemoteCameraHttp::GetResponse() std::string Header = header; mAuthenticator->checkAuthResponse(Header); - if ( mAuthenticator->auth_method() == AUTH_DIGEST ) { + if ( mAuthenticator->auth_method() == zm::AUTH_DIGEST ) { Debug( 2, "Need Digest Authentication" ); request = stringtf( "GET %s HTTP/%s\r\n", path.c_str(), config.http_version ); request += stringtf( "User-Agent: %s/%s\r\n", config.http_ua, ZM_VERSION ); @@ -750,7 +750,7 @@ Debug(3, "Need more data buffer %d < content length %d", buffer.size(), content_ Debug(2, "Checking for digest auth in %s", authenticate_header ); mAuthenticator->checkAuthResponse(Header); - if ( mAuthenticator->auth_method() == AUTH_DIGEST ) { + if ( mAuthenticator->auth_method() == zm::AUTH_DIGEST ) { Debug( 2, "Need Digest Authentication" ); request = stringtf( "GET %s HTTP/%s\r\n", path.c_str(), config.http_version ); request += stringtf( "User-Agent: %s/%s\r\n", config.http_ua, ZM_VERSION ); diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index 0dbcb7329..7ac80e9b6 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -203,9 +203,9 @@ RtspThread::RtspThread( int id, RtspMethod method, const std::string &protocol, mNeedAuth = false; StringVector parts = split(auth,":"); if (parts.size() > 1) - mAuthenticator = new Authenticator(parts[0], parts[1]); + mAuthenticator = new zm::Authenticator(parts[0], parts[1]); else - mAuthenticator = new Authenticator(parts[0], ""); + mAuthenticator = new zm::Authenticator(parts[0], ""); } RtspThread::~RtspThread() diff --git a/src/zm_rtsp.h b/src/zm_rtsp.h index 92b675324..6e247b7cf 100644 --- a/src/zm_rtsp.h +++ b/src/zm_rtsp.h @@ -65,7 +65,7 @@ private: // subsequent requests can set the required authentication header. bool mNeedAuth; int respCode; - Authenticator* mAuthenticator; + zm::Authenticator* mAuthenticator; std::string mHttpSession; ///< Only for RTSP over HTTP sessions diff --git a/src/zm_rtsp_auth.cpp b/src/zm_rtsp_auth.cpp index fd9087afa..10ecf3475 100644 --- a/src/zm_rtsp_auth.cpp +++ b/src/zm_rtsp_auth.cpp @@ -24,6 +24,8 @@ #include #include +namespace zm { + Authenticator::Authenticator(std::string &username, std::string password) { #ifdef HAVE_GCRYPT_H // Special initialisation for libgcrypt @@ -227,3 +229,5 @@ void Authenticator::checkAuthResponse(std::string &response) { Debug( 2, "Didn't find auth line in %s", authLine.c_str()); } } + +} // namespace zm diff --git a/src/zm_rtsp_auth.h b/src/zm_rtsp_auth.h index 23745f9c7..079dec639 100644 --- a/src/zm_rtsp_auth.h +++ b/src/zm_rtsp_auth.h @@ -32,6 +32,8 @@ #include #endif // HAVE_GCRYPT_H || HAVE_LIBCRYPTO +namespace zm { + enum AuthMethod { AUTH_UNDEFINED = 0, AUTH_BASIC = 1, AUTH_DIGEST = 2 }; class Authenticator { public: @@ -62,4 +64,6 @@ private: int nc; }; +} // namespace zm + #endif // ZM_RTSP_AUTH_H diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 30a420bb1..c66638759 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -18,6 +18,10 @@ // #include +#include +#include +#include +#include #include "zm.h" #include "zm_mpeg.h" @@ -286,6 +290,23 @@ void StreamBase::openComms() { if ( connkey > 0 ) { + + snprintf( sock_path_lock, sizeof(sock_path_lock), "%s/zms-%06d.lock", config.path_socks, connkey); + + lock_fd = open(sock_path_lock, O_CREAT|O_WRONLY, S_IRUSR | S_IWUSR); + if (lock_fd <= 0 || flock(lock_fd, LOCK_EX) != 0) + { + Error("Unable to lock sock lock file %s: %s", sock_path_lock, strerror(errno) ); + + close(lock_fd); + lock_fd = 0; + } + else + { + Debug( 1, "We have obtained a lock on %s fd: %d", sock_path_lock, lock_fd); + } + + sd = socket( AF_UNIX, SOCK_DGRAM, 0 ); if ( sd < 0 ) { @@ -321,6 +342,11 @@ void StreamBase::closeComms() { unlink( loc_sock_path ); } + if (lock_fd > 0) + { + close(lock_fd); //close it rather than unlock it incase it got deleted. + unlink(sock_path_lock); + } } } diff --git a/src/zm_stream.h b/src/zm_stream.h index edab321d8..3f876ad8c 100644 --- a/src/zm_stream.h +++ b/src/zm_stream.h @@ -77,6 +77,8 @@ protected: struct sockaddr_un loc_addr; char rem_sock_path[PATH_MAX]; struct sockaddr_un rem_addr; + char sock_path_lock[PATH_MAX]; + int lock_fd; protected: bool paused; @@ -126,6 +128,7 @@ public: connkey = 0; sd = -1; + lock_fd = 0; memset( &loc_sock_path, 0, sizeof(loc_sock_path) ); memset( &loc_addr, 0, sizeof(loc_addr) ); memset( &rem_sock_path, 0, sizeof(rem_sock_path) ); diff --git a/version b/version index ca2c9c84c..a960d2a6d 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.28.108 +1.28.109 diff --git a/web/api/app/Controller/AppController.php b/web/api/app/Controller/AppController.php index 1d85115e8..5b39597b3 100644 --- a/web/api/app/Controller/AppController.php +++ b/web/api/app/Controller/AppController.php @@ -34,7 +34,7 @@ class AppController extends Controller { use CrudControllerTrait; public $components = [ - 'Session', // PP - We are going to use SessionHelper to check PHP session vars + 'Session', // We are going to use SessionHelper to check PHP session vars 'RequestHandler', 'Crud.Crud' => [ 'actions' => [ @@ -49,7 +49,7 @@ class AppController extends Controller { ] ]; - //PP - Global beforeFilter function + // Global beforeFilter function //Zoneminder sets the username session variable // to the logged in user. If this variable is set // then you are logged in @@ -58,14 +58,62 @@ class AppController extends Controller { // Also checking to do this only if ZM_OPT_USE_AUTH is on public function beforeFilter() { $this->loadModel('Config'); + + $options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_API')); + $config = $this->Config->find('first', $options); + $zmOptApi = $config['Config']['Value']; + + if ($zmOptApi !='1') + { + throw new UnauthorizedException(__('API Disabled')); + return; + } + $options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')); $config = $this->Config->find('first', $options); $zmOptAuth = $config['Config']['Value']; if (!$this->Session->Read('user.Username') && ($zmOptAuth=='1')) { - throw new NotFoundException(__('Not Authenticated')); + throw new UnauthorizedException(__('Not Authenticated')); return; } + else + { + $this->loadModel('User'); + $loggedinUser = $this->Session->Read('user.Username'); + $isEnabled = $this->Session->Read('user.Enabled'); + // this will likely never happen as if its + // not enabled, login will fail and Not Auth will be returned + // however, keeping this here for now + if ($isEnabled != "1" && $zmOptAuth=="1") + { + throw new UnauthorizedException(__('User is not enabled')); + return; + } + + if ($zmOptAuth=='1') + { + $options = array ('conditions' => array ('User.Username' => $loggedinUser)); + $userMonitors = $this->User->find('first', $options); + $this->Session->Write('allowedMonitors',$userMonitors['User']['MonitorIds']); + $this->Session->Write('streamPermission',$userMonitors['User']['Stream']); + $this->Session->Write('eventPermission',$userMonitors['User']['Events']); + $this->Session->Write('controlPermission',$userMonitors['User']['Control']); + $this->Session->Write('systemPermission',$userMonitors['User']['System']); + $this->Session->Write('monitorPermission',$userMonitors['User']['Monitors']); + } + else // if auth is not on, you can do everything + { + //$userMonitors = $this->User->find('first', $options); + $this->Session->Write('allowedMonitors',''); + $this->Session->Write('streamPermission','View'); + $this->Session->Write('eventPermission','Edit'); + $this->Session->Write('controlPermission','Edit'); + $this->Session->Write('systemPermission','Edit'); + $this->Session->Write('monitorPermission','Edit'); + } + } + } diff --git a/web/api/app/Controller/Component/ImageComponent.php b/web/api/app/Controller/Component/ImageComponent.php index 68a254031..f8ed7a533 100644 --- a/web/api/app/Controller/Component/ImageComponent.php +++ b/web/api/app/Controller/Component/ImageComponent.php @@ -48,7 +48,7 @@ class ImageComponent extends Component { $imageFile = $config['ZM_DIR_EVENTS']."/".$imagePath; //$thumbFile = ZM_DIR_EVENTS."/".$thumbPath; $thumbFile = $thumbPath; - // PP: This segment of code results in errors when trying to get Events API + // This segment of code results in errors when trying to get Events API // This actually seems to be generating images for the angular UI web view // and should not be a part of the API anyway // I've commented it so events APIs continue to work diff --git a/web/api/app/Controller/ConfigsController.php b/web/api/app/Controller/ConfigsController.php index e70978246..48f50ae8e 100644 --- a/web/api/app/Controller/ConfigsController.php +++ b/web/api/app/Controller/ConfigsController.php @@ -15,7 +15,7 @@ class ConfigsController extends AppController { public $components = array('RequestHandler'); /** - * PP - resolves the issue of not returning all config parameters + * resolves the issue of not returning all config parameters * refer https://github.com/ZoneMinder/ZoneMinder/issues/953 * index method * diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index 5f88fbfc1..ef569cd7b 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -14,6 +14,17 @@ class EventsController extends AppController { */ public $components = array('RequestHandler', 'Scaler', 'Image', 'Paginator'); +public function beforeFilter() { + parent::beforeFilter(); + $canView = $this->Session->Read('eventPermission'); + if ($canView =='None') + { + throw new UnauthorizedException(__('Insufficient Privileges')); + return; + } + +} + /** * index method * @@ -22,6 +33,18 @@ class EventsController extends AppController { */ public function index() { $this->Event->recursive = -1; + + $allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY); + + if (!empty($allowedMonitors)) + { + $mon_options = array('Event.MonitorId' => $allowedMonitors); + } + else + { + $mon_options=''; + } + if ($this->request->params['named']) { $this->FilterComponent = $this->Components->load('Filter'); @@ -39,7 +62,7 @@ class EventsController extends AppController { $this->Paginator->settings = array( // https://github.com/ZoneMinder/ZoneMinder/issues/995 // 'limit' => $limit['ZM_WEB_EVENTS_PER_PAGE'], - // PP - 25 events per page which is what the above + // 25 events per page which is what the above // default is, is way too low for an API // changing this to 100 so we don't kill ZM // with many event APIs. In future, we can @@ -49,14 +72,14 @@ class EventsController extends AppController { 'limit' => '100', 'order' => array('StartTime', 'MaxScore'), 'paramType' => 'querystring', - 'conditions' => $conditions + 'conditions' => array (array($conditions, $mon_options)) ); $events = $this->Paginator->paginate('Event'); // For each event, get its thumbnail data (path, width, height) foreach ($events as $key => $value) { - // PP - $thumbData = $this->createThumbnail($value['Event']['Id']); - $thumbData =""; + //$thumbData = $this->createThumbnail($value['Event']['Id']); + $thumbData = ""; $events[$key]['thumbData'] = $thumbData; } @@ -71,29 +94,55 @@ class EventsController extends AppController { * @param string $id * @return void */ - public function view($id = null) { - $this->loadModel('Config'); - $configs = $this->Config->find('list', array( - 'fields' => array('Name', 'Value'), - 'conditions' => array('Name' => array('ZM_DIR_EVENTS')) - )); + public function view($id = null) +{ + $this->loadModel('Config'); + $configs = $this->Config->find('list', array( + 'fields' => array('Name', 'Value'), + 'conditions' => array('Name' => array('ZM_DIR_EVENTS')) + )); - $this->Event->recursive = 1; - if (!$this->Event->exists($id)) { - throw new NotFoundException(__('Invalid event')); - } - $options = array('conditions' => array('Event.' . $this->Event->primaryKey => $id)); - $event = $this->Event->find('first', $options); + $this->Event->recursive = 1; + if (!$this->Event->exists($id)) { + throw new NotFoundException(__('Invalid event')); + } + + $allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY); + + if (!empty($allowedMonitors)) + { + $mon_options = array('Event.MonitorId' => $allowedMonitors); + } + else + { + $mon_options=''; + } - $path = $configs['ZM_DIR_EVENTS'].'/'.$this->Image->getEventPath($event).'/'; + $options = array('conditions' => array(array('Event.' . $this->Event->primaryKey => $id), $mon_options)); + $event = $this->Event->find('first', $options); - $event['Event']['BasePath'] = $path; + $path = $configs['ZM_DIR_EVENTS'].'/'.$this->Image->getEventPath($event).'/'; + $event['Event']['BasePath'] = $path; + + # Get the previous and next events for any monitor + $this->Event->id = $id; + $event_neighbors = $this->Event->find('neighbors'); + $event['Event']['Next'] = $event_neighbors['next']['Event']['Id']; + $event['Event']['Prev'] = $event_neighbors['prev']['Event']['Id']; + + # Also get the previous and next events for the same monitor + $event_monitor_neighbors = $this->Event->find('neighbors', array( + 'conditions'=>array('Event.MonitorId'=>$event['Event']['MonitorId']) + )); + $event['Event']['NextOfMonitor'] = $event_monitor_neighbors['next']['Event']['Id']; + $event['Event']['PrevOfMonitor'] = $event_monitor_neighbors['prev']['Event']['Id']; + + $this->set(array( + 'event' => $event, + '_serialize' => array('event') + )); + } - $this->set(array( - 'event' => $event, - '_serialize' => array('event') - )); - } /** * add method @@ -101,6 +150,13 @@ class EventsController extends AppController { * @return void */ public function add() { + + if ($this->Session->Read('eventPermission') != 'Edit') + { + throw new UnauthorizedException(__('Insufficient privileges')); + return; + } + if ($this->request->is('post')) { $this->Event->create(); if ($this->Event->save($this->request->data)) { @@ -119,6 +175,13 @@ class EventsController extends AppController { * @return void */ public function edit($id = null) { + + if ($this->Session->Read('eventPermission') != 'Edit') + { + throw new UnauthorizedException(__('Insufficient privileges')); + return; + } + $this->Event->id = $id; if (!$this->Event->exists($id)) { @@ -145,15 +208,19 @@ class EventsController extends AppController { * @return void */ public function delete($id = null) { + if ($this->Session->Read('eventPermission') != 'Edit') + { + throw new UnauthorizedException(__('Insufficient privileges')); + return; + } $this->Event->id = $id; if (!$this->Event->exists()) { throw new NotFoundException(__('Invalid event')); } $this->request->allowMethod('post', 'delete'); if ($this->Event->delete()) { - // PP - lets make sure the frame table entry is removed too - $this->loadModel('Frame'); - $this->Frame->delete(); + //$this->loadModel('Frame'); + //$this->Event->Frame->delete(); return $this->flash(__('The event has been deleted.'), array('action' => 'index')); } else { return $this->flash(__('The event could not be deleted. Please, try again.'), array('action' => 'index')); diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php index ee5ecd30f..57b210a7e 100644 --- a/web/api/app/Controller/HostController.php +++ b/web/api/app/Controller/HostController.php @@ -101,7 +101,10 @@ class HostController extends AppController { function getVersion() { $version = Configure::read('ZM_VERSION'); - $apiversion = Configure::read('ZM_API_VERSION'); + // not going to use the ZM_API_VERSION + // requires recompilation and dependency on ZM upgrade + //$apiversion = Configure::read('ZM_API_VERSION'); + $apiversion = '1.0'; $this->set(array( 'version' => $version, diff --git a/web/api/app/Controller/MonitorsController.php b/web/api/app/Controller/MonitorsController.php index 3aeb31aa8..9ab7461f9 100644 --- a/web/api/app/Controller/MonitorsController.php +++ b/web/api/app/Controller/MonitorsController.php @@ -16,6 +16,19 @@ class MonitorsController extends AppController { */ public $components = array('Paginator', 'RequestHandler'); + +public function beforeFilter() { + parent::beforeFilter(); + $canView = $this->Session->Read('monitorPermission'); + if ($canView =='None') + { + throw new UnauthorizedException(__('Insufficient Privileges')); + return; + } + +} + + /** * index method * @@ -23,7 +36,17 @@ class MonitorsController extends AppController { */ public function index() { $this->Monitor->recursive = 0; - $monitors = $this->Monitor->find('all'); + $allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY); + + if (!empty($allowedMonitors)) + { + $options = array('conditions'=>array('Monitor.Id'=> $allowedMonitors)); + } + else + { + $options=''; + } + $monitors = $this->Monitor->find('all',$options); $this->set(array( 'monitors' => $monitors, '_serialize' => array('monitors') @@ -42,7 +65,21 @@ class MonitorsController extends AppController { if (!$this->Monitor->exists($id)) { throw new NotFoundException(__('Invalid monitor')); } - $options = array('conditions' => array('Monitor.' . $this->Monitor->primaryKey => $id)); + $allowedMonitors=preg_split ('@,@', $this->Session->Read('allowedMonitors'),NULL, PREG_SPLIT_NO_EMPTY); + if (!empty($allowedMonitors)) + { + $restricted = array('Monitor.' . $this->Monitor->primaryKey => $allowedMonitors); + } + else + { + $restricted = ''; + } + + $options = array('conditions' => array( + array('Monitor.' . $this->Monitor->primaryKey => $id), + $restricted + ) + ); $monitor = $this->Monitor->find('first', $options); $this->set(array( 'monitor' => $monitor, @@ -57,6 +94,13 @@ class MonitorsController extends AppController { */ public function add() { if ($this->request->is('post')) { + + if ($this->Session->Read('systemPermission') != 'Edit') + { + throw new UnauthotizedException(__('Insufficient privileges')); + return; + } + $this->Monitor->create(); if ($this->Monitor->save($this->request->data)) { $this->daemonControl($this->Monitor->id, 'start', $this->request->data); @@ -78,7 +122,11 @@ class MonitorsController extends AppController { if (!$this->Monitor->exists($id)) { throw new NotFoundException(__('Invalid monitor')); } - + if ($this->Session->Read('systemPermission') != 'Edit') + { + throw new UnauthorizedException(__('Insufficient privileges')); + return; + } if ($this->Monitor->save($this->request->data)) { $message = 'Saved'; } else { @@ -89,9 +137,8 @@ class MonitorsController extends AppController { 'message' => $message, '_serialize' => array('message') )); - // PP - restart this monitor after change - $this->daemonControl($this->Monitor->id, 'restart', $this->request->data); - + // - restart this monitor after change + $this->daemonControl($this->Monitor->id, 'restart', $this->request->data); } /** @@ -106,6 +153,11 @@ class MonitorsController extends AppController { if (!$this->Monitor->exists()) { throw new NotFoundException(__('Invalid monitor')); } + if ($this->Session->Read('systemPermission') != 'Edit') + { + throw new UnauthorizedException(__('Insufficient privileges')); + return; + } $this->request->allowMethod('post', 'delete'); $this->daemonControl($this->Monitor->id, 'stop'); diff --git a/web/api/app/Model/User.php b/web/api/app/Model/User.php new file mode 100644 index 000000000..8ef18d131 --- /dev/null +++ b/web/api/app/Model/User.php @@ -0,0 +1,31 @@ + array( + 'Help' => "This field has certain limitations when used for non-local devices.~~ ". + "Failure to adhere to these limitations will cause a delay in live video, irregular frame skipping, ". + "and missed events~~". + "For streaming IP cameras, do not use this field to reduce the frame rate. Set the frame rate in the". + " camera, instead. You can, however, use a value that is slightly higher than the frame rate in the camera. ". + "In this case, this helps keep the cpu from being overtaxed in the event of a network problem.~~". + "Some, mostly older, IP cameras support snapshot mode. In this case ZoneMinder is actively polling the camera ". + "for new images. In this case, it is safe to use thie field." ), // 'LANG_DEFAULT' => array( diff --git a/web/skins/classic/includes/config.php b/web/skins/classic/includes/config.php index d586f90c8..459bbc587 100644 --- a/web/skins/classic/includes/config.php +++ b/web/skins/classic/includes/config.php @@ -40,6 +40,7 @@ $scales = array( "50" => "1/2x", "33" => "1/3x", "25" => "1/4x", + "12.5" => "1/8x", ); $bwArray = array( diff --git a/web/skins/classic/js/dark.js b/web/skins/classic/js/dark.js index 8868c8ce7..f8867feda 100644 --- a/web/skins/classic/js/dark.js +++ b/web/skins/classic/js/dark.js @@ -42,13 +42,13 @@ var popupSizes = { 'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 100 }, 'frames': { 'width': 500, 'height': 600 }, 'function': { 'width': 300, 'height': 92 }, - 'group': { 'width': 360, 'height': 180 }, - 'groups': { 'width': 440, 'height': 220 }, + 'group': { 'width': 360, 'height': 300 }, + 'groups': { 'width': 540, 'height': 420 }, 'image': { 'addWidth': 48, 'addHeight': 80 }, 'log': { 'width': 1080, 'height': 720 }, 'login': { 'width': 720, 'height': 480 }, 'logout': { 'width': 260, 'height': 100 }, - 'monitor': { 'width': 450, 'height': 440 }, + 'monitor': { 'width': 525, 'height': 700 }, 'monitorpreset':{ 'width': 440, 'height': 200 }, 'monitorprobe': { 'width': 500, 'height': 240 }, 'monitorselect':{ 'width': 160, 'height': 200 }, diff --git a/web/skins/classic/js/flat.js b/web/skins/classic/js/flat.js index 8f8d2f1fc..c60607d63 100644 --- a/web/skins/classic/js/flat.js +++ b/web/skins/classic/js/flat.js @@ -42,13 +42,13 @@ var popupSizes = { 'frame': { 'addWidth': 32, 'minWidth': 384, 'addHeight': 100 }, 'frames': { 'width': 500, 'height': 600 }, 'function': { 'width': 300, 'height': 140 }, - 'group': { 'width': 360, 'height': 180 }, - 'groups': { 'width': 440, 'height': 220 }, + 'group': { 'width': 360, 'height': 300 }, + 'groups': { 'width': 540, 'height': 420 }, 'image': { 'addWidth': 48, 'addHeight': 80 }, 'log': { 'width': 1080, 'height': 720 }, 'login': { 'width': 720, 'height': 480 }, 'logout': { 'width': 260, 'height': 100 }, - 'monitor': { 'width': 450, 'height': 440 }, + 'monitor': { 'width': 525, 'height': 700 }, 'monitorpreset':{ 'width': 440, 'height': 200 }, 'monitorprobe': { 'width': 500, 'height': 240 }, 'monitorselect':{ 'width': 160, 'height': 200 }, diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 3f7db2d29..85d0f0a5b 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -689,9 +689,19 @@ switch ( $tab ) - - +  () +  () + + + + diff --git a/web/views/image.php b/web/views/image.php index 80377599f..de8205f76 100644 --- a/web/views/image.php +++ b/web/views/image.php @@ -40,6 +40,21 @@ if ( !canView( 'Events' ) ) header( 'Content-type: image/jpeg' ); +// Compatibility for PHP 5.4 +if (!function_exists('imagescale')) +{ + function imagescale($image, $new_width, $new_height = -1, $mode = 0) + { + $mode; // Not supported + + $new_height = ($new_height == -1) ? imagesy($image) : $new_height; + $imageNew = imagecreatetruecolor($new_width, $new_height); + imagecopyresampled($imageNew, $image, 0, 0, 0, 0, (int)$new_width, (int)$new_height, imagesx($image), imagesy($image)); + + return $imageNew; + } +} + $errorText = false; if ( empty($_REQUEST['path']) ) {