fix(ssh): config option to pass extra args to SCP (#340)
* Adding in SCP options configuration
This changeset adds in additional SCP options to the config. This allows
the user to specify a list of flags to send to the SCP command that will
be expanded into each shell command.
The primary driver for this is from newe boxes SSHing into pre 9 openSSH
boxes. New openSSH uses sftp server under the hood, rather than the
older SCP protocol. If you go into a system that does not have these
changes, SCP fails to work. The '-O' command line flag was introduced to
resolve this.
Using this change, the user can now pass in `extra_scp_options = {"-O"}`
to resolve the issue.
* Replacing table.unpack with global unpack
* lint: apply stylua
* refactor: change option name and shuffle config around
---------
Co-authored-by: Eric Guinn <eric_guinn@selinc.com>
Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
This commit is contained in:
parent
bcfc0a2e01
commit
3abb6077d7
4 changed files with 37 additions and 17 deletions
10
README.md
10
README.md
|
|
@ -199,10 +199,6 @@ require("oil").setup({
|
|||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
-- Configuration for the floating keymaps help window
|
||||
keymaps_help = {
|
||||
border = "rounded",
|
||||
},
|
||||
-- Set to false to disable all of the above keymaps
|
||||
use_default_keymaps = true,
|
||||
view_options = {
|
||||
|
|
@ -226,6 +222,8 @@ require("oil").setup({
|
|||
{ "name", "asc" },
|
||||
},
|
||||
},
|
||||
-- Extra arguments to pass to SCP when moving/copying files over SSH
|
||||
extra_scp_args = {},
|
||||
-- EXPERIMENTAL support for performing file operations with git
|
||||
git = {
|
||||
-- Return true to automatically git add/mv/rm files
|
||||
|
|
@ -298,6 +296,10 @@ require("oil").setup({
|
|||
ssh = {
|
||||
border = "rounded",
|
||||
},
|
||||
-- Configuration for the floating keymaps help window
|
||||
keymaps_help = {
|
||||
border = "rounded",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
|
|
|
|||
10
doc/oil.txt
10
doc/oil.txt
|
|
@ -90,10 +90,6 @@ CONFIG *oil-confi
|
|||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
-- Configuration for the floating keymaps help window
|
||||
keymaps_help = {
|
||||
border = "rounded",
|
||||
},
|
||||
-- Set to false to disable all of the above keymaps
|
||||
use_default_keymaps = true,
|
||||
view_options = {
|
||||
|
|
@ -117,6 +113,8 @@ CONFIG *oil-confi
|
|||
{ "name", "asc" },
|
||||
},
|
||||
},
|
||||
-- Extra arguments to pass to SCP when moving/copying files over SSH
|
||||
extra_scp_args = {},
|
||||
-- EXPERIMENTAL support for performing file operations with git
|
||||
git = {
|
||||
-- Return true to automatically git add/mv/rm files
|
||||
|
|
@ -189,6 +187,10 @@ CONFIG *oil-confi
|
|||
ssh = {
|
||||
border = "rounded",
|
||||
},
|
||||
-- Configuration for the floating keymaps help window
|
||||
keymaps_help = {
|
||||
border = "rounded",
|
||||
},
|
||||
})
|
||||
<
|
||||
|
||||
|
|
|
|||
|
|
@ -303,7 +303,14 @@ M.perform_action = function(action, cb)
|
|||
local src_conn = get_connection(action.src_url)
|
||||
local dest_conn = get_connection(action.dest_url)
|
||||
if src_conn ~= dest_conn then
|
||||
shell.run({ "scp", "-C", "-r", url_to_scp(src_res), url_to_scp(dest_res) }, function(err)
|
||||
shell.run({
|
||||
"scp",
|
||||
unpack(config.extra_scp_args),
|
||||
"-C",
|
||||
"-r",
|
||||
url_to_scp(src_res),
|
||||
url_to_scp(dest_res),
|
||||
}, function(err)
|
||||
if err then
|
||||
return cb(err)
|
||||
end
|
||||
|
|
@ -322,7 +329,14 @@ M.perform_action = function(action, cb)
|
|||
local src_res = M.parse_url(action.src_url)
|
||||
local dest_res = M.parse_url(action.dest_url)
|
||||
if not url_hosts_equal(src_res, dest_res) then
|
||||
shell.run({ "scp", "-C", "-r", url_to_scp(src_res), url_to_scp(dest_res) }, cb)
|
||||
shell.run({
|
||||
"scp",
|
||||
unpack(config.extra_scp_args),
|
||||
"-C",
|
||||
"-r",
|
||||
url_to_scp(src_res),
|
||||
url_to_scp(dest_res),
|
||||
}, cb)
|
||||
else
|
||||
local src_conn = get_connection(action.src_url)
|
||||
src_conn:cp(src_res.path, dest_res.path, cb)
|
||||
|
|
@ -341,7 +355,7 @@ M.perform_action = function(action, cb)
|
|||
src_arg = fs.posix_to_os_path(path)
|
||||
dest_arg = url_to_scp(M.parse_url(action.dest_url))
|
||||
end
|
||||
shell.run({ "scp", "-C", "-r", src_arg, dest_arg }, cb)
|
||||
shell.run({ "scp", unpack(config.extra_scp_args), "-C", "-r", src_arg, dest_arg }, cb)
|
||||
end
|
||||
else
|
||||
cb(string.format("Bad action type: %s", action.type))
|
||||
|
|
@ -365,7 +379,7 @@ M.read_file = function(bufnr)
|
|||
end
|
||||
local tmp_bufnr = vim.fn.bufadd(tmpfile)
|
||||
|
||||
shell.run({ "scp", "-C", scp_url, tmpfile }, function(err)
|
||||
shell.run({ "scp", unpack(config.extra_scp_args), "-C", scp_url, tmpfile }, function(err)
|
||||
loading.set_loading(bufnr, false)
|
||||
vim.bo[bufnr].modifiable = true
|
||||
vim.cmd.doautocmd({ args = { "BufReadPre", bufname }, mods = { silent = true } })
|
||||
|
|
@ -405,7 +419,7 @@ M.write_file = function(bufnr)
|
|||
vim.cmd.write({ args = { tmpfile }, bang = true, mods = { silent = true, noautocmd = true } })
|
||||
local tmp_bufnr = vim.fn.bufadd(tmpfile)
|
||||
|
||||
shell.run({ "scp", "-C", tmpfile, scp_url }, function(err)
|
||||
shell.run({ "scp", unpack(config.extra_scp_args), "-C", tmpfile, scp_url }, function(err)
|
||||
vim.bo[bufnr].modifiable = true
|
||||
if err then
|
||||
vim.notify(string.format("Error writing file: %s", err), vim.log.levels.ERROR)
|
||||
|
|
|
|||
|
|
@ -73,10 +73,6 @@ local default_config = {
|
|||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
-- Configuration for the floating keymaps help window
|
||||
keymaps_help = {
|
||||
border = "rounded",
|
||||
},
|
||||
-- Set to false to disable all of the above keymaps
|
||||
use_default_keymaps = true,
|
||||
view_options = {
|
||||
|
|
@ -100,6 +96,8 @@ local default_config = {
|
|||
{ "name", "asc" },
|
||||
},
|
||||
},
|
||||
-- Extra arguments to pass to SCP when moving/copying files over SSH
|
||||
extra_scp_args = {},
|
||||
-- EXPERIMENTAL support for performing file operations with git
|
||||
git = {
|
||||
-- Return true to automatically git add/mv/rm files
|
||||
|
|
@ -172,6 +170,10 @@ local default_config = {
|
|||
ssh = {
|
||||
border = "rounded",
|
||||
},
|
||||
-- Configuration for the floating keymaps help window
|
||||
keymaps_help = {
|
||||
border = "rounded",
|
||||
},
|
||||
}
|
||||
|
||||
-- The adapter API hasn't really stabilized yet. We're not ready to advertise or encourage people to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue