From 763176ea7033e5f9fae41461a0e75d1bc1383db1 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Fri, 8 Mar 2024 14:28:30 +0100 Subject: [PATCH] Options: do not error out on client + pull Config client pull was not correctly handled like client + tls-client since the code short-circuited if tls-client wasn't set and so didn't touch pull option. Github: #277 Signed-off-by: Frank Lichtenheld --- openvpn/client/cliopthelper.hpp | 8 ++++++-- test/unittests/test_cliopt.cpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openvpn/client/cliopthelper.hpp b/openvpn/client/cliopthelper.hpp index 5bb3050ba..0d156a6fa 100644 --- a/openvpn/client/cliopthelper.hpp +++ b/openvpn/client/cliopthelper.hpp @@ -366,8 +366,12 @@ class ParseClientConfig // add in missing options bool added = false; - // client - if (options.exists("tls-client") && options.exists("pull")) + /* client + Ensure that we always look at both options, so they register as touched */ + const bool tls_client_exists = options.exists("tls-client"); + const bool pull_exists = options.exists("pull"); + + if (tls_client_exists && pull_exists) { Option opt; opt.push_back("client"); diff --git a/test/unittests/test_cliopt.cpp b/test/unittests/test_cliopt.cpp index a0dab0c66..6c97d85ab 100644 --- a/test/unittests/test_cliopt.cpp +++ b/test/unittests/test_cliopt.cpp @@ -240,6 +240,7 @@ INSTANTIATE_TEST_SUITE_P( certconfig + "\nremote 1.2.3.4\ntls-client\npull\n", /* Should not trigger an error. Redundant options are no problem */ certconfig + "\nremote 1.2.3.4\ntls-client\npull\nclient\n", + certconfig + "\nremote 1.2.3.4\npull\nclient\n", certconfig + "\nremote 1.2.3.4\nclient\ntls-client\n")); INSTANTIATE_TEST_SUITE_P(