diff options
author | Julian Andres Klode <jak@debian.org> | 2015-08-14 10:50:56 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-08-14 10:50:56 +0200 |
commit | 51c4e07f4cba0615ff269b5a8d04dfd3d1313b00 (patch) | |
tree | 40ce3c71671144c3d367d42c06a7dfa91eb8dc5e /methods/rsh.cc | |
parent | dd14b7a562c54bb9ce551da1f8a80c78da5a4b6e (diff) | |
parent | 14c50b58e938cf78ce2d32d4ec39979f7575c543 (diff) |
Merge branch 'debian/experimental' of https://github.com/DonKult/apt into debian/experimental
Diffstat (limited to 'methods/rsh.cc')
-rw-r--r-- | methods/rsh.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/methods/rsh.cc b/methods/rsh.cc index 52349c61c..7ef2f7c7a 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -84,7 +84,7 @@ bool RSHConn::Open() if (Process != -1) return true; - if (Connect(ServerName.Host,ServerName.User) == false) + if (Connect(ServerName.Host,ServerName.Port,ServerName.User) == false) return false; return true; @@ -93,8 +93,15 @@ bool RSHConn::Open() // RSHConn::Connect - Fire up rsh and connect /*{{{*/ // --------------------------------------------------------------------- /* */ -bool RSHConn::Connect(std::string Host, std::string User) +bool RSHConn::Connect(std::string Host, unsigned int Port, std::string User) { + char *PortStr = NULL; + if (Port != 0) + { + if (asprintf (&PortStr, "%d", Port) == -1 || PortStr == NULL) + return _error->Errno("asprintf", _("Failed")); + } + // Create the pipes int Pipes[4] = {-1,-1,-1,-1}; if (pipe(Pipes) != 0 || pipe(Pipes+2) != 0) @@ -140,6 +147,10 @@ bool RSHConn::Connect(std::string Host, std::string User) Args[i++] = "-l"; Args[i++] = User.c_str(); } + if (PortStr != NULL) { + Args[i++] = "-p"; + Args[i++] = PortStr; + } if (Host.empty() == false) { Args[i++] = Host.c_str(); } @@ -149,6 +160,9 @@ bool RSHConn::Connect(std::string Host, std::string User) exit(100); } + if (PortStr != NULL) + free(PortStr); + ReadFd = Pipes[0]; WriteFd = Pipes[3]; SetNonBlock(Pipes[0],true); @@ -158,6 +172,10 @@ bool RSHConn::Connect(std::string Host, std::string User) return true; } +bool RSHConn::Connect(std::string Host, std::string User) +{ + return Connect(Host, 0, User); +} /*}}}*/ // RSHConn::ReadLine - Very simple buffered read with timeout /*{{{*/ // --------------------------------------------------------------------- |