From 2ace092e63f1bb85da544930a93e6bd368493d6d Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Sun, 23 Sep 2018 17:33:43 +0200 Subject: [PATCH] dird: reset or use client connection handshake modes saved in the client-config - reset all modes to kUndefined after reloading the config - safe the successful connection mode in the config - use the last saved connection mode for future connections - adapted some comments --- core/src/dird/dird_conf.cc | 14 ++++++++++++++ core/src/dird/fd_cmds.cc | 14 ++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index e7b6c802968..15f1ae5d64e 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -3794,6 +3794,18 @@ static void PrintConfigCb(ResourceItem *items, int i, PoolMem &cfg_str, bool hid } } +static void ResetAllClientConnectionHandshakeModes(ConfigurationParser &my_config) +{ + CommonResourceHeader *header = nullptr; + do { + header = my_config.GetNextRes(R_CLIENT, header); + ClientResource *client = reinterpret_cast(header); + if (client) { + client->connection_successful_handshake_ = ClientConnectionHandshakeMode::kUndefined; + } + } while (header); +} + static void ConfigReadyCallback(ConfigurationParser &my_config) { CreateAndAddUserAgentConsoleResource(my_config); @@ -3805,6 +3817,8 @@ static void ConfigReadyCallback(ConfigurationParser &my_config) {R_MSGS, "R_MSGS"}, {R_COUNTER, "R_COUNTER"}, {R_PROFILE, "R_PROFILE"}, {R_CONSOLE, "R_CONSOLE"}, {R_DEVICE, "R_DEVICE"}}; my_config.InitializeQualifiedResourceNameTypeConverter(map); + + ResetAllClientConnectionHandshakeModes(my_config); } static bool AddResourceCopyToEndOfChain(UnionOfResources *res_to_add, int type) diff --git a/core/src/dird/fd_cmds.cc b/core/src/dird/fd_cmds.cc index feb1c0e930e..c85dac35ae2 100644 --- a/core/src/dird/fd_cmds.cc +++ b/core/src/dird/fd_cmds.cc @@ -165,10 +165,16 @@ bool ConnectToFileDaemon(JobControlRecord *jcr, int retry_interval, int max_retr bool tcp_connect_failed = false; int connect_tries = 3; /* as a finish-hook for the UseWaitingClient mechanism */ - /* try the connection mode in case a client that cannot do Tls - * immediately without cleartext md5-handshake first */ - jcr->connection_handshake_try_ = ClientConnectionHandshakeMode::kTlsFirst; - jcr->res.client->connection_successful_handshake_ = ClientConnectionHandshakeMode::kUndefined; + /* try the connection modes starting with tls directly, + * in case there is a client that cannot do Tls immediately then + * fall back to cleartext md5-handshake */ + if (jcr->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined + || jcr->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kFailed) { + jcr->connection_handshake_try_ = ClientConnectionHandshakeMode::kTlsFirst; + } else { + /* if there is a stored mode from a previous connection then use this */ + jcr->connection_handshake_try_ = jcr->res.client->connection_successful_handshake_; + } do { /* while (tcp_connect_failed ...) */ /* connect the tcp socket */