forked from lix-project/lix
Merge pull request #9293 from ThinkChaos/ssh-misc-improvments
SSH small improvments
(cherry picked from commit dcc49744ed0c3b91f905b0f3304d3ca700f9f717)
Change-Id: Ie87910df3ab739d0ff983c085190da1d108e96e2
This commit is contained in:
parent
b7e7949035
commit
6cb215f63b
|
@ -111,9 +111,11 @@ std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string
|
||||||
reply = readLine(out.readSide.get());
|
reply = readLine(out.readSide.get());
|
||||||
} catch (EndOfFile & e) { }
|
} catch (EndOfFile & e) { }
|
||||||
|
|
||||||
if (reply != "started")
|
if (reply != "started") {
|
||||||
|
printTalkative("SSH stdout first line: %s", reply);
|
||||||
throw Error("failed to start SSH connection to '%s'", host);
|
throw Error("failed to start SSH connection to '%s'", host);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conn->out = std::move(out.readSide);
|
conn->out = std::move(out.readSide);
|
||||||
conn->in = std::move(in.writeSide);
|
conn->in = std::move(in.writeSide);
|
||||||
|
@ -129,7 +131,6 @@ Path SSHMaster::startMaster()
|
||||||
|
|
||||||
if (state->sshMaster != -1) return state->socketPath;
|
if (state->sshMaster != -1) return state->socketPath;
|
||||||
|
|
||||||
|
|
||||||
state->socketPath = (Path) *state->tmpDir + "/ssh.sock";
|
state->socketPath = (Path) *state->tmpDir + "/ssh.sock";
|
||||||
|
|
||||||
Pipe out;
|
Pipe out;
|
||||||
|
@ -141,7 +142,8 @@ Path SSHMaster::startMaster()
|
||||||
logger->pause();
|
logger->pause();
|
||||||
Finally cleanup = [&]() { logger->resume(); };
|
Finally cleanup = [&]() { logger->resume(); };
|
||||||
|
|
||||||
bool wasMasterRunning = isMasterRunning();
|
if (isMasterRunning())
|
||||||
|
return state->socketPath;
|
||||||
|
|
||||||
state->sshMaster = startProcess([&]() {
|
state->sshMaster = startProcess([&]() {
|
||||||
restoreProcessContext();
|
restoreProcessContext();
|
||||||
|
@ -162,13 +164,13 @@ Path SSHMaster::startMaster()
|
||||||
|
|
||||||
out.writeSide = -1;
|
out.writeSide = -1;
|
||||||
|
|
||||||
if (!wasMasterRunning) {
|
|
||||||
std::string reply;
|
std::string reply;
|
||||||
try {
|
try {
|
||||||
reply = readLine(out.readSide.get());
|
reply = readLine(out.readSide.get());
|
||||||
} catch (EndOfFile & e) { }
|
} catch (EndOfFile & e) { }
|
||||||
|
|
||||||
if (reply != "started")
|
if (reply != "started") {
|
||||||
|
printTalkative("SSH master stdout first line: %s", reply);
|
||||||
throw Error("failed to start SSH master connection to '%s'", host);
|
throw Error("failed to start SSH master connection to '%s'", host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue