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_link_times",
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: _verbatim forced for 'exitcodes' entry.
change: manpage is not rebuild by default.
@ -15,10 +18,12 @@
change:
faulty/deprecated config files that use settings = { ... }, with equal sign
are no longer worked around.
change: default.direct now calls copy with -p
fix: ']' is not escaped for rsync rules, since rsync only applies
doesn't applie pattern matching if no other pattern chars
are found.
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
enhancement: Lsyncd now locks its pidfile

View File

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

View File

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

View File

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