You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2015/02/23 16:40:23 UTC

[1/2] mina-sshd git commit: [SSHD-411] SSH_FX_OP_UNSUPPORTED should not be logged as error

Repository: mina-sshd
Updated Branches:
  refs/heads/0.14.x 964e76890 -> a3e218152


[SSHD-411] SSH_FX_OP_UNSUPPORTED should not be logged as error

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/c8f56bda
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/c8f56bda
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/c8f56bda

Branch: refs/heads/0.14.x
Commit: c8f56bda0a7223b9a03fed1935fa9894aec308c2
Parents: 964e768
Author: Guillaume Nodet <gn...@apache.org>
Authored: Mon Feb 23 16:37:16 2015 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Mon Feb 23 16:37:16 2015 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/sshd/server/sftp/SftpSubsystem.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c8f56bda/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java b/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java
index 3ce1c78..07c4b20 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/sftp/SftpSubsystem.java
@@ -895,8 +895,14 @@ public class SftpSubsystem implements Command, Runnable, SessionAware, FileSyste
                 }
                 break;
             }
+            case SSH_FXP_EXTENDED: {
+                String extension = buffer.getString();
+                log.info("Received unsupported SSH_FXP_EXTENDED({})", extension);
+                sendStatus(id, SSH_FX_OP_UNSUPPORTED, "Command SSH_FXP_EXTENDED(" + extension + ") is unsupported or not implemented");
+                break;
+            }
             default: {
-                log.error("Received: {}", type);
+                log.warn("Received: {}", type);
                 sendStatus(id, SSH_FX_OP_UNSUPPORTED, "Command " + type + " is unsupported or not implemented");
                 break;
             }


[2/2] mina-sshd git commit: [SSHD-410] Do not seek on files when unnecessary

Posted by gn...@apache.org.
[SSHD-410] Do not seek on files when unnecessary

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/a3e21815
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/a3e21815
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/a3e21815

Branch: refs/heads/0.14.x
Commit: a3e21815267ad6e36c78b7c79d0baa0bec14094e
Parents: c8f56bd
Author: Guillaume Nodet <gn...@apache.org>
Authored: Mon Feb 23 16:40:08 2015 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Mon Feb 23 16:40:08 2015 +0100

----------------------------------------------------------------------
 .../common/file/nativefs/NativeSshFile.java     | 37 +++++++++++++++++---
 1 file changed, 33 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a3e21815/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeSshFile.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeSshFile.java b/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeSshFile.java
index 8b336ef..817df5f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeSshFile.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeSshFile.java
@@ -412,6 +412,18 @@ public class NativeSshFile implements SshFile {
         if (!canRead) {
             file.setReadable(true, true);
         }
+
+        /*
+         * Move to the appropriate offset only if non-zero. The reason for
+         * this check is that special "files" (e.g., /proc or /dev ones)
+         * might not support 'seek' to a specific position but rather only
+         * sequential read/write. If this is what is requested, there is no
+         * reason to risk incurring an IOException
+         */
+        if (offset == 0L) {
+            return new FileOutputStream(file);
+        }
+
         final RandomAccessFile raf = new RandomAccessFile(file, "rw");
         try {
             raf.seek(offset);
@@ -420,8 +432,11 @@ public class NativeSshFile implements SshFile {
             // objects closed to actually close the file
             return new FileOutputStream(raf.getFD()) {
                 public void close() throws IOException {
-                    super.close();
-                    raf.close();
+                    try {
+                        super.close();
+                    } finally { // make sure we close the random access file even if super close fails
+                        raf.close();
+                    }
                     if (!canRead) {
                         file.setReadable(false, true);
                     }
@@ -437,16 +452,30 @@ public class NativeSshFile implements SshFile {
      * Create input stream for reading.
      */
     public InputStream createInputStream(final long offset) throws IOException {
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("createInputStream(" + file.getAbsolutePath() + ")[" + offset + "]");
+        }
 
         // permission check
         if (!isReadable()) {
             throw new IOException("No read permission : " + file.getName());
         }
 
-        // move to the appropriate offset and create input stream
         final FileInputStream fis = new FileInputStream(file);
+        /*
+         * Move to the appropriate offset only if non-zero. The reason for
+         * this check is that special "files" (e.g., /proc or /dev ones)
+         * might not support 'seek' to a specific position but rather only
+         * sequential read/write. If this is what is requested, there is no
+         * reason to risk incurring an IOException
+         */
+        if (offset == 0L) {
+            return fis;
+        }
+
         try {
-            fis.getChannel().position(offset);
+            FileChannel channel=fis.getChannel();
+            channel.position(offset);
             return fis;
         } catch (IOException e) {
             fis.close();