mirror of
https://github.com/NixOS/nix
synced 2025-07-02 09:21:47 +02:00
Make SSHMaster::startCommand
work on an args list
This avoids split-on-whitespace errors: - No more `bash -c` needed - No more `shellEscape` needed - `remote-program` ssh store setting also cleanly supports args (e.g. `nix daemon`) - `ssh` uses `--` to separate args for SSH from args for the command to run. and will help with Hydra dedup. Some code taken from #6628. Co-Authored-By: Alexander Bantyev <balsoft@balsoft.ru>
This commit is contained in:
parent
74534829f2
commit
b71673109c
5 changed files with 36 additions and 19 deletions
|
@ -17,7 +17,7 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig
|
|||
using RemoteStoreConfig::RemoteStoreConfig;
|
||||
using CommonSSHStoreConfig::CommonSSHStoreConfig;
|
||||
|
||||
const Setting<Path> remoteProgram{this, "nix-daemon", "remote-program",
|
||||
const Setting<Strings> remoteProgram{this, {"nix-daemon"}, "remote-program",
|
||||
"Path to the `nix-daemon` executable on the remote machine."};
|
||||
|
||||
const std::string name() override { return "Experimental SSH Store"; }
|
||||
|
@ -212,14 +212,15 @@ public:
|
|||
ref<RemoteStore::Connection> SSHStore::openConnection()
|
||||
{
|
||||
auto conn = make_ref<Connection>();
|
||||
|
||||
std::string command = remoteProgram + " --stdio";
|
||||
if (remoteStore.get() != "")
|
||||
command += " --store " + shellEscape(remoteStore.get());
|
||||
for (auto & arg : extraRemoteProgramArgs)
|
||||
command += " " + shellEscape(arg);
|
||||
|
||||
conn->sshConn = master.startCommand(command);
|
||||
Strings command = remoteProgram.get();
|
||||
command.push_back("--stdio");
|
||||
if (remoteStore.get() != "") {
|
||||
command.push_back("--store");
|
||||
command.push_back(remoteStore.get());
|
||||
}
|
||||
command.insert(command.end(),
|
||||
extraRemoteProgramArgs.begin(), extraRemoteProgramArgs.end());
|
||||
conn->sshConn = master.startCommand(std::move(command));
|
||||
conn->to = FdSink(conn->sshConn->in.get());
|
||||
conn->from = FdSource(conn->sshConn->out.get());
|
||||
return conn;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue