do not append a '/' to targets when there it ends with a ':'

This commit is contained in:
Axel Kittenberger 2018-02-27 10:09:28 +01:00
parent bbe9c5f38c
commit d72a59e70f
5 changed files with 50 additions and 87 deletions

View File

@ -1,11 +1,15 @@
2018-??-??: 2.2.3
change: if the target/targetdir ands with a ':' do not append
a trailing '/' to it, since that would change it from homedir to rootdir!
2017-02-16: 2.2.2 2017-02-16: 2.2.2
fix: checkgauge 'insist' fix: checkgauge 'insist'
fix: no partial path exlusion tests fix: no partial path exlusion tests
fix: write pid of forked process in pidfile fix: write pid of forked process in pidfile
fix: crash on not reachable target fix: crash on not reachable target
workaround: workaround:
changed back to filter style rsync calling changed back to filter style rsync calling
until https://bugzilla.samba.org/show_bug.cgi?id=12569 until https://bugzilla.samba.org/show_bug.cgi?id=12569
is fixed and released. is fixed and released.
2017-01-05: 2.2.1 2017-01-05: 2.2.1

View File

@ -647,11 +647,13 @@ rsync.prepare = function
end end
-- appends a / to target if not present -- appends a / to target if not present
if not skipTarget and string.sub(config.target, -1) ~= '/' -- and not a ':' for home dir.
if not skipTarget
and string.sub( config.target, -1 ) ~= '/'
and string.sub( config.target, -1 ) ~= ':'
then then
config.target = config.target..'/' config.target = config.target..'/'
end end
end end

View File

@ -91,10 +91,7 @@ local replaceRsyncFilter =
( (
path path
) )
if not path if not path then return end
then
return
end
return( return(
path path
@ -161,9 +158,7 @@ rsyncssh.action = function
-- Replaces what rsync would consider filter rules by literals -- Replaces what rsync would consider filter rules by literals
-- --
local function sub( p ) local function sub( p )
if not p then if not p then return end
return
end
return p: return p:
gsub( '%?', '\\?' ): gsub( '%?', '\\?' ):
@ -195,11 +190,7 @@ rsyncssh.action = function
-- adds one path to the filter -- adds one path to the filter
local function addToFilter( path ) local function addToFilter( path )
if filterP[ path ] then return end
if filterP[ path ]
then
return
end
filterP[ path ] = true filterP[ path ] = true
@ -372,7 +363,7 @@ rsyncssh.collect = function
if rc == 'ok' if rc == 'ok'
then then
log('Normal', 'Startup of "', agent.source, '" finished: ', exitcode) log( 'Normal', 'Startup of "', agent.source, '" finished: ', exitcode )
elseif rc == 'again' elseif rc == 'again'
then then
if settings('insist') if settings('insist')
@ -382,16 +373,16 @@ rsyncssh.collect = function
log( log(
'Error', 'Error',
'Temporary or permanent failure on startup of "', 'Temporary or permanent failure on startup of "',
agent.source, '". Terminating since "insist" is not set.' agent.source, '". Terminating since "insist" is not set.'
) )
terminate( -1 ) -- ERRNO terminate( -1 ) -- ERRNO
end end
elseif rc == 'die' elseif rc == 'die'
then then
log( 'Error', 'Failure on startup of "',agent.source,'": ', exitcode ) log( 'Error', 'Failure on startup of "', agent.source, '": ', exitcode )
else else
log( 'Error', 'Unknown exitcode on startup of "', agent.source,': "',exitcode ) log( 'Error', 'Unknown exitcode on startup of "', agent.source, ': "', exitcode )
rc = 'die' rc = 'die'
end end
@ -431,7 +422,7 @@ rsyncssh.collect = function
then then
log( 'Normal', 'Failure ', agent.etype, ' ', agent.sourcePath, ': ', exitcode ) log( 'Normal', 'Failure ', agent.etype, ' ', agent.sourcePath, ': ', exitcode )
else else
log( 'Error', 'Unknown exitcode ',agent.etype,' ',agent.sourcePath,': ',exitcode ) log( 'Error', 'Unknown exitcode ', agent.etype,' ', agent.sourcePath,': ', exitcode )
rc = 'die' rc = 'die'
end end
@ -453,18 +444,12 @@ rsyncssh.prepare = function
if not config.host if not config.host
then then
error( error( 'default.rsyncssh needs "host" configured', level )
'default.rsyncssh needs "host" configured',
level
)
end end
if not config.targetdir if not config.targetdir
then then
error( error( 'default.rsyncssh needs "targetdir" configured', level )
'default.rsyncssh needs "targetdir" configured',
level
)
end end
-- --
@ -472,18 +457,12 @@ rsyncssh.prepare = function
-- --
if config.ssh._computed if config.ssh._computed
then then
error( error( 'please do not use the internal rsync._computed parameter', level )
'please do not use the internal rsync._computed parameter',
level
)
end end
if config.maxProcesses ~= 1 if config.maxProcesses ~= 1
then then
error( error( 'default.rsyncssh must have maxProcesses set to 1.', level )
'default.rsyncssh must have maxProcesses set to 1.',
level
)
end end
local cssh = config.ssh; local cssh = config.ssh;
@ -578,10 +557,11 @@ rsyncssh.prepare = function
end end
-- appends a slash to the targetdir if missing -- appends a slash to the targetdir if missing
-- and is not ':' for home dir
if string.sub( config.targetdir, -1 ) ~= '/' if string.sub( config.targetdir, -1 ) ~= '/'
and string.sub( config.targetdir, -1 ) ~= ':'
then then
config.targetdir = config.targetdir = config.targetdir .. '/'
config.targetdir .. '/'
end end
end end

View File

@ -12,7 +12,7 @@
#define LSYNCD_H #define LSYNCD_H
// some older machines need this to see pselect // some older machines need this to see pselect
#define _BSD_SOURCE 1 #define _DEFAULT_SOURCE 1
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#define _DARWIN_C_SOURCE 1 #define _DARWIN_C_SOURCE 1

View File

@ -349,7 +349,7 @@ Queue = ( function
return nt[ nt.first ] return nt[ nt.first ]
end end
-- --
-- Returns the last item of the Queue. -- Returns the last item of the Queue.
-- --
@ -361,7 +361,7 @@ Queue = ( function
return nt[ nt.last ] return nt[ nt.last ]
end end
-- --
-- Returns the size of the queue. -- Returns the size of the queue.
-- --
@ -549,7 +549,6 @@ Queue = ( function
) )
return iterReverse, self, self[ k_nt ].last + 1 return iterReverse, self, self[ k_nt ].last + 1
end end
-- --
-- Creates a new queue. -- Creates a new queue.
@ -1582,10 +1581,7 @@ local InletFactory = ( function
if delay.etype ~= 'Move' if delay.etype ~= 'Move'
then then
if eu if eu then return eu end
then
return eu
end
local event = { } local event = { }
@ -1598,10 +1594,7 @@ local InletFactory = ( function
return event return event
else else
-- moves have 2 events - origin and destination -- moves have 2 events - origin and destination
if eu if eu then return eu[1], eu[2] end
then
return eu[1], eu[2]
end
local event = { move = 'Fr' } local event = { move = 'Fr' }
local event2 = { move = 'To' } local event2 = { move = 'To' }
@ -1628,10 +1621,7 @@ local InletFactory = ( function
) )
local eu = e2d2[ dlist ] local eu = e2d2[ dlist ]
if eu if eu then return eu end
then
return eu
end
local elist = { } local elist = { }
@ -1773,10 +1763,7 @@ local InletFactory = ( function
if not f if not f
then then
error( error( 'inlet does not have function "'..func..'"', 2 )
'inlet does not have function "'..func..'"',
2
)
end end
return function( ... ) return function( ... )
@ -1837,7 +1824,7 @@ end )( )
-- --
-- A set of exclude patterns -- A set of exclude patterns.
-- --
local Excludes = ( function( ) local Excludes = ( function( )
@ -1850,6 +1837,7 @@ local Excludes = ( function( )
p -- the rsync like pattern p -- the rsync like pattern
) )
local o = p local o = p
p = string.gsub( p, '%%', '%%%%' ) p = string.gsub( p, '%%', '%%%%' )
p = string.gsub( p, '%^', '%%^' ) p = string.gsub( p, '%^', '%%^' )
p = string.gsub( p, '%$', '%%$' ) p = string.gsub( p, '%$', '%%$' )
@ -1873,11 +1861,7 @@ local Excludes = ( function( )
p = '/' .. p; p = '/' .. p;
end end
log( log( 'Exclude', 'toLuaPattern "', o, '" = "', p, '"' )
'Exclude',
'toLuaPattern "',
o, '" = "', p, '"'
)
return p return p
end end
@ -1908,7 +1892,6 @@ local Excludes = ( function( )
self, -- self self, -- self
pattern -- the pattern to remove pattern -- the pattern to remove
) )
if not self.list[ pattern ] if not self.list[ pattern ]
then -- already in the list? then -- already in the list?
log( log(
@ -1930,9 +1913,9 @@ local Excludes = ( function( )
self, self,
plist plist
) )
for _, v in ipairs(plist) for _, v in ipairs( plist )
do do
add(self, v) add( self, v )
end end
end end
@ -1948,11 +1931,7 @@ local Excludes = ( function( )
if not f if not f
then then
log( log( 'Error', 'Cannot open exclude file "', file,'": ', err )
'Error',
'Cannot open exclude file "', file,'": ',
err
)
terminate( -1 ) terminate( -1 )
end end
@ -2281,10 +2260,7 @@ local Sync = ( function
do do
local pd = path .. dirname local pd = path .. dirname
if isdir if isdir then pd = pd..'/' end
then
pd = pd..'/'
end
log( log(
'Delay', 'Delay',
@ -3082,13 +3058,16 @@ local Syncs = ( function
config.prepare( config, 4 ) config.prepare( config, 4 )
end end
if not config[ 'source' ] then if not config[ 'source' ]
then
local info = debug.getinfo( 3, 'Sl' ) local info = debug.getinfo( 3, 'Sl' )
log( log(
'Error', 'Error',
info.short_src,':', info.short_src,':',
info.currentline,': source missing from sync.' info.currentline,': source missing from sync.'
) )
terminate( -1 ) terminate( -1 )
end end
@ -3104,6 +3083,7 @@ local Syncs = ( function
'Cannot access source directory: ', 'Cannot access source directory: ',
config.source config.source
) )
terminate( -1 ) terminate( -1 )
end end
@ -3118,6 +3098,7 @@ local Syncs = ( function
and not config.onMove and not config.onMove
then then
local info = debug.getinfo( 3, 'Sl' ) local info = debug.getinfo( 3, 'Sl' )
log( log(
'Error', 'Error',
info.short_src, ':', info.short_src, ':',
@ -3553,14 +3534,12 @@ end)( )
-- --
local Fsevents = ( function local Fsevents = ( function
( ) ( )
-- --
-- A list indexed by syncs yielding -- A list indexed by syncs yielding
-- the root path the sync is interested in. -- the root path the sync is interested in.
-- --
local syncRoots = { } local syncRoots = { }
-- --
-- Adds a Sync to receive events. -- Adds a Sync to receive events.
-- --
@ -4036,8 +4015,6 @@ end )( )
-- --
local StatusFile = ( function local StatusFile = ( function
( ) ( )
-- --
-- Timestamp when the status file has been written. -- Timestamp when the status file has been written.
-- --