diff --git a/lix/libstore/machines.cc b/lix/libstore/machines.cc index daf91d532..ac9428dd0 100644 --- a/lix/libstore/machines.cc +++ b/lix/libstore/machines.cc @@ -71,12 +71,12 @@ try { StoreConfig::Params storeParams; if (storeUri.starts_with("ssh://")) { - pipe.create(); - storeParams["log-fd"] = std::to_string(pipe.writeSide.get()); storeParams["max-connections"] = "1"; } if (storeUri.starts_with("ssh://") || storeUri.starts_with("ssh-ng://")) { + pipe.create(); + storeParams["log-fd"] = std::to_string(pipe.writeSide.get()); if (sshKey != "") storeParams["ssh-key"] = sshKey; if (sshPublicHostKey != "") diff --git a/lix/libstore/ssh-store.cc b/lix/libstore/ssh-store.cc index dad27f2ed..e38f18144 100644 --- a/lix/libstore/ssh-store.cc +++ b/lix/libstore/ssh-store.cc @@ -28,27 +28,51 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig } }; +struct SSHStoreConfigWithLog : SSHStoreConfig +{ + SSHStoreConfigWithLog(const Params & params) + : StoreConfig(params) + , RemoteStoreConfig(params) + , CommonSSHStoreConfig(params) + , SSHStoreConfig(params) + { + } + + // Hack for getting ssh errors into build-remote. + // Intentionally not in `SSHStoreConfig` so that it doesn't appear in + // the documentation + const Setting logFD{ + this, -1, "log-fd", "file descriptor to which SSH's stderr is connected" + }; +}; + class SSHStore final : public RemoteStore { - SSHStoreConfig config_; + SSHStoreConfigWithLog config_; public: - SSHStore(const std::string & scheme, const std::string & host, SSHStoreConfig config) + SSHStore(const std::string & scheme, const std::string & host, SSHStoreConfigWithLog config) : Store(config) , RemoteStore(config) , config_(std::move(config)) , host(host) - , ssh( - host, - config_.port, - config_.sshKey, - config_.sshPublicHostKey, - config_.compress) + , ssh(host, + config_.port, + config_.sshKey, + config_.sshPublicHostKey, + config_.compress, + config_.logFD) { } - SSHStoreConfig & config() override { return config_; } - const SSHStoreConfig & config() const override { return config_; } + SSHStoreConfigWithLog & config() override + { + return config_; + } + const SSHStoreConfigWithLog & config() const override + { + return config_; + } static std::set uriSchemes() { return {"ssh-ng"}; } diff --git a/lix/libstore/ssh.hh b/lix/libstore/ssh.hh index a3bf8358b..b4db256e5 100644 --- a/lix/libstore/ssh.hh +++ b/lix/libstore/ssh.hh @@ -30,8 +30,12 @@ private: void addCommonSSHOpts(Strings & args); public: - - SSH(const std::string & host, const std::optional port, const std::string & keyFile, const std::string & sshPublicHostKey, bool compress, int logFD = -1); + SSH(const std::string & host, + const std::optional port, + const std::string & keyFile, + const std::string & sshPublicHostKey, + bool compress, + int logFD); struct Connection {