mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-12 14:17:47 +00:00
Sanitize mv arguments:
1. Fixes crashes on file names containing `, $ or " 2. Also prevents shell execution of ``, $() … in file names, which can be used to gain remote shell access as lsyncd's (target) user.
This commit is contained in:
parent
4da2257758
commit
18f02ad013
@ -77,6 +77,8 @@ rsyncssh.action = function( inlet )
|
|||||||
-- makes move local on target host
|
-- makes move local on target host
|
||||||
-- if the move fails, it deletes the source
|
-- if the move fails, it deletes the source
|
||||||
if event.etype == 'Move' then
|
if event.etype == 'Move' then
|
||||||
|
local path1 = event.path:gsub ('"', '\\"'):gsub ('`', '\\`'):gsub ('%$','\\%$')
|
||||||
|
local path2 = event2.path:gsub ('"', '\\"'):gsub ('`', '\\`'):gsub ('%$','\\%$')
|
||||||
|
|
||||||
log(
|
log(
|
||||||
'Normal',
|
'Normal',
|
||||||
@ -92,10 +94,10 @@ rsyncssh.action = function( inlet )
|
|||||||
config.ssh._computed,
|
config.ssh._computed,
|
||||||
config.host,
|
config.host,
|
||||||
'mv',
|
'mv',
|
||||||
'\"' .. config.targetdir .. event.path .. '\"',
|
'\"' .. config.targetdir .. path1 .. '\"',
|
||||||
'\"' .. config.targetdir .. event2.path .. '\"',
|
'\"' .. config.targetdir .. path2 .. '\"',
|
||||||
'||', 'rm', '-rf',
|
'||', 'rm', '-rf',
|
||||||
'\"' .. config.targetdir .. event.path .. '\"'
|
'\"' .. config.targetdir .. path1 .. '\"'
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user