forked from lix-project/lix
Disallow SSH host names starting with a dash
This commit is contained in:
parent
82c4b37c6f
commit
e4bd42f98f
|
@ -2,6 +2,17 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
SSHMaster::SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress, int logFD)
|
||||||
|
: host(host)
|
||||||
|
, keyFile(keyFile)
|
||||||
|
, useMaster(useMaster)
|
||||||
|
, compress(compress)
|
||||||
|
, logFD(logFD)
|
||||||
|
{
|
||||||
|
if (host == "" || hasPrefix(host, "-"))
|
||||||
|
throw Error("invalid SSH host name '%s'", host);
|
||||||
|
}
|
||||||
|
|
||||||
void SSHMaster::addCommonSSHOpts(Strings & args)
|
void SSHMaster::addCommonSSHOpts(Strings & args)
|
||||||
{
|
{
|
||||||
for (auto & i : tokenizeString<Strings>(getEnv("NIX_SSHOPTS")))
|
for (auto & i : tokenizeString<Strings>(getEnv("NIX_SSHOPTS")))
|
||||||
|
|
|
@ -28,14 +28,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress, int logFD = -1)
|
SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress, int logFD = -1);
|
||||||
: host(host)
|
|
||||||
, keyFile(keyFile)
|
|
||||||
, useMaster(useMaster)
|
|
||||||
, compress(compress)
|
|
||||||
, logFD(logFD)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Connection
|
struct Connection
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue