References: <20200711093655.23686-1-arne@...1227...> <20200711093655.23686-3-arne@...1227...> From: tincanteksup Message-ID: <6629c113-7d01-5f7c-6592-e08f7dd2bb07@...277...> Date: Mon, 13 Jul 2020 13:50:58 +0100 MIME-Version: 1.0 In-Reply-To: <20200711093655.23686-3-arne@...1227...> Content-Language: en-GB Subject: Re: [Openvpn-devel] [PATCH v5 03/14] client-connect: Refactor multi_client_connect_source_ccd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: openvpn-devel@lists.sourceforge.net 1x grammar On 11/07/2020 10:36, Arne Schwabe wrote: > From: Fabian Knittel > > Refactor multi_client_connect_source_ccd(), so that options_server_import() (or > the success path in general) is only entered in one place within the function. > > Signed-off-by: Fabian Knittel > > Patch V5: Simplify the logic even further to make more easy to understand. grammar: to make it more easy > > Signed-off-by: Arne Schwabe > --- > src/openvpn/multi.c | 43 +++++++++++++++++++++---------------------- > 1 file changed, 21 insertions(+), 22 deletions(-) > > diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c > index 3c4ceeb5..35e0bd10 100644 > --- a/src/openvpn/multi.c > +++ b/src/openvpn/multi.c > @@ -2164,15 +2164,30 @@ multi_client_connect_source_ccd(struct multi_context *m, > if (mi->context.options.client_config_dir) > { > struct gc_arena gc = gc_new(); > - const char *ccd_file; > + const char *ccd_file = NULL; > + > + const char *ccd_client = platform_gen_path(mi->context.options.client_config_dir, > + tls_common_name(mi->context.c2.tls_multi, > + false), > + &gc); > + > + const char *ccd_default = platform_gen_path(mi->context.options.client_config_dir, > + CCD_DEFAULT, > + &gc); > > - ccd_file = platform_gen_path(mi->context.options.client_config_dir, > - tls_common_name(mi->context.c2.tls_multi, > - false), > - &gc); > > /* try common-name file */ > - if (platform_test_file(ccd_file)) > + if (platform_test_file(ccd_client)) > + { > + ccd_file = ccd_client; > + } > + /* try default file */ > + else if (platform_test_file(ccd_default)) > + { > + ccd_file = ccd_default; > + } > + > + if (ccd_file) > { > options_server_import(&mi->context.options, > ccd_file, > @@ -2181,22 +2196,6 @@ multi_client_connect_source_ccd(struct multi_context *m, > option_types_found, > mi->context.c2.es); > } > - else /* try default file */ > - { > - ccd_file = platform_gen_path(mi->context.options.client_config_dir, > - CCD_DEFAULT, > - &gc); > - > - if (platform_test_file(ccd_file)) > - { > - options_server_import(&mi->context.options, > - ccd_file, > - D_IMPORT_ERRORS|M_OPTERR, > - CLIENT_CONNECT_OPT_MASK, > - option_types_found, > - mi->context.c2.es); > - } > - } > gc_free(&gc); > } > } >