浏览代码

Bug 1837: Failure when primary SSH channel fails to open

https://winscp.net/tracker/1837

Source commit: 960e31849005eccf2b81a39505a363fac0959513
Martin Prikryl 5 年之前
父节点
当前提交
d400aabc94
共有 2 个文件被更改,包括 19 次插入8 次删除
  1. 15 8
      source/core/SecureShell.cpp
  2. 4 0
      source/putty/ssh2connection.c

+ 15 - 8
source/core/SecureShell.cpp

@@ -328,6 +328,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
       {
         conf_set_str(conf, CONF_remote_cmd, AnsiString(Data->Shell).c_str());
       }
+      conf_set_bool(conf, CONF_force_remote_cmd2, 0);
     }
     else
     {
@@ -360,15 +361,21 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
           conf_set_str(conf, CONF_remote_cmd2, AnsiString(Data->Shell).c_str());
         }
       }
-
-      if ((Data->FSProtocol == fsSFTPonly) && Data->SftpServer.IsEmpty())
+      else
       {
-        // see psftp_connect() from psftp.c
-        conf_set_bool(conf, CONF_ssh_subsys2, FALSE);
-        conf_set_str(conf, CONF_remote_cmd2,
-          "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n"
-          "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n"
-          "exec sftp-server");
+        if (Data->SftpServer.IsEmpty())
+        {
+          // see psftp_connect() from psftp.c
+          conf_set_bool(conf, CONF_ssh_subsys2, FALSE);
+          conf_set_str(conf, CONF_remote_cmd2,
+            "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n"
+            "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n"
+            "exec sftp-server");
+        }
+        else
+        {
+          conf_set_bool(conf, CONF_force_remote_cmd2, 0);
+        }
       }
     }
   }

+ 4 - 0
source/putty/ssh2connection.c

@@ -336,9 +336,13 @@ static bool ssh2_connection_filter_queue(struct ssh2_connection_state *s)
 
     while (1) {
         if (ssh2_common_filter_queue(&s->ppl))
+        {
             return true;
+        }
         if ((pktin = pq_peek(s->ppl.in_pq)) == NULL)
+        {
             return false;
+        }
 
         switch (pktin->type) {
           case SSH2_MSG_GLOBAL_REQUEST: