Browse Source

Merge branch 'master' into dev

Conflicts:
	source/WinSCP.cbproj

Source commit: 0f6ff9f27ea2602772aa1bf4dbb8b93c2eebf05e
Martin Prikryl 9 years ago
parent
commit
efc89fad31

+ 1 - 1
source/core/Exceptions.cpp

@@ -165,7 +165,7 @@ static bool __fastcall ExceptionMessage(Exception * E, bool Count,
     Configuration->Usage->Inc(CounterName);
     UnicodeString ExceptionDebugInfo =
       E->ClassName() + L":" + GetExceptionDebugInfo();
-    Configuration->Usage->Set(L"LastInternalException", ExceptionDebugInfo);
+    Configuration->Usage->Set(LastInternalExceptionCounter, ExceptionDebugInfo);
   }
 
   return Result;

+ 3 - 0
source/core/SecureShell.cpp

@@ -353,6 +353,8 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
   conf_set_int_int(conf, CONF_ssh_hklist, 4, HK_WARN);
   DebugAssert(HK_MAX == 5);
 
+  conf_set_str(conf, CONF_loghost, AnsiString(Data->LogicalHostName).c_str());
+
   return conf;
 }
 //---------------------------------------------------------------------------
@@ -2104,6 +2106,7 @@ void __fastcall TSecureShell::GetRealHost(UnicodeString & Host, int & Port)
 {
   if (FSessionData->Tunnel)
   {
+    // Not that we set the CONF_loghost, the hostname is correct already
     Host = FSessionData->OrigHostName;
     Port = FSessionData->OrigPortNumber;
   }

+ 2 - 0
source/core/SessionData.cpp

@@ -1808,6 +1808,7 @@ void __fastcall TSessionData::ConfigureTunnel(int APortNumber)
   PortNumber = APortNumber;
   // proxy settings is used for tunnel
   ProxyMethod = ::pmNone;
+  FLogicalHostName = FOrigHostName;
 }
 //---------------------------------------------------------------------
 void __fastcall TSessionData::RollbackTunnel()
@@ -1815,6 +1816,7 @@ void __fastcall TSessionData::RollbackTunnel()
   HostName = FOrigHostName;
   PortNumber = FOrigPortNumber;
   ProxyMethod = FOrigProxyMethod;
+  FLogicalHostName = L"";
 }
 //---------------------------------------------------------------------
 void __fastcall TSessionData::ExpandEnvironmentVariables()

+ 2 - 0
source/core/SessionData.h

@@ -205,6 +205,7 @@ private:
   TProxyMethod FOrigProxyMethod;
   TSessionSource FSource;
   bool FSaveOnly;
+  UnicodeString FLogicalHostName;
 
   void __fastcall SetHostName(UnicodeString value);
   UnicodeString __fastcall GetHostNameExpanded();
@@ -580,6 +581,7 @@ public:
   __property UnicodeString StorageKey = { read = GetStorageKey };
   __property UnicodeString SiteKey = { read = GetSiteKey };
   __property UnicodeString OrigHostName = { read = FOrigHostName };
+  __property UnicodeString LogicalHostName = { read = FLogicalHostName };
   __property int OrigPortNumber = { read = FOrigPortNumber };
   __property UnicodeString LocalName = { read = GetLocalName };
   __property UnicodeString FolderName = { read = GetFolderName };

+ 7 - 0
source/core/Terminal.cpp

@@ -6056,6 +6056,13 @@ bool __fastcall TTerminal::CanRecurseToDirectory(const TRemoteFile * File)
   return !File->IsSymLink || FSessionData->FollowDirectorySymlinks;
 }
 //---------------------------------------------------------------------------
+bool __fastcall TTerminal::IsThisOrChild(TTerminal * Terminal)
+{
+  return
+    (this == Terminal) ||
+    ((FCommandSession != NULL) && (FCommandSession == Terminal));
+}
+//---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 __fastcall TSecondaryTerminal::TSecondaryTerminal(TTerminal * MainTerminal,
   TSessionData * ASessionData, TConfiguration * Configuration, const UnicodeString & Name) :

+ 1 - 0
source/core/Terminal.h

@@ -492,6 +492,7 @@ public:
   void __fastcall FatalAbort();
   void __fastcall ReflectSettings();
   void __fastcall CollectUsage();
+  bool __fastcall IsThisOrChild(TTerminal * Terminal);
 
   const TSessionInfo & __fastcall GetSessionInfo();
   const TFileSystemInfo & __fastcall GetFileSystemInfo(bool Retrieve = false);

+ 18 - 0
source/core/Usage.cpp

@@ -9,6 +9,8 @@
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 //---------------------------------------------------------------------------
+const UnicodeString LastInternalExceptionCounter(L"LastInternalException2");
+//---------------------------------------------------------------------------
 __fastcall TUsage::TUsage(TConfiguration * Configuration)
 {
   FCriticalSection = new TCriticalSection();
@@ -160,6 +162,7 @@ void __fastcall TUsage::Reset()
   TGuard Guard(FCriticalSection);
   UpdateLastReport();
   FPeriodCounters.clear();
+  ResetLastInternalException();
 }
 //---------------------------------------------------------------------------
 void __fastcall TUsage::UpdateCurrentVersion()
@@ -181,10 +184,25 @@ void __fastcall TUsage::UpdateCurrentVersion()
     {
       Inc(L"Downgrades");
     }
+
+    if (PrevVersion != CompoundVersion)
+    {
+      ResetLastInternalException();
+    }
   }
   Set(L"CurrentVersion", CompoundVersion);
 }
 //---------------------------------------------------------------------------
+void __fastcall TUsage::ResetLastInternalException()
+{
+  TGuard Guard(FCriticalSection);
+  int Index = FValues->IndexOfName(LastInternalExceptionCounter);
+  if (Index >= 0)
+  {
+    FValues->Delete(Index);
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall TUsage::Inc(const UnicodeString & Key, int Increment)
 {
   if (Collect)

+ 3 - 0
source/core/Usage.h

@@ -51,6 +51,9 @@ private:
   void __fastcall SetMax(const UnicodeString & Key, int Value, TCounters & Counters);
   void __fastcall Serialize(UnicodeString& List,
     const UnicodeString & Name, const TCounters & Counters) const;
+  void __fastcall ResetLastInternalException();
 };
 //---------------------------------------------------------------------------
+extern const UnicodeString LastInternalExceptionCounter;
+//---------------------------------------------------------------------------
 #endif

+ 2 - 2
source/forms/CopyParams.dfm

@@ -333,9 +333,9 @@ object CopyParamsFrame: TCopyParamsFrame
       OnClick = ControlChange
     end
     object IncludeFileMaskHintText: TStaticText
-      Left = 204
+      Left = 184
       Top = 58
-      Width = 105
+      Width = 125
       Height = 17
       Alignment = taRightJustify
       AutoSize = False

+ 9 - 4
source/forms/CustomScpExplorer.cpp

@@ -4800,7 +4800,7 @@ bool __fastcall TCustomScpExplorerForm::DoSynchronizeDirectories(
       FLAGMASK(SynchronizeAllowSelectedOnly(), soAllowSelectedOnly);
     DebugAssert(FOnFeedSynchronizeError == NULL);
     Result = DoSynchronizeDialog(Params, &CopyParam, Controller.StartStop,
-      SaveSettings, Options, CopyParamAttrs, GetSynchronizeOptions,
+      SaveSettings, Options, CopyParamAttrs, GetSynchronizeOptions, SynchronizeSessionLog,
       FOnFeedSynchronizeError, UseDefaults);
     if (Result)
     {
@@ -4973,6 +4973,11 @@ bool __fastcall TCustomScpExplorerForm::SynchronizeAllowSelectedOnly()
      (HasDirView[osLocal] && (DirView(osLocal)->SelCount > 0)));
 }
 //---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::SynchronizeSessionLog(const UnicodeString & Message)
+{
+  LogSynchronizeEvent(Terminal, Message);
+}
+//---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::GetSynchronizeOptions(
   int Params, TSynchronizeOptions & Options)
 {
@@ -7315,10 +7320,10 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDQueryContinueDrag(
       // If downloading fails we need to cancel drag&drop, otherwise
       // Explorer shows error
       // But by the way exception probably never reach this point as
-      // it's catched on way
+      // it's catched on way.
+      // Fatal exceptions get here (like when opening a secondary shell extension for file duplication fails).
       Result = DRAGDROP_S_CANCEL;
-      DebugAssert(Terminal != NULL);
-      Terminal->ShowExtendedException(&E);
+      ShowExtendedException(Terminal, &E);
     }
   }
 }

+ 1 - 0
source/forms/CustomScpExplorer.h

@@ -394,6 +394,7 @@ protected:
     const UnicodeString RemoteDirectory, TSynchronizeMode Mode,
     const TCopyParamType & CopyParam, int Params, TSynchronizeChecklist ** Checklist,
     TSynchronizeOptions * Options);
+  void __fastcall SynchronizeSessionLog(const UnicodeString & Message);
   void __fastcall GetSynchronizeOptions(int Params, TSynchronizeOptions & Options);
   bool __fastcall SynchronizeAllowSelectedOnly();
   virtual void __fastcall BatchStart(void *& Storage);

+ 2 - 2
source/forms/EditMask.dfm

@@ -208,9 +208,9 @@ object EditMaskDialog: TEditMaskDialog
     end
   end
   object MaskHintText: TStaticText
-    Left = 312
+    Left = 288
     Top = 369
-    Width = 105
+    Width = 129
     Height = 17
     Alignment = taRightJustify
     AutoSize = False

+ 2 - 2
source/forms/FileFind.dfm

@@ -1426,9 +1426,9 @@ object FileFindDialog: TFileFindDialog
       OnExit = MaskEditExit
     end
     object MaskHintText: TStaticText
-      Left = 248
+      Left = 240
       Top = 59
-      Width = 116
+      Width = 124
       Height = 17
       Alignment = taRightJustify
       Anchors = [akTop, akRight]

+ 6 - 1
source/forms/Synchronize.cpp

@@ -31,13 +31,14 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
   const TCopyParamType * CopyParams, TSynchronizeStartStopEvent OnStartStop,
   bool & SaveSettings, int Options, int CopyParamAttrs,
   TGetSynchronizeOptionsEvent OnGetOptions,
+  TSynchronizeSessionLog OnSynchronizeSessionLog,
   TFeedSynchronizeError & OnFeedSynchronizeError,
   bool Start)
 {
   bool Result;
   TSynchronizeDialog * Dialog = SafeFormCreate<TSynchronizeDialog>(Application);
 
-  Dialog->Init(OnStartStop, OnGetOptions, OnFeedSynchronizeError, Start);
+  Dialog->Init(OnStartStop, OnGetOptions, OnSynchronizeSessionLog, OnFeedSynchronizeError, Start);
 
   try
   {
@@ -91,11 +92,13 @@ __fastcall TSynchronizeDialog::TSynchronizeDialog(TComponent * Owner)
 //---------------------------------------------------------------------------
 void __fastcall TSynchronizeDialog::Init(TSynchronizeStartStopEvent OnStartStop,
   TGetSynchronizeOptionsEvent OnGetOptions,
+  TSynchronizeSessionLog OnSynchronizeSessionLog,
   TFeedSynchronizeError & OnFeedSynchronizeError,
   bool StartImmediately)
 {
   FOnStartStop = OnStartStop;
   FOnGetOptions = OnGetOptions;
+  FOnSynchronizeSessionLog = OnSynchronizeSessionLog;
   FOnFeedSynchronizeError = &OnFeedSynchronizeError;
   FStartImmediately = StartImmediately;
 }
@@ -375,6 +378,8 @@ void __fastcall TSynchronizeDialog::DoLogInternal(
       LogView->Repaint();
     }
   }
+
+  FOnSynchronizeSessionLog(Message);
 }
 //---------------------------------------------------------------------------
 void __fastcall TSynchronizeDialog::DoLog(TSynchronizeController * /*Controller*/,

+ 2 - 0
source/forms/Synchronize.h

@@ -77,6 +77,7 @@ private:
   TSynchronizeParamType FParams;
   TSynchronizeStartStopEvent FOnStartStop;
   TGetSynchronizeOptionsEvent FOnGetOptions;
+  TSynchronizeSessionLog FOnSynchronizeSessionLog;
   int FOptions;
   int FCopyParamAttrs;
   bool FSynchronizing;
@@ -125,6 +126,7 @@ public:
   __fastcall TSynchronizeDialog(TComponent * Owner);
   void __fastcall Init(TSynchronizeStartStopEvent OnStartStop,
     TGetSynchronizeOptionsEvent OnGetOptions,
+    TSynchronizeSessionLog OnSynchronizeSessionLog,
     TFeedSynchronizeError & OnFeedSynchronizeError, bool StartImmediately);
   virtual __fastcall ~TSynchronizeDialog();
 

+ 12 - 0
source/putty/ssh.c

@@ -10000,6 +10000,10 @@ static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
 		int micoffset, len;
 		char *data;
 		Ssh_gss_buf mic;
+#ifdef MPEXT
+		const char * fullhostname;
+		char *loghost;
+#endif
 		s->type = AUTH_TYPE_GSSAPI;
 		s->tried_gssapi = TRUE;
 		s->gotit = TRUE;
@@ -10079,6 +10083,14 @@ static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
 		}
 
 		/* now start running */
+#ifdef MPEXT
+		fullhostname = ssh->fullhostname;
+		loghost = conf_get_str(ssh->conf, CONF_loghost);
+		if (loghost[0] != '\0')
+		{
+		  fullhostname = loghost;
+		}
+#endif
 		s->gss_stat = s->gsslib->import_name(s->gsslib,
 						     ssh->fullhostname,
 						     &s->gss_srv_name);

+ 2 - 2
source/resource/TextsWin.h

@@ -433,9 +433,9 @@
 #define CIPHER_NAME_WARN        1794
 #define CIPHER_NAME_3DES        1795
 #define CIPHER_NAME_BLOWFISH    1796
-#define CIPHER_NAME_AES         1797
+#define CIPHER_NAME_AES2        1797
 #define CIPHER_NAME_DES         1798
-#define CIPHER_NAME_ARCFOUR     1799
+#define CIPHER_NAME_ARCFOUR2    1799
 #define CIPHER_NAME_CHACHA20    1800
 #define KEX_NAME_WARN           1801
 #define KEX_NAME_DHGROUP1       1802

+ 2 - 2
source/resource/TextsWin1.rc

@@ -437,9 +437,9 @@ BEGIN
         CIPHER_NAME_WARN, "-- warn below here --"
         CIPHER_NAME_3DES, "3DES"
         CIPHER_NAME_BLOWFISH, "Blowfish"
-        CIPHER_NAME_AES, "AES"
+        CIPHER_NAME_AES2, "AES"
         CIPHER_NAME_DES, "DES"
-        CIPHER_NAME_ARCFOUR, "Arcfour"
+        CIPHER_NAME_ARCFOUR2, "Arcfour"
         CIPHER_NAME_CHACHA20, "ChaCha20"
         KEX_NAME_WARN, "-- warn below here --"
         KEX_NAME_DHGROUP1, "Diffie-Hellman group 1"

+ 1 - 0
source/windows/ConsoleRunner.cpp

@@ -1724,6 +1724,7 @@ void __fastcall TConsoleRunner::SynchronizeControllerLog(
   const UnicodeString Message)
 {
   PrintMessage(Message);
+  LogSynchronizeEvent(FScript->Terminal, Message);
 }
 //---------------------------------------------------------------------------
 void __fastcall TConsoleRunner::SynchronizeControllerAbort(TObject * /*Sender*/,

+ 8 - 0
source/windows/SynchronizeController.cpp

@@ -267,3 +267,11 @@ void __fastcall TSynchronizeController::SynchronizeDirectoriesChange(
 {
   SynchronizeLog(slDirChange, FMTLOAD(SYNCHRONIZE_START, (Directories)));
 }
+//---------------------------------------------------------------------------
+void __fastcall LogSynchronizeEvent(TTerminal * Terminal, const UnicodeString & Message)
+{
+  if (Terminal != NULL)
+  {
+    Terminal->LogEvent(FORMAT("Keep up to date: %s", (Message)));
+  }
+}

+ 2 - 0
source/windows/SynchronizeController.h

@@ -83,4 +83,6 @@ private:
   void __fastcall SynchronizeDirectoriesChange(TObject * Sender, int Directories);
 };
 //---------------------------------------------------------------------------
+void __fastcall LogSynchronizeEvent(TTerminal * Terminal, const UnicodeString & Message);
+//---------------------------------------------------------------------------
 #endif

+ 2 - 2
source/windows/UserInterface.cpp

@@ -173,10 +173,10 @@ void __fastcall ShowExtendedExceptionEx(TTerminal * Terminal,
       WinConfiguration->ConfirmExitOnCompletion;
 
     if (E->InheritsFrom(__classid(EFatal)) && (Terminal != NULL) &&
-        (Manager != NULL) && (Manager->ActiveTerminal == Terminal))
+        (Manager != NULL) && (Manager->ActiveTerminal != NULL) && Manager->ActiveTerminal->IsThisOrChild(Terminal))
     {
       int SessionReopenTimeout = 0;
-      TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Terminal);
+      TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Manager->ActiveTerminal);
       if ((ManagedTerminal != NULL) &&
           ((Configuration->SessionReopenTimeout == 0) ||
            ((double)ManagedTerminal->ReopenStart == 0) ||

+ 1 - 1
source/windows/WinConfiguration.cpp

@@ -3070,7 +3070,7 @@ bool __fastcall TCustomCommandType::ParseOption(const UnicodeString & Value, TOp
           Result = true;
         }
 
-        if (Result && Option.IsControl)
+        if (Result)
         {
           if (CutTokenEx(Buf, Option.Default))
           {

+ 3 - 0
source/windows/WinInterface.h

@@ -318,6 +318,8 @@ const soNoMinimize =       0x02;
 const soAllowSelectedOnly = 0x04;
 typedef void __fastcall (__closure *TGetSynchronizeOptionsEvent)
   (int Params, TSynchronizeOptions & Options);
+typedef void __fastcall (__closure *TSynchronizeSessionLog)
+  (const UnicodeString & Message);
 typedef void __fastcall (__closure *TFeedSynchronizeError)
   (const UnicodeString & Message, TStrings * MoreMessages, TQueryType Type,
    const UnicodeString & HelpKeyword);
@@ -325,6 +327,7 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
   const TCopyParamType * CopyParams, TSynchronizeStartStopEvent OnStartStop,
   bool & SaveSettings, int Options, int CopyParamAttrs,
   TGetSynchronizeOptionsEvent OnGetOptions,
+  TSynchronizeSessionLog OnSynchronizeSessionLog,
   TFeedSynchronizeError & OnFeedSynchronizeError,
   bool Start);