adding -p to cp for default.direct. Put a log message before daemonizing to test logging. Fix a crash for default.direct

This commit is contained in:
Axel Kittenberger 2016-12-02 16:24:07 +01:00
parent c58658e642
commit b79defadb3
4 changed files with 41 additions and 31 deletions

View File

@ -8,6 +8,9 @@
"omit_dir_times" "omit_dir_times"
"omit_link_times", "omit_link_times",
enhancement: settings{ } now checks for unknown entries and errors if so. enhancement: settings{ } now checks for unknown entries and errors if so.
change: Lsyncd now writes a startup log message before daemonizing
does in case logging fails, it is recognized before it cannot
message anything about it, since it deamonized
change: compatible with Lua5.3 (along with 5.1 and 5.2) change: compatible with Lua5.3 (along with 5.1 and 5.2)
change: _verbatim forced for 'exitcodes' entry. change: _verbatim forced for 'exitcodes' entry.
change: manpage is not rebuild by default. change: manpage is not rebuild by default.
@ -15,10 +18,12 @@
change: change:
faulty/deprecated config files that use settings = { ... }, with equal sign faulty/deprecated config files that use settings = { ... }, with equal sign
are no longer worked around. are no longer worked around.
change: default.direct now calls copy with -p
fix: ']' is not escaped for rsync rules, since rsync only applies fix: ']' is not escaped for rsync rules, since rsync only applies
doesn't applie pattern matching if no other pattern chars doesn't applie pattern matching if no other pattern chars
are found. are found.
fix: Shell injection hole close for default.direct on mv commands. (Marcin Szewczyk) fix: Shell injection hole close for default.direct on mv commands. (Marcin Szewczyk)
fix: Crash of default-direct when source doesn't exit (Michael Ploujnikov)
15-10-2015: 2.1.6 15-10-2015: 2.1.6
enhancement: Lsyncd now locks its pidfile enhancement: Lsyncd now locks its pidfile

View File

@ -70,6 +70,7 @@ direct.action = function(inlet)
spawn( spawn(
event, event,
'/bin/cp', '/bin/cp',
'-p',
'--', '--',
event.sourcePath, event.sourcePath,
event.targetPathdir event.targetPathdir
@ -81,6 +82,7 @@ direct.action = function(inlet)
end end
spawn(event, spawn(event,
'/bin/cp', '/bin/cp',
'-p',
'--', '--',
event.sourcePath, event.sourcePath,
event.targetPathdir event.targetPathdir
@ -145,8 +147,10 @@ direct.collect = function(agent, exitcode)
local rc = config.rsyncExitCodes[exitcode] local rc = config.rsyncExitCodes[exitcode]
if rc == 'ok' then if rc == 'ok' then
log('Normal', 'Startup of "',agent.source,'" finished: ', exitcode) log('Normal', 'Startup of "',agent.source,'" finished: ', exitcode)
elseif rc == 'again' then elseif rc == 'again'
if settings.insist then then
if settings( 'insist' )
then
log('Normal', 'Retrying startup of "',agent.source,'": ', exitcode) log('Normal', 'Retrying startup of "',agent.source,'": ', exitcode)
else else
log('Error', 'Temporary or permanent failure on startup of "', log('Error', 'Temporary or permanent failure on startup of "',

View File

@ -1605,24 +1605,29 @@ l_configure( lua_State *L )
settings.log_syslog = true; settings.log_syslog = true;
const char * log_ident = const char * log_ident =
settings.log_ident ? settings.log_ident
settings.log_ident : ? settings.log_ident
"lsyncd"; : "lsyncd";
openlog( log_ident, 0, settings.log_facility ); openlog( log_ident, 0, settings.log_facility );
} }
if( !settings.nodaemon && !is_daemon )
{
logstring( "Debug", "daemonizing now." );
daemonize( L );
}
if( settings.pidfile ) if( settings.pidfile )
{ {
write_pidfile( L, settings.pidfile ); write_pidfile( L, settings.pidfile );
} }
if( !settings.nodaemon && !is_daemon )
{
logstring( "Normal", "--- Startup, daemonizing ---" );
daemonize( L );
}
else
{
logstring( "Normal", "--- Startup ---" );
}
} }
else if( !strcmp( command, "nodaemon" ) ) else if( !strcmp( command, "nodaemon" ) )
{ {
@ -1649,8 +1654,7 @@ l_configure( lua_State *L )
free( settings.pidfile ); free( settings.pidfile );
} }
settings.pidfile = settings.pidfile = s_strdup( file );
s_strdup( file );
} }
else if( !strcmp( command, "logfacility" ) ) else if( !strcmp( command, "logfacility" ) )
{ {
@ -1694,8 +1698,10 @@ l_configure( lua_State *L )
{ {
const char * ident = luaL_checkstring( L, 2 ); const char * ident = luaL_checkstring( L, 2 );
if (settings.log_ident) if( settings.log_ident )
{ free(settings.log_ident); } {
free( settings.log_ident );
}
settings.log_ident = s_strdup( ident ); settings.log_ident = s_strdup( ident );
} }
@ -2423,6 +2429,7 @@ main1( int argc, char *argv[] )
// load Lua // load Lua
L = luaL_newstate( ); L = luaL_newstate( );
luaL_openlibs( L ); luaL_openlibs( L );
{ {
// checks the lua version // checks the lua version
@ -2500,7 +2507,6 @@ main1( int argc, char *argv[] )
// registers Lsycnd's core library // registers Lsycnd's core library
register_lsyncd( L ); register_lsyncd( L );
if( check_logcat( "Debug" ) <= settings.log_level ) if( check_logcat( "Debug" ) <= settings.log_level )
{ {
// printlogf doesnt support %ld :-( // printlogf doesnt support %ld :-(
@ -2658,7 +2664,6 @@ main1( int argc, char *argv[] )
} }
} }
// checks if there is a "-help" or "--help" // checks if there is a "-help" or "--help"
{ {
int i; int i;
@ -2786,15 +2791,11 @@ main1( int argc, char *argv[] )
} }
#ifdef WITH_INOTIFY #ifdef WITH_INOTIFY
open_inotify( L ); open_inotify( L );
#endif #endif
#ifdef WITH_FSEVENTS #ifdef WITH_FSEVENTS
open_fsevents( L ); open_fsevents( L );
#endif #endif
// adds signal handlers // adds signal handlers

View File

@ -836,7 +836,7 @@ local InletFactory = ( function( )
return e2d[ event ].sync.config return e2d[ event ].sync.config
end, end,
----- --
-- Returns the inlet belonging to an event. -- Returns the inlet belonging to an event.
-- --
inlet = function( event ) inlet = function( event )
@ -893,7 +893,7 @@ local InletFactory = ( function( )
return string.match( getPath( event ), '([^/]+)/?$') return string.match( getPath( event ), '([^/]+)/?$')
end, end,
--- --
-- Returns the file/dir relative to watch root -- Returns the file/dir relative to watch root
-- including a trailing slash for dirs. -- including a trailing slash for dirs.
-- --
@ -917,7 +917,7 @@ local InletFactory = ( function( )
return cutSlash( getPath( event ) ) return cutSlash( getPath( event ) )
end, end,
--- --
-- Returns the absolute path of the watch root. -- Returns the absolute path of the watch root.
-- All symlinks are resolved. -- All symlinks are resolved.
-- --
@ -942,7 +942,7 @@ local InletFactory = ( function( )
( string.match( getPath( event ), '^(.*/)[^/]+/?' ) or '' ) ( string.match( getPath( event ), '^(.*/)[^/]+/?' ) or '' )
end, end,
------ --
-- Returns the absolute path of the file/dir -- Returns the absolute path of the file/dir
-- excluding a trailing slash for dirs. -- excluding a trailing slash for dirs.
-- --
@ -1383,7 +1383,7 @@ local Excludes = ( function( )
end end
----- --
-- Adds a list of patterns to exclude. -- Adds a list of patterns to exclude.
-- --
local function addList(self, plist) local function addList(self, plist)
@ -2044,7 +2044,7 @@ local Sync = ( function( )
end end
------ --
-- Adds and returns a blanket delay thats blocks all. -- Adds and returns a blanket delay thats blocks all.
-- Used as custom marker. -- Used as custom marker.
-- --
@ -2475,7 +2475,7 @@ local Syncs = ( function( )
terminate( -1 ) terminate( -1 )
end end
--- creates the new sync -- creates the new sync
local s = Sync.new( config ) local s = Sync.new( config )
table.insert( syncsList, s ) table.insert( syncsList, s )
@ -4436,8 +4436,8 @@ function spawnShell(
) )
end end
----- --
-- Observes a filedescriptor -- Observes a filedescriptor.
-- --
function observefd( function observefd(
fd, -- file descriptor fd, -- file descriptor
@ -4452,7 +4452,7 @@ function observefd(
end end
-- --
-- Stops observeing a filedescriptor -- Stops observeing a filedescriptor.
-- --
function nonobservefd( function nonobservefd(
fd -- file descriptor fd -- file descriptor