Hmm, I attached a patch file to that email, but it seems to have been stripped 
off.
Here is the patch:

>From a602b4e253e49598a3cc55d70773abca5bc459ab Mon Sep 17 00:00:00 2001
From: Richard Bradley <[email protected]>
Date: Thu, 3 Dec 2015 08:37:20 +0000
Subject: [PATCH] Add in/out wire logging for SFTP

---
.../apache/sshd/server/subsystem/sftp/SftpSubsystem.java  | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
index b47bffa..0d9fe2f 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
@@ -435,7 +435,12 @@ public class SftpSubsystem
         int type = buffer.getUByte();
         int id = buffer.getInt();
         if (log.isDebugEnabled()) {
-            log.debug("process(length={}, type={}, id={})", length, type, id);
+            log.debug("process(length={}, type={}, id={}, data={})",
+                    length, type, id,
+                    BufferUtils.printHex(
+                            buffer.array(),
+                            buffer.rpos(),
+                            Math.min(buffer.array().length - length, length)));
         }
         switch (type) {
@@ -3020,6 +3025,14 @@ public class SftpSubsystem
     protected void send(Buffer buffer) throws IOException {
         int len = buffer.available();
         BufferUtils.writeInt(out, len, workBuf, 0, workBuf.length);
+
+        if (log.isDebugEnabled()) {
+            log.debug("Send (len={}, data={})",
+                    len,
+                    BufferUtils.printHex(
+                            buffer.array(), buffer.rpos(), len));
+        }
+
         out.write(buffer.array(), buffer.rpos(), len);
         out.flush();
     }
--
2.5.3



From: Richard Bradley [mailto:[email protected]]
Sent: 03 December 2015 10:56
To: [email protected]
Subject: patch: extra DEBUG wire logging for SFTP subsystem

Hi,

I had a strange error where an SFTP client was unable to upload files: the 
transfer would start, but all the files ended up at zero length.
It turns out that the client was bugged and was assuming that all the SFTP file 
handles were "\0". This works when connecting to OpenSSH, as it always names 
its file handles "0", "1", "2" etc., but it doesn't work when connecting to 
Apache MINA (which uses random strings for file handles).

This patch adds extra logging when in DEBUG mode - I found that most SFTP 
protocol messages were being logged at DEBUG level, but not all.

I needed this extra logging to diagnose my issue: perhaps it will be useful to 
someone else later.

Best,


Rich

Richard Bradley
Tel : 020 7485 7500 ext 3230 | Fax : 020 7485 7575
softwire
Sunday Times Best Small Companies - UK top 25 five years running
Web : www.softwire.com<http://www.softwire.com/> | Follow us on Twitter : 
@SoftwireUK<https://twitter.com/SoftwireUK>
Addr : 110 Highgate Studios, 53-79 Highgate Road, London NW5 1TL
Softwire Technology Limited. Registered in England no. 3824658. Registered 
Office : Gallery Court, 28 Arcadia Avenue, Finchley, London. N3 2FG

Richard Bradley
Tel : 020 7485 7500 ext 3230 | Fax : 020 7485 7575

softwire
Sunday Times Best Small Companies - UK top 25 five years running
Web : www.softwire.com<http://www.softwire.com/> | Follow us on Twitter : 
@SoftwireUK<https://twitter.com/SoftwireUK>
Addr : 110 Highgate Studios, 53-79 Highgate Road, London NW5 1TL
Softwire Technology Limited. Registered in England no. 3824658. Registered 
Office : Gallery Court, 28 Arcadia Avenue, Finchley, London. N3 2FG

Reply via email to