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 2015/11/16 07:16:10 UTC
[1/2] mina-sshd git commit: [SSHD-585] sshd performs LF->CRLF to
output
Repository: mina-sshd
Updated Branches:
refs/heads/master bc0ab58ba -> 67f75c24b
[SSHD-585] sshd performs LF->CRLF to output
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/c3be4f3c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/c3be4f3c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/c3be4f3c
Branch: refs/heads/master
Commit: c3be4f3c20f7cd3d09812831545e2cefb42b7e84
Parents: bc0ab58
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Mon Nov 16 08:15:39 2015 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Mon Nov 16 08:15:39 2015 +0200
----------------------------------------------------------------------
.../common/util/buffer/ByteArrayBuffer.java | 8 +-
.../sshd/server/shell/TtyFilterInputStream.java | 64 ++++++---
.../server/shell/TtyFilterOutputStream.java | 28 +++-
.../apache/sshd/server/shell/TtyOptions.java | 33 ++++-
.../server/shell/TtyFilterInputStreamTest.java | 123 ++++++++++++++++
.../server/shell/TtyFilterOutputStreamTest.java | 140 +++++++++++++++++++
6 files changed, 364 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c3be4f3c/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/ByteArrayBuffer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/ByteArrayBuffer.java b/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/ByteArrayBuffer.java
index bd39da5..aaec9c6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/ByteArrayBuffer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/ByteArrayBuffer.java
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
import org.apache.sshd.common.util.Int2IntFunction;
import org.apache.sshd.common.util.Readable;
+import org.apache.sshd.common.util.ValidateUtils;
/**
* Provides an implementation of {@link Buffer} using a backing byte array
@@ -80,7 +81,9 @@ public final class ByteArrayBuffer extends Buffer {
@Override
public void wpos(int wpos) {
- ensureCapacity(wpos - this.wpos);
+ if (wpos > this.wpos) {
+ ensureCapacity(wpos - this.wpos);
+ }
this.wpos = wpos;
}
@@ -139,6 +142,7 @@ public final class ByteArrayBuffer extends Buffer {
@Override
public void putRawBytes(byte[] d, int off, int len) {
+ ValidateUtils.checkTrue(len >= 0, "Negative raw bytes length: %d", len);
ensureCapacity(len);
System.arraycopy(d, off, data, wpos, len);
wpos += len;
@@ -165,6 +169,8 @@ public final class ByteArrayBuffer extends Buffer {
@Override
public void ensureCapacity(int capacity, Int2IntFunction growthFactor) {
+ ValidateUtils.checkTrue(capacity >= 0, "Negative capacity requested: %d", capacity);
+
int maxSize = size();
int curPos = wpos();
int remaining = maxSize - curPos;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c3be4f3c/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
index fd5ffcb..3059c8c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
@@ -18,9 +18,11 @@
*/
package org.apache.sshd.server.shell;
+import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StreamCorruptedException;
import java.util.Collection;
import java.util.Set;
@@ -36,14 +38,17 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
*/
public class TtyFilterInputStream extends FilterInputStream {
private final Set<TtyOptions> ttyOptions;
- private Buffer buffer;
- private int lastChar;
+ private Buffer buffer = new ByteArrayBuffer(32);
+ private int lastChar = -1;
public TtyFilterInputStream(InputStream in, Collection<TtyOptions> ttyOptions) {
super(in);
// we create a copy of the options so as to avoid concurrent modifications
this.ttyOptions = GenericUtils.of(ttyOptions);
- this.buffer = new ByteArrayBuffer(32);
+
+ if (this.ttyOptions.contains(TtyOptions.LfOnlyInput) && this.ttyOptions.contains(TtyOptions.CrLfInput)) {
+ throw new IllegalArgumentException("Ambiguous TTY options: " + ttyOptions);
+ }
}
public synchronized void write(int c) {
@@ -61,37 +66,62 @@ public class TtyFilterInputStream extends FilterInputStream {
@Override
public synchronized int read() throws IOException {
- int c;
- if (buffer.available() > 0) {
- c = buffer.getByte();
- buffer.compact();
- } else {
- c = super.read();
+ int c = readRawInput();
+ if (c == -1) {
+ return c;
}
- if ((c == '\n') && ttyOptions.contains(TtyOptions.ONlCr) && (lastChar != '\r')) {
- c = '\r';
- Buffer buf = new ByteArrayBuffer();
- buf.putByte((byte) '\n');
- buf.putBuffer(buffer);
- buffer = buf;
- } else if ((c == '\r') && ttyOptions.contains(TtyOptions.OCrNl)) {
- c = '\n';
+ if ((c == '\r') && ttyOptions.contains(TtyOptions.LfOnlyInput)) {
+ c = readRawInput();
+ if (c == -1) {
+ throw new EOFException("Premature EOF while waiting for LF after CR");
+ }
+
+ if (c != '\n') {
+ throw new StreamCorruptedException("CR not followed by LF");
+ }
+ }
+
+ if ((c == '\n') && ttyOptions.contains(TtyOptions.CrLfInput)) {
+ if (lastChar != '\r') {
+ c = '\r';
+ Buffer buf = new ByteArrayBuffer();
+ buf.putByte((byte) '\n');
+ buf.putBuffer(buffer);
+ buffer = buf;
+ }
}
+
lastChar = c;
return c;
}
+ protected int readRawInput() throws IOException {
+ // see if have any pending data
+ if (buffer.available() > 0) {
+ int c = buffer.getUByte();
+ buffer.compact();
+ return c;
+ }
+
+ return super.read();
+ }
+
@Override
public synchronized int read(byte[] b, int off, int len) throws IOException {
if (buffer.available() == 0) {
int nb = super.read(b, off, len);
+ if (nb == -1) {
+ return -1;
+ }
buffer.putRawBytes(b, off, nb);
}
+
int nb = 0;
while ((nb < len) && (buffer.available() > 0)) {
b[off + nb++] = (byte) read();
}
+
return nb;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c3be4f3c/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
index 6461ef0..010eb28 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
@@ -29,28 +29,42 @@ import org.apache.sshd.common.util.ValidateUtils;
/**
* Handles the output stream while taking care of the {@link TtyOptions} for CR / LF
- * and ECHO settings
+ * and ECHO settings. <B>Note:</B> does not close the echo stream when filter stream is closed
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class TtyFilterOutputStream extends FilterOutputStream {
private final Set<TtyOptions> ttyOptions;
private TtyFilterInputStream echo;
+ private int lastChar = -1;
public TtyFilterOutputStream(OutputStream out, TtyFilterInputStream echo, Collection<TtyOptions> ttyOptions) {
super(out);
// we create a copy of the options so as to avoid concurrent modifications
this.ttyOptions = GenericUtils.of(ttyOptions);
+ if (this.ttyOptions.contains(TtyOptions.LfOnlyOutput) && this.ttyOptions.contains(TtyOptions.CrLfOutput)) {
+ throw new IllegalArgumentException("Ambiguous TTY options: " + this.ttyOptions);
+ }
+
this.echo = this.ttyOptions.contains(TtyOptions.Echo) ? ValidateUtils.checkNotNull(echo, "No echo stream") : echo;
}
@Override
public void write(int c) throws IOException {
- if ((c == '\n') && ttyOptions.contains(TtyOptions.INlCr)) {
- c = '\r';
- } else if ((c == '\r') && ttyOptions.contains(TtyOptions.ICrNl)) {
- c = '\n';
+ if ((c == '\r') && ttyOptions.contains(TtyOptions.LfOnlyOutput)) {
+ lastChar = c;
+ return;
+ }
+
+ if ((c == '\n') && ttyOptions.contains(TtyOptions.CrLfOutput) && (lastChar != '\r')) {
+ writeRawOutput('\r');
}
+
+ writeRawOutput(c);
+ }
+
+ protected void writeRawOutput(int c) throws IOException {
+ lastChar = c;
super.write(c);
if (ttyOptions.contains(TtyOptions.Echo)) {
echo.write(c);
@@ -59,8 +73,8 @@ public class TtyFilterOutputStream extends FilterOutputStream {
@Override
public void write(byte[] b, int off, int len) throws IOException {
- for (int i = off; i < len; i++) {
- write(b[i]);
+ for (int curPos = off, l = 0; l < len; curPos++, l++) {
+ write(b[curPos]);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c3be4f3c/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyOptions.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyOptions.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyOptions.java
index 0334631..d0192e8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyOptions.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyOptions.java
@@ -25,21 +25,40 @@ import java.util.Set;
import org.apache.sshd.common.util.OsUtils;
/**
- * Options controlling the I/O streams behavior
+ * Options controlling the I/O streams behavior regarding CR/LF and echoing
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public enum TtyOptions {
+ /**
+ * Echo the output
+ */
Echo,
- INlCr,
- ICrNl,
- ONlCr,
- OCrNl;
+ /**
+ * Convert CRLF to LF if not already such when writing to output stream
+ */
+ LfOnlyOutput,
+ /**
+ * Convert LF to CRLF if not already such when writing to output stream
+ */
+ CrLfOutput,
+ /**
+ * Convert LF to CRLF if not already such when reading from input stream
+ */
+ CrLfInput,
+ /**
+ * Convert CRLF to LF if not already such when reading from input stream
+ */
+ LfOnlyInput;
public static final Set<TtyOptions> LINUX_OPTIONS =
- Collections.unmodifiableSet(EnumSet.of(TtyOptions.ONlCr));
+ Collections.unmodifiableSet(EnumSet.of(TtyOptions.LfOnlyOutput, TtyOptions.LfOnlyInput));
+ /*
+ * NOTE !!! the assumption is that a Windows server is writing to a Linux
+ * client (the most likely) thus it expects CRLF on input, but outputs LF only
+ */
public static final Set<TtyOptions> WINDOWS_OPTIONS =
- Collections.unmodifiableSet(EnumSet.of(TtyOptions.Echo, TtyOptions.ICrNl, TtyOptions.ONlCr));
+ Collections.unmodifiableSet(EnumSet.of(TtyOptions.Echo, TtyOptions.LfOnlyOutput, TtyOptions.CrLfInput));
public static Set<TtyOptions> resolveDefaultTtyOptions() {
return resolveTtyOptions(OsUtils.isWin32());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c3be4f3c/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
new file mode 100644
index 0000000..e3b1e56
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.server.shell;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TtyFilterInputStreamTest extends BaseTestSupport {
+ public TtyFilterInputStreamTest() {
+ super();
+ }
+
+ @Test
+ public void testLfOnlyStream() throws IOException {
+ List<String> expected = createTestLines();
+ List<String> actual = new ArrayList<>(expected.size());
+ byte[] data = GenericUtils.join(expected, "\r\n").getBytes(StandardCharsets.UTF_8);
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ TtyFilterInputStream tty = new TtyFilterInputStream(bais, Collections.singleton(TtyOptions.LfOnlyInput)) {
+ private long offset;
+
+ @Override
+ public synchronized int read() throws IOException {
+ int c = super.read();
+ if (c == -1) {
+ return -1;
+ }
+
+ offset++;
+ if (c == '\n') {
+ offset++; // compensate for CR filtering
+ }
+ assertFalse("Unexpected CR at offset=" + offset, c == '\r');
+ return c;
+ }
+ };
+ BufferedReader rdr = new BufferedReader(new InputStreamReader(tty, StandardCharsets.UTF_8))) {
+
+ for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
+ actual.add(line);
+ }
+ }
+
+ assertListEquals("Mismatched lines", expected, actual);
+ }
+
+ @Test
+ public void testCrLfStream() throws IOException {
+ List<String> expected = createTestLines();
+ List<String> actual = new ArrayList<>(expected.size());
+ byte[] data = GenericUtils.join(expected, '\n').getBytes(StandardCharsets.UTF_8);
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ TtyFilterInputStream tty = new TtyFilterInputStream(bais, Collections.singleton(TtyOptions.CrLfInput)) {
+ private long offset;
+ private int lastChar = -1;
+
+ @Override
+ public synchronized int read() throws IOException {
+ int c = super.read();
+ if (c == -1) {
+ return -1;
+ }
+
+ if (c != '\r') {
+ offset++;
+ }
+
+ if (c == '\n') {
+ assertEquals("LF not preceded by CR at offset=" + offset, '\r', lastChar);
+ }
+
+ lastChar = c;
+ return c;
+ }
+ };
+ BufferedReader rdr = new BufferedReader(new InputStreamReader(tty, StandardCharsets.UTF_8))) {
+
+ for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
+ actual.add(line);
+ }
+ }
+
+ assertListEquals("Mismatched lines", expected, actual);
+ }
+
+ private List<String> createTestLines() {
+ return Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName(), new Date(System.currentTimeMillis()).toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c3be4f3c/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
new file mode 100644
index 0000000..e21f273
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.server.shell;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.List;
+
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TtyFilterOutputStreamTest extends BaseTestSupport {
+ public TtyFilterOutputStreamTest() {
+ super();
+ }
+
+ @Test
+ public void testNoEchoIfNotInTtyOptions() throws IOException {
+ try (TtyFilterInputStream ttyIn = new TtyFilterInputStream(new ByteArrayInputStream(GenericUtils.EMPTY_BYTE_ARRAY), Collections.<TtyOptions>emptySet());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(Byte.MAX_VALUE);
+ TtyFilterOutputStream ttyOut = new TtyFilterOutputStream(baos, ttyIn, Collections.<TtyOptions>emptySet())) {
+
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(ttyOut, StandardCharsets.UTF_8))) {
+ writer.append(getClass().getName()).append('#').append(getCurrentTestName());
+ writer.newLine();
+ }
+
+ assertEquals("Unexpected data echoed", 0, ttyIn.available());
+ }
+ }
+
+ @Test
+ public void testLfOnlyOutput() throws IOException {
+ List<String> expected = createTestLines();
+ byte[] data = GenericUtils.join(expected, "\r\n").getBytes(StandardCharsets.UTF_8);
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length)) {
+ try (TtyFilterOutputStream ttyOut = new TtyFilterOutputStream(baos, null, EnumSet.of(TtyOptions.LfOnlyOutput)) {
+ private long offset;
+
+ @Override
+ protected void writeRawOutput(int c) throws IOException {
+ offset++;
+ if (c == '\n') {
+ offset++; // compensate for CR filtering
+ }
+ assertNotEquals("Unexpected CR at offset=" + offset, '\r', c);
+ super.writeRawOutput(c);
+ }
+ }) {
+ ttyOut.write(data);
+ }
+
+ List<String> actual = new ArrayList<>(expected.size());
+ try (BufferedReader rdr = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()), StandardCharsets.UTF_8))) {
+ for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
+ actual.add(line);
+ }
+ }
+
+ assertListEquals("Mismatched read lines", expected, actual);
+ }
+ }
+
+ @Test
+ public void testCrLfOutput() throws IOException {
+ List<String> expected = createTestLines();
+ byte[] data = GenericUtils.join(expected, '\n').getBytes(StandardCharsets.UTF_8);
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length)) {
+ try (TtyFilterOutputStream ttyOut = new TtyFilterOutputStream(baos, null, EnumSet.of(TtyOptions.CrLfOutput)) {
+ private long offset;
+ private int lastChar = -1;
+
+ @Override
+ protected void writeRawOutput(int c) throws IOException {
+ if (c != '\r') {
+ offset++; // compensate for CR insertion
+ }
+
+ if (c == '\n') {
+ assertEquals("No CR at offset=" + offset, '\r', lastChar);
+ }
+
+ super.writeRawOutput(c);
+ lastChar = c;
+ }
+ }) {
+ ttyOut.write(data);
+ }
+
+ List<String> actual = new ArrayList<>(expected.size());
+ try (BufferedReader rdr = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()), StandardCharsets.UTF_8))) {
+ for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
+ actual.add(line);
+ }
+ }
+
+ assertListEquals("Mismatched read lines", expected, actual);
+ }
+ }
+
+ private List<String> createTestLines() {
+ return Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName(), new Date(System.currentTimeMillis()).toString());
+ }
+
+}
[2/2] mina-sshd git commit: Demoted some log messages from INFO to
DEBUG level
Posted by lg...@apache.org.
Demoted some log messages from INFO to DEBUG level
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/67f75c24
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/67f75c24
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/67f75c24
Branch: refs/heads/master
Commit: 67f75c24bcd04845ad3b4083d9255601f7db8a5c
Parents: c3be4f3
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Mon Nov 16 08:15:59 2015 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Mon Nov 16 08:15:59 2015 +0200
----------------------------------------------------------------------
.../org/apache/sshd/client/session/ClientConnectionService.java | 4 +++-
.../java/org/apache/sshd/client/session/ClientSessionImpl.java | 2 +-
.../main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java | 4 +++-
.../main/java/org/apache/sshd/server/shell/ProcessShell.java | 5 ++++-
4 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/67f75c24/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
index bd8d0db..db400aa 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
@@ -77,7 +77,9 @@ public class ClientConnectionService extends AbstractConnectionService {
buf.putBoolean(false);
session.writePacket(buf);
} catch (IOException e) {
- log.info("Error sending keepalive message=" + request, e);
+ if (log.isDebugEnabled()) {
+ log.debug("Error (" + e.getClass().getSimpleName() + ") sending keepalive message=" + request + ": " + e.getMessage());
+ }
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/67f75c24/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index ce597ec..06c0a6e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -329,7 +329,7 @@ public class ClientSessionImpl extends AbstractSession implements ClientSession
} else if ((!c2sEncClientNone) || (!s2cEncClientNone)) {
kexFuture.setValue(new SshException("Client does not support none cipher"));
} else {
- log.info("Switching to none cipher");
+ log.info("Switching to none cipher " + this);
Map<KexProposalOption, String> proposal = new EnumMap<KexProposalOption, String>(KexProposalOption.class);
synchronized (clientProposal) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/67f75c24/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
index b9d6a22..3a96e00 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
@@ -160,7 +160,9 @@ public class UserAuthGSS extends AbstractUserAuth {
if (established && (identity == null)) {
identity = context.getSrcName().toString();
- log.info("GSS identity is {}", identity);
+ if (log.isDebugEnabled()) {
+ log.info("GSS identity is {}", identity);
+ }
if (!auth.validateIdentity(session, identity)) {
return Boolean.FALSE;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/67f75c24/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
index 1fa9b6f..b964506 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
@@ -73,7 +73,10 @@ public class ProcessShell extends AbstractLoggingBean implements InvertedShell {
}
}
- log.info("Starting shell with command: '{}' and env: {}", builder.command(), builder.environment());
+ if (log.isDebugEnabled()) {
+ log.debug("Starting shell with command: '{}' and env: {}", builder.command(), builder.environment());
+ }
+
process = builder.start();
out = new TtyFilterInputStream(process.getInputStream(), ttyOptions);
err = new TtyFilterInputStream(process.getErrorStream(), ttyOptions);