You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2017/05/15 16:38:32 UTC
[3/3] mina-sshd git commit: Add EOL at end of appended known-hosts
file entry
Add EOL at end of appended known-hosts file entry
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/6256245d
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/6256245d
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/6256245d
Branch: refs/heads/master
Commit: 6256245da6308a0aa4f94c9a3813a4d5d38b2c9e
Parents: 2119f79
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Mon May 15 16:51:21 2017 +0300
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Mon May 15 19:38:22 2017 +0300
----------------------------------------------------------------------
.../sshd/client/keyverifier/KnownHostsServerKeyVerifier.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6256245d/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java
index 8dd6ca6..1fc9429 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java
@@ -637,12 +637,15 @@ public class KnownHostsServerKeyVerifier
String line = entry.getConfigLine();
byte[] lineData = line.getBytes(StandardCharsets.UTF_8);
boolean reuseExisting = Files.exists(file) && (Files.size(file) > 0);
+ byte[] eolBytes = IoUtils.getEOLBytes();
synchronized (updateLock) {
try (OutputStream output = reuseExisting ? Files.newOutputStream(file, StandardOpenOption.APPEND) : Files.newOutputStream(file)) {
if (reuseExisting) {
- output.write(IoUtils.getEOLBytes()); // separate from previous lines
+ output.write(eolBytes); // separate from previous lines
}
+
output.write(lineData);
+ output.write(eolBytes); // add another separator for trailing lines - in case regular SSH client appends to it
}
}