diff --git a/scripts/ssh.lua b/scripts/ssh.lua index de5435a..8cbb80b 100644 --- a/scripts/ssh.lua +++ b/scripts/ssh.lua @@ -44,7 +44,8 @@ function ssh_module.execute(command, user, host, port, identity_file) -- Pass remote command as provided; caller is responsible for proper quoting table.insert(pieces, "--") - table.insert(pieces, command) + -- Quote the remote command to prevent shell interpretation of && and || + table.insert(pieces, "'" .. command:gsub("'", "'\\''") .. "'") -- Join with spaces for os.execute local function join(args) @@ -97,7 +98,8 @@ function ssh_module.execute_with_output(command, user, host, port, identity_file -- Pass remote command as provided table.insert(pieces, "--") - table.insert(pieces, command) + -- Quote the remote command to prevent shell interpretation of && and || + table.insert(pieces, "'" .. command:gsub("'", "'\\''") .. "'") -- Join with spaces for io.popen local function join(args)