diff --git a/Makefile.in b/Makefile.in index e337b66a5..11f984135 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.7 from Makefile.am. +# Makefile.in generated by automake 1.7.8 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -163,10 +163,10 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \ all-recursive install-data-recursive install-exec-recursive \ installdirs-recursive install-recursive uninstall-recursive \ check-recursive installcheck-recursive -DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ - Makefile.in NEWS TODO aclocal.m4 config.h.in configure \ - configure.in depcomp install-sh missing mkinstalldirs \ - zmconfig.pl.in +DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure AUTHORS \ + COPYING ChangeLog INSTALL Makefile.am NEWS TODO aclocal.m4 \ + config.h.in configure configure.in depcomp install-sh missing \ + mkinstalldirs zmconfig.pl.in DIST_SUBDIRS = $(SUBDIRS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -307,9 +307,15 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ + if (etags --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + else \ + include_option=--include; \ + fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + test -f $$subdir/TAGS && \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ @@ -363,9 +369,11 @@ distdir: $(DISTFILES) mkdir $(distdir) $(mkinstalldirs) $(distdir)/. @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ @@ -419,13 +427,12 @@ distcheck: dist $(am__remove_distdir) GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/=build - mkdir $(distdir)/=inst + mkdir $(distdir)/_build + mkdir $(distdir)/_inst chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && $(mkinstalldirs) $$dc_destdir \ - && cd $(distdir)/=build \ + && cd $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ @@ -437,7 +444,9 @@ distcheck: dist && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ - && ({ $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && ({ \ + (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ @@ -450,7 +459,7 @@ distcheck: dist @echo "$(distdir).tar.gz is ready for distribution" | \ sed 'h;s/./=/g;p;x;p;x' distuninstallcheck: - cd $(distuninstallcheck_dir) \ + @cd $(distuninstallcheck_dir) \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ @@ -459,11 +468,11 @@ distuninstallcheck: $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean - if test '$(srcdir)' = . ; then \ + @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi - test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 @@ -493,7 +502,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -504,6 +513,7 @@ clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr distclean-tags dvi: dvi-recursive @@ -528,7 +538,8 @@ installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf autom4te.cache + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive diff --git a/config.h.in b/config.h.in index a0d6de810..d9c5da300 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.in by autoheader. */ +/* Define to 1 if you have the declaration of `MD5', and to 0 if you don't. */ +#undef HAVE_DECL_MD5 + /* Define to 1 if you have the declaration of `round', and to 0 if you don't. */ #undef HAVE_DECL_ROUND @@ -17,6 +20,9 @@ /* Define to 1 if you have the `avformat' library (-lavformat). */ #undef HAVE_LIBAVFORMAT +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#undef HAVE_LIBCRYPTO + /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL diff --git a/configure b/configure index 0a5bbefdc..becb7428d 100755 --- a/configure +++ b/configure @@ -4540,6 +4540,70 @@ _ACEOF fi +echo "$as_me:$LINENO: checking whether MD5 is declared" >&5 +echo $ECHO_N "checking whether MD5 is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_MD5+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef MD5 + char *p = (char *) MD5; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_MD5=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_MD5=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_MD5" >&5 +echo "${ECHO_T}$ac_cv_have_decl_MD5" >&6 +if test $ac_cv_have_decl_MD5 = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MD5 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MD5 0 +_ACEOF + + +fi + + echo "$as_me:$LINENO: checking for jpeg_start_compress in -ljpeg" >&5 echo $ECHO_N "checking for jpeg_start_compress in -ljpeg... $ECHO_C" >&6 @@ -4813,6 +4877,73 @@ echo "$as_me: error: zm requires libmysqlclient.a" >&2;} fi +echo "$as_me:$LINENO: checking for MD5 in -lcrypto" >&5 +echo $ECHO_N "checking for MD5 in -lcrypto... $ECHO_C" >&6 +if test "${ac_cv_lib_crypto_MD5+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char MD5 (); +int +main () +{ +MD5 (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_crypto_MD5=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_crypto_MD5=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_MD5" >&5 +echo "${ECHO_T}$ac_cv_lib_crypto_MD5" >&6 +if test $ac_cv_lib_crypto_MD5 = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCRYPTO 1 +_ACEOF + + LIBS="-lcrypto $LIBS" + +else + { echo "$as_me:$LINENO: WARNING: libcrypto.a is required for authenticated streaming" >&5 +echo "$as_me: WARNING: libcrypto.a is required for authenticated streaming" >&2;} +fi + + echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6 if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then diff --git a/configure.in b/configure.in index dbb80264f..222b35578 100644 --- a/configure.in +++ b/configure.in @@ -117,10 +117,12 @@ AC_CHECK_HEADERS(pcre/pcre.h,,,) AC_CHECK_HEADERS(pcre.h,,,) AC_CHECK_DECLS(round,,,[#include ]) AC_CHECK_DECLS(strsignal,,,[#include ]) +AC_CHECK_DECLS(MD5,,,[#include ]) AC_CHECK_LIB(jpeg,jpeg_start_compress,,AC_MSG_ERROR(zm requires libjpeg.a)) AC_CHECK_LIB(z,compress,,AC_MSG_ERROR(zm requires libz.a)) AC_CHECK_LIB(dl,dlsym,,AC_MSG_ERROR(zm requires libdl.a)) AC_CHECK_LIB(mysqlclient,mysql_init,,AC_MSG_ERROR(zm requires libmysqlclient.a)) +AC_CHECK_LIB(crypto,MD5,,AC_MSG_WARN(libcrypto.a is required for authenticated streaming)) AC_CHECK_LIB(pcre,pcre_compile,,AC_MSG_WARN(libpcre.a is required for remote/network camera support)) AC_CHECK_LIB(avcodec,avcodec_init,,AC_MSG_WARN(libavcodec.a is required for MPEG streaming)) AC_CHECK_LIB(avformat,av_new_stream,,AC_MSG_WARN(libavformat.a is required for MPEG streaming),-lavcodec) diff --git a/db/Makefile.in b/db/Makefile.in index 219147557..49356b303 100644 --- a/db/Makefile.in +++ b/db/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.7 from Makefile.am. +# Makefile.in generated by automake 1.7.8 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -150,11 +150,12 @@ EXTRA_DIST = \ zmalter-1.19.5.sql subdir = db +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = DIST_SOURCES = -DIST_COMMON = Makefile.am Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am all: all-am .SUFFIXES: @@ -177,9 +178,11 @@ distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ @@ -205,7 +208,6 @@ check: check-am all-am: Makefile installdirs: - install: install-am install-exec: install-exec-am install-data: install-data-am @@ -225,7 +227,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -235,7 +237,7 @@ clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am - + -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am @@ -257,7 +259,7 @@ install-man: installcheck-am: maintainer-clean: maintainer-clean-am - + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am diff --git a/db/zmalter-1.19.5.sql b/db/zmalter-1.19.5.sql index 79df6c8cb..bb2f27aa1 100644 --- a/db/zmalter-1.19.5.sql +++ b/db/zmalter-1.19.5.sql @@ -10,6 +10,10 @@ CREATE TABLE Groups ( PRIMARY KEY (Id) ) TYPE=MyISAM; -- +-- Make changes to Users table +-- +alter table Users modify MonitorIds tinytext not null default ''; +-- -- Make changes to Monitors table -- alter table Monitors modify column Function enum('None','Monitor','Modect','Record','Mocord','Nodect') NOT NULL default 'Monitor'; diff --git a/scripts/Makefile.in b/scripts/Makefile.in index e35afe206..8515c86e4 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.7 from Makefile.am. +# Makefile.in generated by automake 1.7.8 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -151,13 +151,14 @@ EXTRA_DIST = \ zm.z subdir = scripts +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = SCRIPTS = $(bin_SCRIPTS) DIST_SOURCES = -DIST_COMMON = Makefile.am Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am all: all-am .SUFFIXES: @@ -200,9 +201,11 @@ distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ @@ -229,7 +232,6 @@ all-am: Makefile $(SCRIPTS) installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) - install: install-am install-exec: install-exec-am install-data: install-data-am @@ -249,7 +251,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -259,7 +261,7 @@ clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am - + -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am @@ -281,7 +283,7 @@ install-man: installcheck-am: maintainer-clean: maintainer-clean-am - + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am diff --git a/src/Makefile.in b/src/Makefile.in index 8d6e35dbc..52e037a65 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.7 from Makefile.am. +# Makefile.in generated by automake 1.7.8 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -199,6 +199,7 @@ noinst_HEADERS = \ EXTRA_DIST = zm_config.h.z subdir = src +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = @@ -275,7 +276,7 @@ DIST_SOURCES = $(zma_SOURCES) $(zmc_SOURCES) $(zmf_SOURCES) \ $(zmfix_SOURCES) $(zms_SOURCES) $(zmu_SOURCES) HEADERS = $(noinst_HEADERS) -DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in Makefile.am SOURCES = $(zma_SOURCES) $(zmc_SOURCES) $(zmf_SOURCES) $(zmfix_SOURCES) $(zms_SOURCES) $(zmu_SOURCES) all: all-am @@ -360,13 +361,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zms.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zmu.Po@am__quote@ -distclean-depend: - -rm -rf ./$(DEPDIR) - .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ @am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ -@am__fastdepCC_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCC_TRUE@ fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @@ -376,19 +374,19 @@ distclean-depend: .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ -@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'`; \ -@am__fastdepCC_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCC_TRUE@ fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'` +@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` .cpp.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ @am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @@ -398,14 +396,14 @@ distclean-depend: .cpp.obj: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ -@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'`; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'` +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` uninstall-info-am: ETAGS = etags @@ -468,9 +466,11 @@ distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ @@ -500,7 +500,6 @@ all-am: Makefile $(PROGRAMS) $(HEADERS) installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) - install: install-am install-exec: install-exec-am install-data: install-data-am @@ -520,7 +519,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -530,9 +529,10 @@ clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am - -distclean-am: clean-am distclean-compile distclean-depend \ - distclean-generic distclean-tags + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags dvi: dvi-am @@ -555,7 +555,8 @@ install-man: installcheck-am: maintainer-clean: maintainer-clean-am - + -rm -rf ./$(DEPDIR) + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am @@ -574,11 +575,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ - distclean-depend distclean-generic distclean-tags distdir dvi \ - dvi-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-man install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ + distclean-generic distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-binPROGRAMS install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-info-am diff --git a/src/zms.cpp b/src/zms.cpp index 6e0e43ecc..8332b3c7b 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -17,21 +17,123 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +#include + #include "zm.h" #include "zm_db.h" #include "zm_monitor.h" +bool validateAuth( const char *user, char *auth, int id ) +{ +#ifdef HAVE_DECL_MD5 + if ( !(bool)config.Item( ZM_OPT_USE_AUTH ) ) + { + return( true ); + } + + char **env_ptr = environ; + const char *remote_addr = ""; + const char *remote_addr_str = "REMOTE_ADDR="; + while ( *env_ptr ) + { + if ( !strncasecmp( remote_addr_str, *env_ptr, strlen(remote_addr_str) ) ) + { + remote_addr = strchr( *env_ptr, '=' )+1; + break; + } + env_ptr++; + } + if ( !*remote_addr ) + { + Warning(( "Can't determine remote address, using null" )); + } + + char sql[BUFSIZ] = ""; + if ( id > 0 ) + { + snprintf( sql, sizeof(sql), "select Username, Password from Users where Username = '%s' and Enabled = 1 and Stream = 'View' and ( MonitorIds = '' or find_in_set( '%d', MonitorIds ) )", user, id ); + } + else + { + snprintf( sql, sizeof(sql), "select Username, Password from Users where Username = '%s' and Enabled = 1 and Events != 'None'", user ); + } + + if ( mysql_query( &dbconn, sql ) ) + { + Error(( "Can't run query: %s", mysql_error( &dbconn ) )); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error(( "Can't use query result: %s", mysql_error( &dbconn ) )); + exit( mysql_errno( &dbconn ) ); + } + int n_users = mysql_num_rows( result ); + + if ( n_users < 1 ) + { + Warning(( "Unable to authenticate user %s", user )); + return( false ); + } + + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + char auth_key[512] = ""; + char auth_md5[32+1] = ""; + unsigned char md5sum[64] = ""; + + time_t now = time( 0 ); + int max_tries = 2; + + for ( int i = 0; i < max_tries; i++, now -= (60*60) ) + { + struct tm *now_tm = localtime( &now ); + + snprintf( auth_key, sizeof(auth_key), "%s%s%s%s%d%d%d%d", + (const char *)config.Item( ZM_AUTH_SECRET ), + user, + dbrow[1], + remote_addr, + now_tm->tm_hour, + now_tm->tm_mday, + now_tm->tm_mon, + now_tm->tm_year + ); + + MD5( (unsigned char *)auth_key, strlen(auth_key), md5sum ); + auth_md5[0] = '\0'; + for ( int j = 0; j < strlen((const char *)md5sum); j++ ) + { + sprintf( auth_md5+strlen(auth_md5), "%02x", md5sum[j] ); + } + + if ( !strcmp( auth, auth_md5 ) ) + { + // We have a match + return( true ); + } + } + return( false ); +#else // HAVE_DECL_MD5 + return( true ); +#endif // HAVE_DECL_MD5 +} + int main( int argc, const char *argv[] ) { enum { ZMS_JPEG, ZMS_MPEG, ZMS_SINGLE } mode = ZMS_JPEG; char format[32] = ""; - int id = 1; + int id = 0; int event = 0; unsigned int scale = 100; unsigned int rate = 100; unsigned int maxfps = 10; unsigned int bitrate = 100000; unsigned int ttl = 0; + char auth[64] = ""; + char user[64] = ""; zm_dbg_name = "zms"; @@ -44,10 +146,21 @@ int main( int argc, const char *argv[] ) nph = true; } + //extern char **environ; + //char **env_ptr = environ; + //while ( *env_ptr ) + //{ + //printf( "X-Env: %s\n", *env_ptr ); + //env_ptr++; + //} + //exit( 0 ); + zmDbgInit(); zmLoadConfig(); + zmDbConnect(); + const char *query = getenv( "QUERY_STRING" ); if ( query ) { @@ -89,10 +202,26 @@ int main( int argc, const char *argv[] ) bitrate = atoi( value ); else if ( !strcmp( name, "ttl" ) ) ttl = atoi(value); + else if ( (bool)config.Item( ZM_OPT_USE_AUTH ) ) + { + if ( !strcmp( name, "auth" ) ) + { + strncpy( auth, value, sizeof(auth) ); + } + else if ( !strcmp( name, "user" ) ) + { + strncpy( user, value, sizeof(user) ); + } + } } } - zmDbConnect(); + if ( !validateAuth( user, auth, id ) ) + { + Error(( "Unable to validate authentication on '%s'", query )); + fprintf( stderr, "Unable to validate authentication on '%s'\n", query ); + return( -1 ); + } setbuf( stdout, 0 ); if ( nph ) diff --git a/web/Makefile.in b/web/Makefile.in index a30ef4ca2..2152c873f 100644 --- a/web/Makefile.in +++ b/web/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.7 from Makefile.am. +# Makefile.in generated by automake 1.7.8 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -294,13 +294,14 @@ EXTRA_DIST = \ zm_lang_pt_br.php subdir = web +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = DIST_SOURCES = DATA = $(web_DATA) -DIST_COMMON = Makefile.am Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am all: all-am .SUFFIXES: @@ -341,9 +342,11 @@ distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ @@ -370,7 +373,6 @@ all-am: Makefile $(DATA) installdirs: $(mkinstalldirs) $(DESTDIR)$(webdir) - install: install-am install-exec: install-exec-am install-data: install-data-am @@ -390,7 +392,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -400,7 +402,7 @@ clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am - + -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am @@ -424,7 +426,7 @@ install-man: installcheck-am: maintainer-clean: maintainer-clean-am - + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am diff --git a/web/zm.php b/web/zm.php index a50223340..dd684f54c 100644 --- a/web/zm.php +++ b/web/zm.php @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -import_request_variables( "EGPCS" ); +import_request_variables( "GPC" ); error_reporting (E_ALL ^ E_NOTICE); $debug = false; @@ -138,6 +138,8 @@ else } } +session_start(); + if ( !$HTTP_SESSION_VARS['format'] ) { $HTTP_SESSION_VARS['format'] = $format; diff --git a/web/zm_funcs.php b/web/zm_funcs.php index de625347c..62d737d79 100644 --- a/web/zm_funcs.php +++ b/web/zm_funcs.php @@ -32,6 +32,7 @@ function userLogin( $username, $password ) if ( $db_user = mysql_fetch_assoc( $result ) ) { $HTTP_SESSION_VARS['user'] = $user = $db_user; + $HTTP_SESSION_VARS['password_hash'] = $user['Password']; } else { @@ -50,6 +51,43 @@ function userLogout() session_destroy(); } +function authHash() +{ + global $HTTP_SESSION_VARS; + + if ( ZM_OPT_USE_AUTH ) + { + $time = localtime(); + $auth_key = ZM_AUTH_SECRET.$HTTP_SESSION_VARS['username'].$HTTP_SESSION_VARS['password_hash'].$HTTP_SESSION_VARS['remote_addr'].$time[2].$time[3].$time[4].$time[5]; + $auth = md5( $auth_key ); + } + else + { + $auth = "0"; + } + return( $auth ); +} + +function getStreamSrc( $args ) +{ + global $HTTP_SESSION_VARS; + + $stream_src = ZM_PATH_ZMS; + + if ( ZM_OPT_USE_AUTH ) + { + $args[] = "auth=".authHash(); + $args[] = "user=".$HTTP_SESSION_VARS['username']; + } + + if ( count($args) ) + { + $stream_src .= "?".join( "&", $args ); + } + + return( $stream_src ); +} + function visibleMonitor( $mid ) { global $user; diff --git a/web/zm_html_view_cycle.php b/web/zm_html_view_cycle.php index a41bbb77b..561781717 100644 --- a/web/zm_html_view_cycle.php +++ b/web/zm_html_view_cycle.php @@ -123,7 +123,7 @@ window.setTimeout( "window.location.replace( ' @@ -139,7 +139,7 @@ if ( $mode == "stream" ) } else { - $image_src = ZM_PATH_ZMS."?mode=single&monitor=".$monitor['Id']."&scale=".$scale; + $image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) ); ?> } else { - $stream_src = ZM_PATH_ZMS."?mode=jpeg&event=$eid&scale=$scale&rate=$rate&maxfps=".ZM_WEB_VIDEO_MAXFPS; + $stream_src = getStreamSrc( array( "mode=jpeg", "event=".$eid, "scale=".$scale, "rate=".$rate, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) ); if ( canStreamNative() ) { ?> diff --git a/web/zm_html_view_montagefeed.php b/web/zm_html_view_montagefeed.php index 65518ae9c..7110005bd 100644 --- a/web/zm_html_view_montagefeed.php +++ b/web/zm_html_view_montagefeed.php @@ -55,7 +55,7 @@ header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 -$image_src = ZM_PATH_ZMS."?mode=single&monitor=".$monitor['Id']."&scale=".$scale; +$image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) ); ?> @@ -100,7 +100,7 @@ if ( $mode == "stream" ) { if ( ZM_VIDEO_STREAM_METHOD == 'mpeg' && ZM_VIDEO_LIVE_FORMAT ) { - $stream_src = ZM_PATH_ZMS."?mode=mpeg&monitor=".$monitor['Id']."&scale=$scale&bitrate=".ZM_WEB_VIDEO_BITRATE."&maxfps=".ZM_WEB_VIDEO_MAXFPS."&format=".ZM_VIDEO_LIVE_FORMAT; + $stream_src = getStreamSrc( array( "mode=mpeg", "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_VIDEO_LIVE_FORMAT ) ); if ( isWindows() ) { if ( isInternetExplorer() ) @@ -147,7 +147,7 @@ autostart="true"> } else { - $stream_src = ZM_PATH_ZMS."?mode=jpeg&monitor=".$monitor['Id']."&scale=$scale&maxfps=".ZM_WEB_VIDEO_MAXFPS; + $stream_src = getStreamSrc( array( "mode=jpeg", "monitor=".$monitor['Id'], "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) ); if ( canStreamNative() ) { ?> diff --git a/web/zm_html_view_watchfeed.php b/web/zm_html_view_watchfeed.php index 8cfbda0bf..3a8c97e20 100644 --- a/web/zm_html_view_watchfeed.php +++ b/web/zm_html_view_watchfeed.php @@ -52,7 +52,7 @@ header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 -$image_src = ZM_PATH_ZMS."?mode=single&monitor=".$monitor['Id']."&scale=".$scale; +$image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) ); ?> @@ -97,7 +97,7 @@ if ( $mode == "stream" ) { if ( ZM_VIDEO_STREAM_METHOD == 'mpeg' && ZM_VIDEO_LIVE_FORMAT ) { - $stream_src = ZM_PATH_ZMS."?mode=mpeg&monitor=".$monitor['Id']."&scale=$scale&bitrate=".ZM_WEB_VIDEO_BITRATE."&maxfps=".ZM_WEB_VIDEO_MAXFPS."&format=".ZM_VIDEO_LIVE_FORMAT; + $stream_src = getStreamSrc( array( "mode=mpeg", "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_VIDEO_LIVE_FORMAT ) ); if ( isWindows() ) { if ( isInternetExplorer() ) @@ -144,7 +144,7 @@ autostart="true"> } else { - $stream_src = ZM_PATH_ZMS."?mode=jpeg&monitor=".$monitor['Id']."&scale=$scale&maxfps=".ZM_WEB_VIDEO_MAXFPS; + $stream_src = getStreamSrc( array( "mode=jpeg", "monitor=".$monitor['Id'], "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) ); if ( canStreamNative() ) { ?> diff --git a/web/zm_xhtml_view_montage.php b/web/zm_xhtml_view_montage.php index 2cbc3bc45..cbf8081e0 100644 --- a/web/zm_xhtml_view_montage.php +++ b/web/zm_xhtml_view_montage.php @@ -55,8 +55,7 @@ foreach( $monitors as $monitor ) $scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale); $scale /= 2; // Try and get two pics per line - $image_src = ZM_PATH_ZMS."?mode=single&monitor=".$monitor['Id']."&scale=".$scale; - + $image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) ); ?> <?= $monitor['Name'] ?> diff --git a/zmconfig.pl.in b/zmconfig.pl.in index 2684740e5..50378f00d 100755 --- a/zmconfig.pl.in +++ b/zmconfig.pl.in @@ -213,6 +213,15 @@ my @options = type => $types{boolean}, category => 'system', }, + { + name => "ZM_AUTH_SECRET", + default => "", + description => "Secret used when encoding authentication information", + help => "When ZoneMinder is running in authentcated mode it is sometimes necessary to generate hashed strings containing sensitive information such as usernames and password. Although these string are reasonably secure the addition of a random secret increases security substantially.", + requires => [ { name=>"ZM_OPT_USE_AUTH", value=>"yes" } ], + type => $types{string}, + category => 'system', + }, { name => "ZM_DIR_EVENTS", default => "events",