diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index 30b1eca9e..b69c78b71 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -166,7 +166,6 @@ if ( $command =~ /^(?:start|restart)$/ ) } } zmMemTidy(); - runCommand( "zmfix" ); runCommand( "zmdc.pl startup" ); my $sql = "select * from Monitors"; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b91baa978..90d69c3c2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,6 @@ add_executable(zmf zmf.cpp) add_executable(zms zms.cpp) add_executable(nph-zms zms.cpp) add_executable(zmstreamer zmstreamer.cpp) -add_executable(zmfix zmfix.cpp zm_config.cpp zm_regexp.cpp zm_logger.cpp zm_utils.cpp zm_db.cpp zm.cpp) target_link_libraries(zmc zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) target_link_libraries(zma zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) @@ -25,9 +24,8 @@ target_link_libraries(zmf zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) target_link_libraries(zms zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) target_link_libraries(nph-zms zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) target_link_libraries(zmstreamer zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) -target_link_libraries(zmfix ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) -install(TARGETS zmc zma zmu zmf zmstreamer zmfix RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(TARGETS zmc zma zmu zmf zmstreamer RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(TARGETS zms nph-zms RUNTIME DESTINATION "${ZM_CGIDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/Makefile.am b/src/Makefile.am index 9f111bfe3..6bd7ea4c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,8 +17,7 @@ bin_PROGRAMS = \ zmu \ zms \ zmf \ - zmstreamer \ - zmfix + zmstreamer zm_SOURCES = \ zm_box.cpp \ @@ -66,7 +65,6 @@ zms_SOURCES = zms.cpp $(zm_SOURCES) zmu_SOURCES = zmu.cpp $(zm_SOURCES) zmf_SOURCES = zmf.cpp $(zm_SOURCES) zmstreamer_SOURCES = zmstreamer.cpp $(zm_SOURCES) -zmfix_SOURCES = zmfix.cpp zm_config.cpp zm_regexp.cpp zm_logger.cpp zm_utils.cpp zm_db.cpp zm.cpp noinst_HEADERS = \ jinclude.h \ @@ -126,7 +124,6 @@ dist-hook: install-exec-hook: ( cd $(DESTDIR)@bindir@; mkdir -p $(DESTDIR)$(cgidir); mv zms $(DESTDIR)$(cgidir) ) ( cd $(DESTDIR)$(cgidir); chown $(webuser):$(webgroup) zms; ln -f zms nph-zms ) - ( cd $(DESTDIR)@bindir@; chmod u+s zmfix ) uninstall-hook: ( cd $(DESTDIR)$(cgidir); rm -f zms nph-zms ) diff --git a/src/zmfix.cpp b/src/zmfix.cpp deleted file mode 100644 index a9254844b..000000000 --- a/src/zmfix.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// -// ZoneMinder Video Device Fixer, $Date$, $Revision$ -// Copyright (C) 2001-2008 Philip Coombes -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "zm.h" -#include "zm_db.h" - -// Determine if we are a member of the group -int inGroup( gid_t gid ) -{ - // Get how many groups we are in - int n_gids = getgroups( 0, NULL ); - if ( n_gids < 0 ) - { - Error( "getgroups:%s", strerror(errno) ); - return( -1 ); - } - - // Not in any groups - if ( !n_gids ) - { - return( 0 ); - } - - // Allocate space to hold groups - gid_t *gids = new gid_t[n_gids * sizeof(gid_t)]; - if ( !gids ) - { - Error( "Unable to allocate groups: %s", strerror(errno) ); - return( -1 ); - } - - // Get list of groups - if ( getgroups( n_gids, gids ) != n_gids ) - { - Error( "getgroups:%s", strerror(errno) ); - delete[] gids; - return( -1 ); - } - - // See if gid in list of groups we belong to - int in_gid = 0; - for ( int i = 0; i < n_gids; i++ ) - { - if ( gids[i] == gid ) - { - in_gid = 1; - } - } - delete[] gids; - return( in_gid ); -} - -bool fixDevice( const char *device_path ) -{ - struct stat stat_buf; - - if ( stat( device_path, &stat_buf ) < 0 ) - { - Error( "Can't stat %s: %s", device_path, strerror(errno)); - return( false ); - } - - uid_t uid = getuid(); - gid_t gid = getgid(); - - int in_gid; - if ( (in_gid = inGroup( stat_buf.st_gid )) < 0 ) - { - return( false ); - } - - mode_t mask = 0; - if ( uid == stat_buf.st_uid ) - { - // If we are the owner - mask = 00600; - } - else if ( gid == stat_buf.st_gid || in_gid ) - { - // If we are in the owner group - mask = 00060; - } - else - { - // We are neither the owner nor in the group - mask = 00006; - } - - mode_t mode = stat_buf.st_mode; - if ( (mode & mask) == mask ) - { - Debug( 1, "Permissions on %s are ok at %o", device_path, mode ); - return( true ); - } - mode |= mask; - - Info( "Resetting permissions on %s to %o", device_path, mode ); - if ( chmod( device_path, mode ) < 0 ) - { - Error( "Can't chmod %s to %o: %s", device_path, mode, strerror(errno)); - return( false ); - } - return( true ); -} - -int main( int argc, char *argv[] ) -{ - self = argv[0]; - - zmLoadConfig(); - - logInit( "zmfix" ); - logCapLevel( Logger::ERROR ); - - // Only do registered devices - static char sql[ZM_SQL_SML_BUFSIZ]; - snprintf( sql, sizeof(sql), "select distinct Device from Monitors where not isnull(Device) and Type = 'Local'" ); - 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 ) ); - } - - for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) - { - fixDevice( dbrow[0] ); - } - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - // Yadda yadda - mysql_free_result( result ); - - snprintf( sql, sizeof(sql), "select distinct ControlDevice from Monitors where not isEmpty(ControlDevice)" ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) - { - fixDevice( dbrow[0] ); - } - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - // Yadda yadda - mysql_free_result( result ); - - if ( config.opt_x10 ) - { - if ( config.x10_device ) - { - fixDevice( config.x10_device ); - } - } - - return( 0 ); -} diff --git a/web/includes/actions.php b/web/includes/actions.php index 6eadb97ae..643bf82a5 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -554,7 +554,6 @@ if ( !empty($action) ) if ( $restart ) { $monitor = dbFetchOne( "select * from Monitors where Id = '".dbEscape($mid)."'" ); - fixDevices(); //if ( $cookies ) //session_write_close(); if ( daemonCheck() ) diff --git a/web/includes/functions.php b/web/includes/functions.php index dcde0014e..49abecde2 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -916,13 +916,6 @@ function canStream() return( canStreamNative() | canStreamApplet() ); } -function fixDevices() -{ - $string = ZM_PATH_BIN."/zmfix"; - $string .= " 2>/dev/null >&- <&- >/dev/null"; - exec( $string ); -} - function packageControl( $command ) { $string = ZM_PATH_BIN.'/zmpkg.pl '.escapeshellarg( $command );